mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-21 04:57:05 +02:00
refactor(theme-classic): replace color mode toggle with button; remove switchConfig (#6771)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
b1492135c2
commit
7ec44bb32c
15 changed files with 282 additions and 356 deletions
|
@ -509,16 +509,17 @@ describe('themeConfig', () => {
|
|||
const withDefaultValues = (colorMode) =>
|
||||
_.merge({}, DEFAULT_CONFIG.colorMode, colorMode);
|
||||
|
||||
test('minimal config', () => {
|
||||
test('switch config', () => {
|
||||
const colorMode = {
|
||||
switchConfig: {
|
||||
darkIcon: '🌙',
|
||||
},
|
||||
};
|
||||
expect(testValidateThemeConfig({colorMode})).toEqual({
|
||||
...DEFAULT_CONFIG,
|
||||
colorMode: withDefaultValues(colorMode),
|
||||
});
|
||||
expect(() =>
|
||||
testValidateThemeConfig({colorMode}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"colorMode.switchConfig is deprecated. If you want to customize the icons for light and dark mode, swizzle IconLightMode, IconDarkMode, or ColorModeToggle instead."`,
|
||||
);
|
||||
});
|
||||
|
||||
test('max config', () => {
|
||||
|
@ -526,17 +527,6 @@ describe('themeConfig', () => {
|
|||
defaultMode: 'dark',
|
||||
disableSwitch: false,
|
||||
respectPrefersColorScheme: true,
|
||||
switchConfig: {
|
||||
darkIcon: '🌙',
|
||||
darkIconStyle: {
|
||||
marginTop: '1px',
|
||||
marginLeft: '2px',
|
||||
},
|
||||
lightIcon: '☀️',
|
||||
lightIconStyle: {
|
||||
marginLeft: '1px',
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(testValidateThemeConfig({colorMode})).toEqual({
|
||||
...DEFAULT_CONFIG,
|
||||
|
@ -562,16 +552,6 @@ describe('themeConfig', () => {
|
|||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('empty switch config', () => {
|
||||
const colorMode = {
|
||||
switchConfig: {},
|
||||
};
|
||||
expect(testValidateThemeConfig({colorMode})).toEqual({
|
||||
...DEFAULT_CONFIG,
|
||||
colorMode: withDefaultValues(colorMode),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue