(no title)
secoif | 9 years ago
There is a standard for CSS variables and a very functional subset of their functionality can be compiled for older browsers at build time: http://cssnext.io, yet as far as I can tell, all of these component frameworks impose some other nonstandard compiles-to-CSS language or one of many possible APIs for writing inline styles.
Inline styles seem to be a trend at the moment but I can only assume the people driving this movement haven't had the experience of working with 3rd party components (which you may or may not have the source for) and needing to alter something the designers didn't expose and simply having no simple options because the damn inline style can't be overridden even by !important. Now you've got to fork whole the f'ing component, possibly multiple, each of which potentially coming with yet another different compiles-to-CSS toolchain all because you wanted to add a single line of CSS.
Admittedly, antd doesn't use inline styles si the above doesn't apply here, but having to maintain a custom builder for antd in order to change some fonts and a few colors was a frustrating experience. Not sure what a good solution is until CSS variables get more browser adoption, but it'd be great if we could collectively start standardizing on standards.
mxstbr|9 years ago
I'm one of the maintainers of ElementalUI, and Glen Maddern, the styled-components co-creator, one of the creators of CSS Modules. One of the biggest downsides of CSS Modules (and, by extension, every other styles in JavaScript library right now) is that theming is simply impossible. Building third-party component libraries is hard enough, but providing an easy-to-theme API wasn't a solved problem in the React world. Nobody has done it properly, and there is no agreed-upon way of doing this!
styled-components has built-in theming support[1] to solve this exact problem. (note: this is CSS-in-JS, not inline styles[2], so overriding is easy as pie too[3]) We're rebuilding ElementalUI with it right now and the next versions of react-toolbox and Belle will be built with it as well.
We also have ReactNative support, which nobody else has done before. Just because you're writing a universal React app with a third-party component library shouldn't mean switching between three or four different APIs to style your app. With styled-components, you can just use styled-components no matter what you're styling!
(If you're reading this, I'd love to have a chat with the Antd people about maybe moving to styled-components! You can reach me on Twitter at @mxstbr, just ping me there!)
just-boris|9 years ago
I've been using Antd components for the last year in some my project. All components are also available here[0] as single modules for better reusability and customization.
Currently, I have solved all my theming goals with Plain CSS. For each component, that I'd like to customize I created a wrapper
Then in CSS (This is a very simplified example, just shows the way).I have read about styled-components, but I don't understand how it would help me with theming. I don't think that rewriting every component from LESS to styled-components to make possible to use ThemeProvider will be an option because it doesn't give you any benefits comparing with customization guide[1], that also gives you good enough way to override defaults.
Zalastax|9 years ago
[1]: https://github.com/styled-components/styled-components/issue...
mlsarecmg|9 years ago
If you use a CSS react-lib like React-CSJS, styling this is easy as pie.
mstijak|9 years ago
I'm currently working on themes for a similar framework. It's still in early stage but you can see it here: http://cx.codaxy.com/v/master/themes/
crudbug|9 years ago
You can separate component Style into - BASE + States classes.
classnames[0] can used to use multiple classes, the classes can be activated using component state. This provides a viable solution for Structure & Style.
[0] https://github.com/JedWatson/classnames
Lazare|9 years ago
At least on paper, it solved the issues you raise. Time will tell I suppose.
unknown|9 years ago
[deleted]
Illniyar|9 years ago
I don't think your complaint is relevant here, especially since you provide no solution.
It bothers me that this reply is at the top of the comments.
prashnts|9 years ago
griffinmichl|9 years ago
sidi|9 years ago
secoif|9 years ago
I've had some success with simple find & replace preprocessor but this gets complicated if the CSS uses colour manipulation functions e.g. color: color(var(--color-base) tint(50%)), then you're basically going to be re-implementing their whole stylesheet again.
Also, good luck making sure everything still works if and when the components are updated.
Ideally, you alter theme variables in one place, rather than finding and overriding them everywhere they're applied.