Skip to content

Commit

Permalink
refactor: add intl config for storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
ShriD2003 committed Aug 21, 2024
1 parent ee61f79 commit ea3b5e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
'plugin:@typescript-eslint/recommended',
'plugin:storybook/recommended'
],
rules: {
'import/no-webpack-loader-syntax': 0,
Expand Down
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const config: StorybookConfig = {
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/addon-a11y'
'@storybook/addon-a11y',
'storybook-addon-intl'
],
framework: {
name: '@storybook/react-webpack5',
Expand Down
13 changes: 13 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { translationMessages, appLocales, DEFAULT_LOCALE } from '../app/i18n';

import type { Preview } from '@storybook/react';

type TranslationMessages = {
[key: string]: { [key: string]: string };
};

const getMessages = (locale: string) => (translationMessages as TranslationMessages)[locale];

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i
}
},
intl: {
locales: appLocales,
defaultLocale: DEFAULT_LOCALE,
getMessages
}
}
};
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3881,7 +3881,7 @@
resolve-from "^5.0.0"
ts-dedent "^1.1.0"

"@storybook/theming@^8.2.9":
"@storybook/theming@^8.0.8", "@storybook/theming@^8.2.9":
version "8.2.9"
resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-8.2.9.tgz#6eb066f8957272c0bcb0078a8a9bc378ca9311d3"
integrity sha512-OL0NFvowPX85N5zIYdgeKKaFm7V4Vgtci093vL3cDZT13LGH6GuEzJKkUFGuUGNPFlJc+EgTj0o6PYKrOLyQ6w==
Expand Down Expand Up @@ -18239,6 +18239,13 @@ store2@^2.7.1:
resolved "https://registry.yarnpkg.com/store2/-/store2-2.12.0.tgz#e1f1b7e1a59b6083b2596a8d067f6ee88fd4d3cf"
integrity sha512-7t+/wpKLanLzSnQPX8WAcuLCCeuSHoWdQuh9SB3xD0kNOM38DNf+0Oa+wmvxmYueRzkmh6IcdKFtvTa+ecgPDw==

storybook-addon-intl@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/storybook-addon-intl/-/storybook-addon-intl-4.0.0.tgz#099df123ef78fa578767496c5f956040561c22d1"
integrity sha512-dWbG/NRl5JgT3VxkgaTirqHlvCFXcfxFSwnOfmq5IDyGHr6yNhtppYTbmHKILFua6CNMnrddoqRg+NDxsSpyTg==
dependencies:
"@storybook/theming" "^8.0.8"

storybook-router@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/storybook-router/-/storybook-router-0.3.4.tgz#27c0c0de5eafa03b9003a850ac40e2b0c2a3ee65"
Expand Down

0 comments on commit ea3b5e0

Please sign in to comment.