Skip to content

Commit

Permalink
added storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin committed Sep 9, 2024
1 parent c98914f commit 8007bdf
Show file tree
Hide file tree
Showing 8 changed files with 11,480 additions and 2,564 deletions.
18 changes: 18 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type {StorybookConfig} from '@storybook/react-webpack5';

const config: StorybookConfig = {
framework: {
name: '@storybook/react-webpack5',
options: {fastRefresh: true},
},
stories: ['../demo/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/preset-scss',
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
],
typescript: {
check: true,
},
};

export default config;
6 changes: 6 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {addons} from '@storybook/addons';
import {themes} from './theme';

addons.setConfig({
theme: themes.light,
});
47 changes: 47 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type {Preview} from '@storybook/react';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';

import {withThemeProvider, withLang} from '../demo/utils/preview';

const preview: Preview = {
decorators: [withThemeProvider, withLang],
parameters: {
jsx: {showFunctions: true}, // To show functions in sources
viewport: {
viewports: MINIMAL_VIEWPORTS,
},
options: {
storySort: {
order: ['Landing', '*'],
},
},
},
globalTypes: {
theme: {
defaultValue: 'light',
toolbar: {
title: 'Theme',
icon: 'mirror',
items: [
{value: 'light', right: '☼', title: 'Light'},
{value: 'dark', right: '☾', title: 'Dark'},
{value: 'light-hc', right: '☼', title: 'High Contrast Light (beta)'},
{value: 'dark-hc', right: '☾', title: 'High Contrast Dark (beta)'},
],
},
},
lang: {
defaultValue: 'en',
toolbar: {
title: 'Language',
icon: 'globe',
items: [
{value: 'en', right: '🇬🇧', title: 'En'},
{value: 'ru', right: '🇷🇺', title: 'Ru'},
],
},
},
},
};

export default preview;
41 changes: 41 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {create} from '@storybook/theming';

export const ThemeLight = create({
base: 'light',

colorPrimary: '#027bf3',
colorSecondary: 'rgba(2, 123, 243, 0.6)',

// Typography
fontBase: '"Helvetica Neue", Arial, Helvetica, sans-serif',
fontCode:
'"SF Mono", "Menlo", "Monaco", "Consolas", "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", "Courier", monospace',

// Text colors
textColor: 'black',
textInverseColor: 'black',

// Toolbar default and active colors
barTextColor: 'silver',
barSelectedColor: '#027bf3',
// barBg: '#027bf3',

// Form colors
inputBg: 'white',
inputBorder: 'silver',
inputTextColor: 'black',
inputBorderRadius: 4,

brandUrl: 'https://github.com/gravity-ui/landing',
brandTitle: `<div style="font-size: 18px; color: #027bf3; font-weight: 600; margin-top: -6px; margin-bottom: 2px;">Landing</div>
<div style="font-size: 14px;color: #7d7d7d;font-weight: 400;">Landing</div>`,
});

export const ThemeDark = create({
base: 'dark',
});

export const themes = {
light: ThemeLight,
dark: ThemeDark,
};
8 changes: 8 additions & 0 deletions .storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "ES2017"
},
"include": ["src/**/*", "demo/**/*"],
}
5 changes: 5 additions & 0 deletions demo/Landing.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {Meta} from '@storybook/react';

export default {
title: 'Landing / Landing example',
} as Meta;
Loading

0 comments on commit 8007bdf

Please sign in to comment.