Skip to content

Commit

Permalink
Merge branch 'master' of github.com:DevoInc/genesys-design-system
Browse files Browse the repository at this point in the history
# Conflicts:
#	.storybook/preview.tsx
  • Loading branch information
soslayando committed Nov 4, 2024
2 parents 7c81716 + 116fd69 commit 908b519
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 51 deletions.
56 changes: 5 additions & 51 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import * as React from 'react';
import { ThemeProvider } from 'styled-components';
import { Preview, ReactRenderer } from '@storybook/react';
import { DocsContainer } from '@storybook/blocks';
import { create } from '@storybook/theming/create';
import { withThemeFromJSXProvider } from '@storybook/addon-themes';

import { light, dark } from '@devoinc/genesys-brand-devo';
import { Preview } from '@storybook/react';
import { PREFER_UI_THEME, DocContainer, themeDecorator } from './theming';

import '@devoinc/genesys-base-styles/dist/css/styles.min.css';
import './preview.scss';
Expand All @@ -25,53 +20,12 @@ export const createCustomComponents = (tagsList: (keyof React.ReactHTML)[]) => {
}, {});
};

const customLightTheme = create({
base: 'light',
fontBase: '"Poppins", sans-serif',
fontCode: '"Mono Font", monospace',
textColor: '#5B6870',
textInverseColor: 'rgba(255,255,255,0.9)',
});
const customDarkTheme = create({
base: 'dark',
fontBase: '"Poppins", sans-serif',
fontCode: '"Mono Font", monospace',
});

// const THEME_CHANNEL = 'globalsUpdated';

const preferTheme =
window?.matchMedia &&
window?.matchMedia('(prefers-color-scheme: dark)')?.matches
? 'dark'
: 'light';

const preview: Preview = {
decorators: [
// Themes
withThemeFromJSXProvider<ReactRenderer>({
themes: {
light,
dark,
},
defaultTheme: preferTheme,
Provider: ThemeProvider,
}),
],

decorators: themeDecorator,
parameters: {
docs: {
theme: preferTheme === 'dark' ? customDarkTheme : customLightTheme,
container: ({ context, children }) => {
return (
// Theme for the doc
<div className="dali-wrapper dali-wrapper--default">
<DocsContainer context={context}>
<ThemeProvider theme={light}>{children}</ThemeProvider>
</DocsContainer>
</div>
);
},
theme: PREFER_UI_THEME,
container: DocContainer,
components: createCustomComponents([
'div',
'h1',
Expand Down
13 changes: 13 additions & 0 deletions .storybook/theming/DocContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import { ThemeProvider } from 'styled-components';
import { DocsContainer as SBDocsContainer } from '@storybook/blocks';

import { light } from '@devoinc/genesys-brand-devo';

export const DocContainer = ({ context, children }) => (
<div className="dali-wrapper dali-wrapper--default">
<SBDocsContainer context={context}>
<ThemeProvider theme={light}>{children}</ThemeProvider>
</SBDocsContainer>
</div>
);
5 changes: 5 additions & 0 deletions .storybook/theming/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const PREFER_THEME =
window?.matchMedia &&
window?.matchMedia('(prefers-color-scheme: dark)')?.matches
? 'dark'
: 'light';
15 changes: 15 additions & 0 deletions .storybook/theming/decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ReactRenderer } from '@storybook/react';
import { withThemeFromJSXProvider } from '@storybook/addon-themes';
import { light, dark } from '@devoinc/genesys-brand-devo';
import { ThemeProvider } from 'styled-components';

// import { PREFER_THEME } from './constants';

export const themeDecorator = withThemeFromJSXProvider<ReactRenderer>({
themes: {
light,
dark,
},
defaultTheme: 'light', // PREFER_THEME,
Provider: ThemeProvider,
});
4 changes: 4 additions & 0 deletions .storybook/theming/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './ui';
export * from './decorator';
export * from './constants';
export * from './DocContainer';
24 changes: 24 additions & 0 deletions .storybook/theming/ui.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { create } from '@storybook/theming/create';

// import { PREFER_THEME } from './constants';

const uiLightTheme = create({
base: 'light',
fontBase: '"Poppins", sans-serif',
fontCode: '"Mono Font", monospace',
textColor: '#5B6870',
textInverseColor: 'rgba(255,255,255,0.9)',
});

const uiDarkTheme = create({
base: 'dark',
fontBase: '"Poppins", sans-serif',
fontCode: '"Mono Font", monospace',
});

export const uiThemeMap = {
light: uiLightTheme,
dark: uiDarkTheme,
};

export const PREFER_UI_THEME = uiThemeMap.light; // uiThemeMap[PREFER_THEME];

0 comments on commit 908b519

Please sign in to comment.