vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
27 lines (23 loc) • 659 B
JavaScript
import { merge } from './merge';
/**
Makes all sub-style variants inherit from the
'standard' styling for that type scale.
*/
export const buildTypeScale = typeScale => {
return Object.keys(typeScale).reduce((accumTypeScale, typeScaleKey) => {
const { standard, ...subStyles } = typeScale[typeScaleKey];
return {
...accumTypeScale,
[typeScaleKey]: {
standard: standard,
...Object.keys(subStyles).reduce(
(accumVariants, subStyleKey) => ({
...accumVariants,
[subStyleKey]: merge(standard, subStyles[subStyleKey]),
}),
{}
),
},
};
}, {});
};