-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make resolveConfig compatible with feature flag configs (#2347)
* Make resolveConfig compatible with feature flag configs * Update changelog
- Loading branch information
1 parent
ac36e8d
commit e5c193a
Showing
4 changed files
with
50 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
const resolveConfigObjects = require('./lib/util/resolveConfig').default | ||
const defaultConfig = require('./stubs/defaultConfig.stub.js') | ||
const getAllConfigs = require('./lib/util/getAllConfigs').default | ||
|
||
module.exports = function resolveConfig(...configs) { | ||
return resolveConfigObjects([...configs, defaultConfig]) | ||
// Make sure the correct config object is mutated to include flagged config plugins. | ||
// This sucks, refactor soon. | ||
const firstConfigWithPlugins = configs.find(c => Array.isArray(c.plugins)) || configs[0] | ||
const [, ...defaultConfigs] = getAllConfigs(firstConfigWithPlugins) | ||
|
||
return resolveConfigObjects([...configs, ...defaultConfigs]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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' | ||
|
||
export default function getAllConfigs(config) { | ||
const configs = [defaultConfig] | ||
|
||
if (flagEnabled(config, 'uniformColorPalette')) { | ||
configs.unshift(uniformColorPalette) | ||
} | ||
|
||
if (flagEnabled(config, 'extendedSpacingScale')) { | ||
configs.unshift(extendedSpacingScale) | ||
} | ||
|
||
if (flagEnabled(config, 'defaultLineHeights')) { | ||
configs.unshift(defaultLineHeights) | ||
} | ||
|
||
if (flagEnabled(config, 'extendedFontSizeScale')) { | ||
configs.unshift(extendedFontSizeScale) | ||
} | ||
|
||
if (flagEnabled(config, 'standardFontWeights')) { | ||
configs.unshift(standardFontWeights) | ||
} | ||
|
||
if (flagEnabled(config, 'darkModeVariant')) { | ||
configs.unshift(darkModeVariant) | ||
if (Array.isArray(config.plugins)) { | ||
config.plugins = [...darkModeVariant.plugins, ...config.plugins] | ||
} | ||
} | ||
|
||
return [config, ...configs] | ||
} |