-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #854 from InseeFrLab/feat-storybook
feat: add storybook
- Loading branch information
Showing
56 changed files
with
5,277 additions
and
92 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 |
---|---|---|
|
@@ -37,3 +37,5 @@ package-lock.json | |
.idea/ | ||
.env.local.yaml | ||
/src/pluginSystem.js | ||
|
||
*storybook.log |
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,21 @@ | ||
import type { StorybookConfig } from "@storybook/react-vite"; | ||
|
||
export default { | ||
"stories": ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
"addons": [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"storybook-dark-mode", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-themes", | ||
"@storybook/addon-a11y" | ||
], | ||
"framework": { | ||
"name": "@storybook/react-vite", | ||
"options": {} | ||
}, | ||
"core": { | ||
"builder": "@storybook/builder-vite" | ||
}, | ||
"staticDirs": ["./static", "../public"] | ||
} as StorybookConfig; |
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,64 @@ | ||
import type { Preview } from "@storybook/react"; | ||
import { useDarkMode as useStorybookUiDarkMode } from "storybook-dark-mode"; | ||
import { darkTheme, lightTheme } from "./theme"; | ||
import React, { useEffect } from "react"; | ||
import { OnyxiaUi } from "../src/ui/theme"; | ||
import { injectCustomFontFaceIfNotAlreadyDone } from "../src/ui/theme/injectCustomFontFaceIfNotAlreadyDone"; | ||
import { | ||
Language, | ||
languagesPrettyPrint, | ||
useLang, | ||
fallbackLanguage | ||
} from "../src/ui/i18n"; | ||
import { assert } from "tsafe/assert"; | ||
import { is } from "tsafe/is"; | ||
|
||
injectCustomFontFaceIfNotAlreadyDone(); | ||
|
||
const languagesGlobal = Object.entries(languagesPrettyPrint).map(([value, title]) => ({ | ||
value: value as Language, | ||
title | ||
})); | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
backgrounds: { disable: true }, | ||
darkMode: { | ||
light: lightTheme, | ||
dark: darkTheme | ||
}, | ||
docs: { disable: true, hidden: true } | ||
}, | ||
globalTypes: { | ||
locale: { | ||
name: "Locale", | ||
description: "Internationalization locale", | ||
defaultValue: fallbackLanguage, | ||
toolbar: { | ||
icon: "globe", | ||
items: languagesGlobal | ||
} | ||
} | ||
}, | ||
argTypes: {}, | ||
decorators: [ | ||
(Story, { globals: { locale } }) => { | ||
const isStorybookUiDark = useStorybookUiDarkMode(); | ||
const { lang, setLang } = useLang(); | ||
|
||
assert(is<Language>(locale)); | ||
|
||
useEffect(() => { | ||
if (lang !== locale) setLang(locale); | ||
}, [locale]); | ||
|
||
return ( | ||
<OnyxiaUi darkMode={isStorybookUiDark}> | ||
<Story /> | ||
</OnyxiaUi> | ||
); | ||
} | ||
] | ||
}; | ||
|
||
export default preview; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { create } from "@storybook/theming"; | ||
|
||
export const darkTheme = create({ | ||
"base": "dark", | ||
"appBg": "#2c323f", | ||
"appContentBg": "#2c323f", | ||
"appPreviewBg": "#2c323f", | ||
"barBg": "#2c323f", | ||
"colorSecondary": "#ff562c", | ||
"textColor": "#f1f0eb", | ||
"brandImage": "onyxiaLogo.png", | ||
"brandTitle": "Onyxia UI", | ||
"brandUrl": "https://github.com/InseeFrLab/onyxia-ui", | ||
"fontBase": '"Work Sans","Open Sans", sans-serif', | ||
"fontCode": "monospace" | ||
}); | ||
|
||
export const lightTheme = create({ | ||
"base": "light", | ||
"appBg": "#f1f0eb", | ||
"appContentBg": "#f1f0eb", | ||
"appPreviewBg": "#f1f0eb", | ||
"barBg": "#f1f0eb", | ||
"colorSecondary": "#ff562c", | ||
"textColor": "#2c323f", | ||
"textInverseColor": "#f1f0eb", | ||
"brandImage": "onyxiaLogo.png", | ||
"brandTitle": "Onyxia UI", | ||
"brandUrl": "https://github.com/InseeFrLab/onyxia-ui", | ||
"fontBase": '"Work Sans","Open Sans", sans-serif', | ||
"fontCode": "monospace" | ||
}); |
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
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
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,84 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CatalogChartCard } from "./CatalogChartCard"; | ||
import { action } from "@storybook/addon-actions"; | ||
import { StringWithHighlights } from "core/usecases/catalog"; | ||
|
||
const meta = { | ||
title: "Pages/Catalog/CatalogChartCard", | ||
component: CatalogChartCard | ||
} satisfies Meta<typeof CatalogChartCard>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
const exampleChartNameWithHighlights: StringWithHighlights = { | ||
charArray: [ | ||
"E", | ||
"x", | ||
"a", | ||
"m", | ||
"p", | ||
"l", | ||
"e", | ||
" ", | ||
"C", | ||
"h", | ||
"a", | ||
"r", | ||
"t", | ||
" ", | ||
"N", | ||
"a", | ||
"m", | ||
"e" | ||
], | ||
highlightedIndexes: [0, 1, 2, 3, 4, 5, 6] // Highlights "Example" | ||
}; | ||
|
||
const exampleChartDescriptionWithHighlights: StringWithHighlights = { | ||
charArray: [ | ||
"T", | ||
"h", | ||
"i", | ||
"s", | ||
" ", | ||
"i", | ||
"s", | ||
" ", | ||
"a", | ||
"n", | ||
" ", | ||
"e", | ||
"x", | ||
"a", | ||
"m", | ||
"p", | ||
"l", | ||
"e", | ||
" ", | ||
"d", | ||
"e", | ||
"s", | ||
"c", | ||
"r", | ||
"i", | ||
"p", | ||
"t", | ||
"i", | ||
"o", | ||
"n" | ||
], | ||
highlightedIndexes: [11, 12, 13, 14, 15, 16, 17] // Highlights "example" | ||
}; | ||
|
||
export const Default: Story = { | ||
args: { | ||
chartNameWithHighlights: exampleChartNameWithHighlights, | ||
chartDescriptionWithHighlights: exampleChartDescriptionWithHighlights, | ||
projectHomepageUrl: "https://example.com", | ||
iconUrl: | ||
"https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/vscode.png", | ||
onRequestLaunch: action("Launch button clicked") | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
web/src/ui/pages/catalog/CatalogNoSearchMatches.stories.tsx
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,19 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CatalogNoSearchMatches } from "./CatalogNoSearchMatches"; | ||
import { action } from "@storybook/addon-actions"; | ||
|
||
const meta = { | ||
title: "Pages/Catalog/CatalogNoSearchMatches", | ||
component: CatalogNoSearchMatches | ||
} satisfies Meta<typeof CatalogNoSearchMatches>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
search: "example service", | ||
onGoBackClick: action("Go back clicked") | ||
} | ||
}; |
20 changes: 20 additions & 0 deletions
20
web/src/ui/pages/catalog/CatalogSwitcherButton.stories.tsx
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,20 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { CatalogSwitcherButton } from "./CatalogSwitcherButton"; | ||
import { action } from "@storybook/addon-actions"; | ||
|
||
const meta = { | ||
title: "Pages/Catalog/CatalogSwitcherButton", | ||
component: CatalogSwitcherButton | ||
} satisfies Meta<typeof CatalogSwitcherButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
isSelected: false, | ||
onClick: action("Button clicked"), | ||
text: <span>Interactive services</span> | ||
} | ||
}; |
Oops, something went wrong.