mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 19:51:49 +08:00
28 lines
661 B
TypeScript
28 lines
661 B
TypeScript
import { logger } from '@storybook/client-logger';
|
|
|
|
import { deletedDiff } from 'deep-object-diff';
|
|
import { dedent } from 'ts-dedent';
|
|
|
|
import light from './themes/light';
|
|
import type { ThemeVars, StorybookTheme } from './types';
|
|
import { convert } from './convert';
|
|
|
|
export const ensure = (input: ThemeVars): StorybookTheme => {
|
|
if (!input) {
|
|
return convert(light);
|
|
}
|
|
const missing = deletedDiff(light, input);
|
|
if (Object.keys(missing).length) {
|
|
logger.warn(
|
|
dedent`
|
|
Your theme is missing properties, you should update your theme!
|
|
|
|
theme-data missing:
|
|
`,
|
|
missing
|
|
);
|
|
}
|
|
|
|
return convert(input);
|
|
};
|