Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs go dark #409

Merged
merged 10 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .storybook/FreenowTheme.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// .storybook/FreenowTheme.ts
import { create } from '@storybook/theming/create';

export default create({
base: 'light',

// Typography
const baseVars = {
fontBase: '"Open Sans", sans-serif',
fontCode: 'monospace',

brandTitle: 'FREENOW',
brandUrl: 'https://wave.free-now.com/',
brandImage: 'https://wave.free-now.com/freenow-logo.svg',
brandTarget: '_self',
brandTarget: '_self'
};

export const LightTheme = create({
base: 'light',
...baseVars,

//
colorPrimary: '#CA0928',
colorSecondary: '#585C6D',

Expand All @@ -38,3 +39,11 @@ export default create({
inputTextColor: '#10162F',
inputBorderRadius: 2
});

export const DarkTheme = create({
base: 'dark',
appContentBg: 'hsl(0deg, 0%, 5%)',
appPreviewBg: '#222425',
inputTextColor: 'blue',
...baseVars
});
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const config: StorybookConfig = {
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-viewport'
'@storybook/addon-viewport',
'storybook-dark-mode'
],
framework: {
name: '@storybook/react-webpack5',
Expand Down
7 changes: 0 additions & 7 deletions .storybook/manager.ts

This file was deleted.

53 changes: 42 additions & 11 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';
import { Preview } from '@storybook/react';
import { themes } from '@storybook/theming';
import { addons } from '@storybook/preview-api';
import { DocsContainer } from '@storybook/addon-docs';

import { GlobalStyle as ClassicColors } from '../src/essentials/Colors/Colors';
import { GlobalStyle as ModernColors } from '../src/essentials/Colors/ModernColors';
import { DarkScheme, LightScheme } from '../src/components/ColorScheme';

import { getSemanticValue } from '../src/utils/cssVariables';
import { LightTheme, DarkTheme } from './FreenowTheme';
import { useDarkMode } from 'storybook-dark-mode';

const THEMES = {
classic: ClassicColors,
Expand All @@ -15,16 +22,34 @@ export const withTheme = (Story, context) => {
return (
<>
<Theme />
<div className="wave">
<Story {...context} />
</div>
<Story {...context} />
</>
);
};

export const withColorScheme = (Story, context) => {
const SchemeWrapper = useDarkMode() ? DarkScheme : LightScheme;

return (
<SchemeWrapper>
<Story {...context} />
</SchemeWrapper>
);
};

export const preview: Preview = {
decorators: [withTheme],
decorators: [withTheme, withColorScheme],
parameters: {
darkMode: {
dark: { ...themes.dark, ...DarkTheme },
light: {
...themes.normal,
...LightTheme
},
lightClass: ['wave', 'light-scheme'],
darkClass: ['wave', 'dark-scheme'],
stylePreview: true
},
actions: { argTypesRegex: '^on[A-Z].*' },
viewMode: 'docs',
controls: {
Expand All @@ -40,18 +65,24 @@ export const preview: Preview = {
}
},
docs: {
theme: themes.light,
container: props => {
const scheme = useDarkMode() ? DarkTheme : LightTheme;
const globals = props.context.store.globals.get();
const WaveTheme = THEMES[globals.theme];

return (
<>
<WaveTheme />
<DocsContainer {...props} theme={scheme} />
</>
);
},
toc: {
headingSelector: 'h2, h3'
}
},
backgrounds: {
default: 'auto',
values: [
{ name: 'auto', value: getSemanticValue('background-page-default') },
{ name: 'light', value: getSemanticValue('background-surface-neutral-default') },
{ name: 'dark', value: getSemanticValue('background-surface-primary-default') }
]
disable: true
},
viewport: {
viewports: {
Expand Down
139 changes: 50 additions & 89 deletions docs/assets/wave-background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 10 additions & 49 deletions docs/assets/wave-ds-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 0 additions & 38 deletions docs/components/BoxWithSchemeToggle.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/components/migration/CssVariablesMigrationTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Source } from '@storybook/blocks';

import { Source } from '../../../src/docs/Source';
import { Table, TableCell, TableHeaderCell, TableRow } from '../../../src/components/Table';

const codemodsExample = `import styled from 'styled-components';
Expand Down
Loading