-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document namespaced theme feature #31
Comments
I think it would also be nice to update the rest of the docs including new features: nested themes, theme spreads etc. |
Do you plan to support namespaces in default/from context theme? |
@artem-popov The problem with namespaces is that //parent.css
.container {
...
}
.child__container {
}
.child__content {
} then instead of using //parent.css
.container {
}
//parent-child.css
.container {
}
.content {
} Then when rendering you should pass child's theme object instead of namespace string. import { themr } from 'react-css-themr';
import * as css from './parent.css';
const Parent = ({theme}) => (
<div className={theme.container}>
<Child theme={theme} themeNamespace="child__"/>
</div>
);
const ThemedParent = themr(Symbol(), css)(Parent); you should use import { themr, themeable } from 'react-css-themr';
import * as css from './parent.css';
import * as childCss from './parent-child.css';
const Parent = ({theme}) => (
<div className={theme.container}>
<Child theme={theme.Child}/>
</div>
);
const theme = themeable(css, {
Child: childCss
});
const ThemedParent = themr(Symbol(), theme)(Parent); Please correct me if I'm wrong because I don't fully understand the purpose of theme namespaces. UPDATE: nested themes are supported on every level of theme merging: context, props and default configuration. |
Sorry for late answer. I''m very often use HOC's and each of the HOC's add some feature to component and possible has it's own styles. Styles are already in different files, and in my HOC I'm adding default theme. I'm adding namespace with sass:
So, I have all themes merged all together:
In result I want to put component default theme and HOC's theme in different namespaces to not intersect names and do not worry about of this. |
I don't see any problem with HOC's: you can still split HOC's styles and its child styles into different files and combine them into one theme object using
UPDATE: PS. You could still open a PR :) |
@artem-popov |
I'll think about that :) |
Now it's possible to namespace a theme by using a
themeNamespace
property for the component. This avoids collisions between modules of different components using the same classname. It's a feature that it's working and it's published but not documented. We need to write a section detailing the API which is very simple!The text was updated successfully, but these errors were encountered: