3 ms·
Regarding most of the dismissive comments on using JS for styling... 1. you can't inherit... 2. I don't want it in the same file... // component.style.js
by tracker1 8y ago
Regarding most of the dismissive comments on using JS for styling...
1. you can't inherit...
2. I don't want it in the same file...
// component.style.js
import base from '../base.style.js';\
export style = theme => ({
...theme.typography.body1,
...base.component.foo
fontFamily: theme.fonts.serif,
});
// component.js
import { style } from './component.style';
...
I'll see your objections, and raise you one...
// theme-builder.js
import deepMerge ...
import { get } from './api-client';
export default async _ => {
const [base, client, application, user] = await Promise.all([
get('/styles/default'), // default options
get('/styles/site'), // client/deployment options
get('/styles/application'), // in-application configured options
get('/styles/user'), // in-application user options
]);
return deepMerge(base, client, application, user);
};
I'm currently working on an application that has those needs... doing that per-user means building styles at the server every time... using JSS, I just deepMerge some JSON/Objects and it all just works. I've built applications both ways, BEM, generated selector replacement, other techniques, and JSS... I'll take JSS.