-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathgetAllConfigs.js
34 lines (30 loc) · 1.14 KB
/
getAllConfigs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import defaultConfig from '../../stubs/defaultConfig.stub.js'
import { flagEnabled } from '../featureFlags'
import uniformColorPalette from '../flagged/uniformColorPalette.js'
import extendedSpacingScale from '../flagged/extendedSpacingScale.js'
import defaultLineHeights from '../flagged/defaultLineHeights.js'
import extendedFontSizeScale from '../flagged/extendedFontSizeScale.js'
import darkModeVariant from '../flagged/darkModeVariant.js'
import standardFontWeights from '../flagged/standardFontWeights'
import additionalBreakpoint from '../flagged/additionalBreakpoint'
import { flatMap, get } from 'lodash'
export default function getAllConfigs(config) {
const configs = flatMap([...get(config, 'presets', [defaultConfig])].reverse(), preset => {
return getAllConfigs(preset)
})
const features = {
uniformColorPalette,
extendedSpacingScale,
defaultLineHeights,
extendedFontSizeScale,
standardFontWeights,
darkModeVariant,
additionalBreakpoint,
}
Object.keys(features).forEach(feature => {
if (flagEnabled(config, feature)) {
configs.unshift(features[feature])
}
})
return [config, ...configs]
}