javivelasco / react-css-themr

Easy theming and composition for CSS Modules.
MIT License
591 stars 68 forks source link

Add namespace support #14

Closed denisborovikov closed 8 years ago

denisborovikov commented 8 years ago

Result of discussing started in https://github.com/javivelasco/react-css-themr/issues/11

import theme from './section.css';

const Section = () => (
  <section className={theme.content}>
    <Button theme={theme} namespace="button" />
  </section>
);
/* Section.css */
.content {
  border: 1px solid red;
}

.buttonContent {
  color: red;
}

If namespace prop set, only namespaced keys will be passed to the component within theme. I.e. content will be dropped, buttonContent will be converted to content.

javivelasco commented 8 years ago

Amazing, thank you so much!

The only thing that worries me a bit is the usage of a namespace property instead of something like themeNamespace. It's cleaner this way but I wonder if somebody may find it troublesome. What do you think? should be use a more specific prop name?

Great work!

denisborovikov commented 8 years ago

Thank you!

Let's make it clear. I've renamed namespace to themeNamespace.

javivelasco commented 8 years ago

Great! I think it's better like this. Also (in another issue) I think we should make homogeneous props namespacing compose the same way: themeCompose instead of composeTheme :)

denisborovikov commented 8 years ago

And update documentation as well :) Thank you for the merge.

klimashkin commented 7 years ago

And update documentation as well :) Thank you for the merge.

I accidently found namespaces support by searching word 'namespace' in themr.js, assuming it should be somewhere there. Not by reading docs. Namespacing is the most demanded feature, using react-css-themr people independently come to question like was describe in #11. So, docs are really needed for newcomers)

javivelasco commented 7 years ago

You are right @klimashkin I'm opening an issue to update the docs. I'll try to do it as soon as possible but I'm really lacking time so contributions are very welcome on this