2023-09-26 11:40:40 +02:00
|
|
|
import { create } from '@storybook/theming';
|
|
|
|
|
|
2025-08-22 10:09:43 +02:00
|
|
|
const buildLightTheme = () => {
|
2023-09-26 11:40:40 +02:00
|
|
|
return {
|
|
|
|
|
brandUrl: 'https://github.com/openfun/cunningham',
|
|
|
|
|
brandImage: 'logo-cunningham.svg',
|
|
|
|
|
brandTitle: 'Cunningham',
|
|
|
|
|
brandTarget: '_self',
|
|
|
|
|
|
|
|
|
|
//
|
2025-08-22 10:09:43 +02:00
|
|
|
colorPrimary: '#20467F', // content.brand.primary
|
|
|
|
|
colorSecondary: '#0659C5', // content.brand.secondary
|
2023-09-26 11:40:40 +02:00
|
|
|
|
|
|
|
|
// UI
|
2025-08-22 10:09:43 +02:00
|
|
|
// appBg: '#F7F8F8', // background.surface.tertiary
|
|
|
|
|
appContentBg: '#FFFFFF', // background.surface.primary
|
|
|
|
|
appBorderColor: '#E1E2E5', // border.surface.primary
|
2023-09-26 11:40:40 +02:00
|
|
|
appBorderRadius: 4,
|
|
|
|
|
|
|
|
|
|
// Text colors
|
2025-08-22 10:09:43 +02:00
|
|
|
textColor: '#252627', // content.neutral.primary
|
|
|
|
|
textInverseColor: '#5C5F63', // content.neutral.secondary
|
2023-09-26 11:40:40 +02:00
|
|
|
|
|
|
|
|
// Toolbar default and active colors
|
2025-08-22 10:09:43 +02:00
|
|
|
barTextColor: '#74777C', // content.neutral.tertiary
|
|
|
|
|
barSelectedColor: '#252627', // content.neutral.primary
|
|
|
|
|
barBg: '#FFFFFF', // background.surface.primary
|
2023-09-26 11:40:40 +02:00
|
|
|
|
|
|
|
|
// Form colors
|
2025-08-22 10:09:43 +02:00
|
|
|
inputBg: '#FFFFFF', // background.surface.primary
|
|
|
|
|
inputBorder: '#A7ACB2', // border.neutral.secondary
|
|
|
|
|
inputTextColor: '#252627', // content.neutral.primary
|
2023-09-26 11:40:40 +02:00
|
|
|
inputBorderRadius: 2,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-22 10:09:43 +02:00
|
|
|
const buildDarkTheme = () => {
|
|
|
|
|
return {
|
|
|
|
|
brandUrl: 'https://github.com/openfun/cunningham',
|
|
|
|
|
brandImage: 'logo-cunningham.svg',
|
|
|
|
|
brandTitle: 'Cunningham',
|
|
|
|
|
brandTarget: '_self',
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
colorPrimary: '#EAF1FB', // content.brand.primary
|
|
|
|
|
colorSecondary: '#D5E4F7', // content.brand.secondary
|
|
|
|
|
|
|
|
|
|
// UI
|
|
|
|
|
appBg: '#222631', // background.surface.tertiary
|
|
|
|
|
appContentBg: '#181B24', // background.surface.primary
|
|
|
|
|
appBorderColor: '#3A3B3E', // border.surface.primary
|
|
|
|
|
appBorderRadius: 4,
|
|
|
|
|
|
|
|
|
|
// Text colors
|
|
|
|
|
// textColor: '#F0F1F2', // content.neutral.primary
|
|
|
|
|
// textInverseColor: '#E1E2E5', // content.neutral.secondary
|
|
|
|
|
|
|
|
|
|
// Toolbar default and active colors
|
|
|
|
|
// barTextColor: '#B5B9BE', // content.neutral.tertiary
|
|
|
|
|
// barSelectedColor: '#F0F1F2', // content.neutral.primary
|
|
|
|
|
barBg: '#222631', // background.surface.primary
|
|
|
|
|
|
|
|
|
|
// Form colors
|
|
|
|
|
// inputBg: '#2F3033', // background.surface.primary
|
|
|
|
|
// inputBorder: '#5C5F63', // border.neutral.secondary
|
|
|
|
|
// inputTextColor: '#F0F1F2', // content.neutral.primary
|
|
|
|
|
// inputBorderRadius: 2,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-26 11:40:40 +02:00
|
|
|
export const themes = {
|
|
|
|
|
default: create({
|
|
|
|
|
base: 'light',
|
2025-08-22 10:09:43 +02:00
|
|
|
// ...buildLightTheme(),
|
2023-09-26 11:40:40 +02:00
|
|
|
}),
|
|
|
|
|
dark: create({
|
|
|
|
|
base: 'dark',
|
2025-08-22 10:09:43 +02:00
|
|
|
...buildDarkTheme(),
|
2023-09-26 11:40:40 +02:00
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export enum Themes {
|
|
|
|
|
dark = 'dark',
|
|
|
|
|
default = 'default'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const BACKGROUND_COLOR_TO_THEME = {
|
2025-08-22 10:09:43 +02:00
|
|
|
'#181B24': Themes.dark,
|
2023-09-26 11:40:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getThemeFromGlobals = (globals: any): string => {
|
|
|
|
|
const color = BACKGROUND_COLOR_TO_THEME[globals.backgrounds?.value];
|
|
|
|
|
return color ?? Themes.default;
|
|
|
|
|
};
|