|
|
|
|
|
by mxstbr
3488 days ago
|
|
We're currently writing some documentation specifically pertaining to theming third-party component libraries, which you can read the WIP of here: https://github.com/styled-components/styled-components-exper... The TL;DR is that this customization guide will suddenly become really easy. Antd can specify a default theme and users can override the parts of the default theme they want! All the user has to do is pass a single prop to the ThemeProvier and override what they want: import { ThemeProvider } from 'antd';
<ThemeProvider theme={{ primaryColor: '#1DA57A' }}>
<App />
</ThemeProvider>
On top of that different parts of your app can have different themes. Making your sidebar dark but your main component light is not an issue – just wrap them in two ThemeProviders with different themes: <ThemeProvider theme={darkTheme}>
<Sidebar />
</ThemeProvider>
<ThemeProvider theme={lightTheme}>
<Main />
</ThemeProvider>
It's also all dynamic, meaning you can let the users of your app provide custom themes for your app and it'll automatically apply.Compare that with the current customization guide, not only do users have to use webpack, they also have to use specific plugins just to make customization of third-party components work! It's also all global, which means styling the sidebar dark and the main area light is impossible since it's all just Less variables applied at build time. This also makes it very hard to have user supplied themes. Does that make it clear enough how using styled-components would help with theming? :-) |
|
Currently, I (as well as most users, I suppose) just need to apply some global color overrides to match with company's brand guidelines that I can solve it with old good plain CSS.
Also, for big projects, like Antd, transition to some other CSS-tooling almost impossible, because CSS/LESS code is spread across several repositories and will take a lot of efforts and time.
And finally, the current implementation is better because it doesn't mention styles in Javascript at all, so the library users are able to choose any way to style components without extra efforts from the side of library authors.