-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Revitalize Storybook * fix: Fix comments --------- Co-authored-by: Pavel Trofimov <[email protected]>
- Loading branch information
1 parent
f075d70
commit ac30c38
Showing
11 changed files
with
6,324 additions
and
490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: 'Storybook deployment' | ||
|
||
on: | ||
# push: | ||
# branches: [ master ] | ||
# paths: | ||
# - 'template/apps/web/src/components/**' | ||
workflow_dispatch: | ||
inputs: | ||
sha: | ||
description: The SHA-1 hash referring to the commit to check. | ||
required: true | ||
ref: | ||
description: The head branch associated with the pull request. | ||
required: true | ||
|
||
jobs: | ||
chromatic-deployment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Go to the storybook direc | ||
run: | | ||
cd template/apps/web | ||
npm i --ignore-scripts | ||
- name: Publish to Chromatic | ||
uses: chromaui/action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | ||
workingDir: services/web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Workflow name | ||
name: 'storybook-deployment' | ||
|
||
# Event for the workflow | ||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- 'apps/web/src/components/**' | ||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'warning' | ||
tags: | ||
description: 'Test scenario' | ||
required: false | ||
|
||
# List of jobs | ||
jobs: | ||
chromatic-deployment: | ||
# Operating System | ||
runs-on: ubuntu-latest | ||
# Job steps | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Install dependencies | ||
run: yarn | ||
# 馃憞 Adds Chromatic as a step in the workflow | ||
- name: Publish to Chromatic | ||
uses: chromaui/action@v1 | ||
# Chromatic GitHub Action options | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
# 馃憞 Chromatic projectToken, refer to the manage page to obtain it. | ||
# https://www.chromatic.com/docs/github-actions/#:~:text=Project%20token%20secret&text=On%20GitHub%2C%20go%20to%20the,project%20token%20as%20the%20Secret. | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.idea | ||
.husky | ||
.storybook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ yarn-error.log* | |
|
||
.env | ||
.env.local | ||
|
||
#storybook | ||
storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { StorybookConfig } from '@storybook/nextjs'; | ||
|
||
import { join, dirname } from 'path'; | ||
|
||
function getAbsolutePath(value: string): any { | ||
return dirname(require.resolve(join(value, 'package.json'))); | ||
} | ||
const config: StorybookConfig = { | ||
core: { | ||
builder: '@storybook/builder-webpack5', | ||
}, | ||
stories: ['../src/components/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: [ | ||
getAbsolutePath('@storybook/addon-links'), | ||
getAbsolutePath('@storybook/addon-essentials'), | ||
getAbsolutePath('@storybook/addon-onboarding'), | ||
getAbsolutePath('@storybook/addon-interactions'), | ||
getAbsolutePath('@storybook/addon-styling-webpack'), | ||
getAbsolutePath('storybook-dark-mode'), | ||
], | ||
framework: { | ||
name: getAbsolutePath('@storybook/nextjs'), | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: 'tag', | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import '@mantine/core/styles.css'; | ||
|
||
import React, { useEffect } from 'react'; | ||
import { addons } from '@storybook/preview-api'; | ||
import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode'; | ||
import { MantineProvider, useMantineColorScheme } from '@mantine/core'; | ||
|
||
import theme from '../src/theme'; | ||
|
||
const channel = addons.getChannel(); | ||
|
||
const ColorSchemeWrapper = ({ children }: { children: React.ReactNode }) => { | ||
const { setColorScheme } = useMantineColorScheme(); | ||
const handleColorScheme = (value: boolean) => setColorScheme(value ? 'dark' : 'light'); | ||
|
||
useEffect(() => { | ||
channel.on(DARK_MODE_EVENT_NAME, handleColorScheme); | ||
return () => channel.off(DARK_MODE_EVENT_NAME, handleColorScheme); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [channel]); | ||
|
||
// eslint-disable-next-line react/jsx-no-useless-fragment | ||
return <>{ children }</>; | ||
}; | ||
|
||
export const decorators = [ | ||
(renderStory: any) => <ColorSchemeWrapper>{renderStory()}</ColorSchemeWrapper>, | ||
(renderStory: any) => <MantineProvider theme={theme}>{renderStory()}</MantineProvider>, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { IconUserCircle } from '@tabler/icons-react'; | ||
import { StoryFn, Meta } from '@storybook/react'; | ||
|
||
import Link from './index'; | ||
|
||
export default { | ||
title: 'Components/Link', | ||
component: Link, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
children: { name: 'Text', control: 'text', defaultValue: 'Text' }, | ||
href: { name: 'Href', control: 'text', defaultValue: 'https://www.paralect.com' }, | ||
disabled: { | ||
name: 'Disabled', | ||
options: [true, false], | ||
control: { type: 'boolean' }, | ||
defaultValue: false, | ||
}, | ||
underline: { | ||
name: 'Underline', | ||
options: [true, false], | ||
control: { type: 'boolean' }, | ||
defaultValue: false, | ||
}, | ||
inherit: { | ||
name: 'Inherit', | ||
options: [true, false], | ||
control: { type: 'boolean' }, | ||
defaultValue: false, | ||
}, | ||
icon: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
inNewTab: { | ||
name: 'In new tab', | ||
options: [true, false], | ||
control: { type: 'boolean' }, | ||
defaultValue: true, | ||
}, | ||
size: { | ||
name: 'Size', | ||
options: ['xs', 'sm', 'md', 'lg', 'xl'], | ||
control: { | ||
type: 'inline-radio', | ||
labels: { | ||
xs: 'Extra small', | ||
sm: 'Small', | ||
md: 'Medium', | ||
lg: 'Large', | ||
xl: 'Extra large', | ||
}, | ||
}, | ||
defaultValue: 'md', | ||
}, | ||
}, | ||
} as Meta<typeof Link>; | ||
|
||
const Template: StoryFn<typeof Link> = ({ ...args }) => ( | ||
<Link {...args}> | ||
{args.children} | ||
</Link> | ||
); | ||
|
||
export const Icon = Template.bind({}); | ||
|
||
Icon.args = { | ||
icon: <IconUserCircle />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.