-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joel Anton
committed
May 14, 2024
1 parent
f5a79d2
commit 8af5b56
Showing
17 changed files
with
1,309 additions
and
167 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,27 @@ | ||
import React from 'react'; | ||
import { DocsContainer as BaseContainer } from '@storybook/addon-docs'; | ||
import { themes } from '@storybook/theming'; | ||
|
||
export const DocsContainer = ({ children, context }) => { | ||
return ( | ||
<BaseContainer | ||
context={{ | ||
...context, | ||
storyById: (id) => { | ||
const storyContext = context.storyById(id); | ||
return { | ||
...storyContext, | ||
parameters: { | ||
...storyContext?.parameters, | ||
docs: { | ||
// theme: dark ? themes.dark : themes.light, | ||
}, | ||
}, | ||
}; | ||
}, | ||
}} | ||
> | ||
{children} | ||
</BaseContainer> | ||
); | ||
}; |
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,23 @@ | ||
import { ThemeVarsPartial } from '@storybook/theming'; | ||
import { create } from '@storybook/theming/create'; | ||
|
||
const themeBase: ThemeVarsPartial = { | ||
base: 'light', | ||
brandTitle: 'Novu Design System', | ||
brandTarget: '_self', | ||
} | ||
/** | ||
* Novu Design System theme for Storybook | ||
* | ||
* @see https://storybook.js.org/docs/configure/theming | ||
*/ | ||
export const lightTheme = create({ | ||
...themeBase, | ||
brandImage: './novu-logo-light.svg', | ||
}); | ||
|
||
export const darkTheme = create({ | ||
...themeBase, | ||
base: 'dark', | ||
brandImage: './novu-logo-dark.svg', | ||
}); |
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,23 @@ | ||
import { dirname, join } from 'path'; | ||
import { StorybookConfig } from '@storybook/react-vite'; | ||
|
||
export default { | ||
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
|
||
addons: [getAbsolutePath('storybook-dark-mode'), getAbsolutePath('@storybook/addon-mdx-gfm')], | ||
|
||
framework: { | ||
name: '@storybook/react-vite', | ||
options: {}, | ||
}, | ||
|
||
docs: { | ||
autodocs: true, | ||
}, | ||
|
||
staticDirs: ['./public'], | ||
} satisfies StorybookConfig; | ||
|
||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, 'package.json'))); | ||
} |
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 @@ | ||
<link rel="icon" type="image/svg+xml" href="./favicon.svg"> |
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,7 @@ | ||
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<script> | ||
window._env_ = { | ||
SKIP_PREFLIGHT_CHECK: 'true', | ||
}; | ||
</script> |
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,53 @@ | ||
import React from 'react'; | ||
// import { addons } from '@storybook/preview-api'; | ||
// import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode'; | ||
// import { ColorSchemePreferenceEnum, useLocalThemePreference } from '@novu/shared-web'; | ||
import { lightTheme, darkTheme } from './NovuTheme'; | ||
import { Parameters, Decorator } from '@storybook/react'; | ||
|
||
// Bring in the Panda-generated stylesheets | ||
import '../src/index.css'; | ||
|
||
// import '../styled-system/styles.css'; | ||
|
||
export const parameters: Parameters = { | ||
layout: 'fullscreen', | ||
viewMode: 'docs', | ||
docs: { | ||
// @TODO: fix the container context | ||
// container: DocsContainer, | ||
}, | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
darkMode: { | ||
// Override the default dark theme | ||
dark: darkTheme, | ||
// Override the default light theme | ||
light: lightTheme, | ||
}, | ||
}; | ||
|
||
// const channel = addons.getChannel(); | ||
function ColorSchemeThemeWrapper({ children }) { | ||
// const { setThemeStatus } = useLocalThemePreference(); | ||
|
||
// const handleColorScheme = (value) => { | ||
// setThemeStatus(value ? ColorSchemePreferenceEnum.DARK : ColorSchemePreferenceEnum.LIGHT); | ||
// }; | ||
|
||
// useEffect(() => { | ||
// channel.on(DARK_MODE_EVENT_NAME, handleColorScheme); | ||
// return () => channel.off(DARK_MODE_EVENT_NAME, handleColorScheme); | ||
// }, [channel]); | ||
|
||
return <div style={{ margin: '3em' }}>{children}</div>; | ||
} | ||
|
||
export const decorators: Decorator[] = [ | ||
(renderStory) => <ColorSchemeThemeWrapper>{renderStory()}</ColorSchemeThemeWrapper>, | ||
]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
module.exports = { | ||
/** | ||
* must use this syntax for vite + panda | ||
* https://panda-css.com/docs/installation/storybook#install-panda | ||
*/ | ||
plugins: [require('@pandacss/dev/postcss')()], | ||
}; |
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,8 @@ | ||
import { afterEach } from 'vitest'; | ||
import { cleanup } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
// runs a clean after each test case (e.g. clearing jsdom) | ||
afterEach(() => { | ||
cleanup(); | ||
}); |
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 @@ | ||
@layer reset, base, tokens, recipes, utilities; |
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,28 +1,36 @@ | ||
import { Meta } from '@storybook/react'; | ||
import React from 'react'; | ||
import { Divider, Flex, styled } from '../../../styled-system/jsx'; | ||
import { text, title } from '../../../styled-system/recipes'; | ||
/* | ||
* import { Divider, Flex, styled } from '../../../styled-system/jsx'; | ||
* import { text, title } from '../../../styled-system/recipes'; | ||
*/ | ||
|
||
const Text = styled('p', text); | ||
const Title = styled('h2', title); | ||
/* | ||
* const Text = styled('p', text); | ||
* const Title = styled('h2', title); | ||
*/ | ||
|
||
export default { | ||
title: 'Panda/Components/Typography', | ||
component: Text, | ||
// component: Text, | ||
argTypes: {}, | ||
} as Meta<typeof Text>; | ||
}; | ||
// } as Meta<typeof Text>; | ||
|
||
export const all = () => ( | ||
<Flex direction="column" gap="100"> | ||
<Text>Default Body</Text> | ||
<Text variant="main">Main text</Text> | ||
<Text variant="secondary">Secondary text</Text> | ||
<Text variant="strong">Strong text</Text> | ||
<Text variant="mono">Mono text</Text> | ||
<Divider /> | ||
<Title>Default title</Title> | ||
<Title variant="page">Page title</Title> | ||
<Title variant="section">Section title</Title> | ||
<Title variant="subsection">Subsection title</Title> | ||
</Flex> | ||
/* | ||
* <Flex direction="column" gap="100"> | ||
* <Text>Default Body</Text> | ||
* <Text variant="main">Main text</Text> | ||
* <Text variant="secondary">Secondary text</Text> | ||
* <Text variant="strong">Strong text</Text> | ||
* <Text variant="mono">Mono text</Text> | ||
* <Divider /> | ||
* <Title>Default title</Title> | ||
* <Title variant="page">Page title</Title> | ||
* <Title variant="section">Section title</Title> | ||
* <Title variant="subsection">Subsection title</Title> | ||
* </Flex> | ||
*/ | ||
<div>Hello</div> | ||
); |
Oops, something went wrong.