| 1 |
const typographyOnly = (elements) => |
| 2 |
Object.fromEntries( |
| 3 |
Object.entries(elements ?? {}) |
| 4 |
.filter(([, styles]) => styles?.typography) |
| 5 |
.map(([element, styles]) => [element, { typography: styles.typography }]), |
| 6 |
); |
| 7 |
|
| 8 |
// The palette owns colour, so an option may only contribute its font leaves. |
| 9 |
export const fontsOnlyVariation = (variation) => { |
| 10 |
const { typography, elements } = variation?.styles ?? {}; |
| 11 |
const fonts = typographyOnly(elements); |
| 12 |
|
| 13 |
return { |
| 14 |
styles: { |
| 15 |
...(typography ? { typography } : {}), |
| 16 |
...(Object.keys(fonts).length ? { elements: fonts } : {}), |
| 17 |
}, |
| 18 |
}; |
| 19 |
}; |
| 20 |
|