-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on #1214 [Draft of new page](https://next-intl-docs-git-docs-storybook-next-intl.vercel.app/docs/workflows/storybook)
- Loading branch information
Showing
14 changed files
with
3,159 additions
and
188 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Linting | ||
# ESLint | ||
|
||
To ensure correct usage of `next-intl`, you can use ESLint to enforce certain rules. | ||
|
||
|
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 Callout from 'components/Callout'; | ||
import Image from 'next/image'; | ||
|
||
# Storybook integration for `next-intl` | ||
|
||
[Storybook](https://storybook.js.org/) is a tool for developing UI components in isolation. | ||
|
||
If you like to set up stories for components that use `next-intl`, you can use [`storybook-next-intl`](https://github.com/stevensacks/storybook-next-intl), a community-maintained addon that configures Storybook accordingly for you. | ||
|
||
**Features** | ||
|
||
- Sets up [`NextIntlClientProvider`](/docs/usage/configuration#nextintlclientprovider) globally for you | ||
- Provides a locale switcher so you can test components with different locales | ||
|
||
<Image | ||
className="mt-6" | ||
src="/storybook-integration.png" | ||
width={1768} | ||
height={1128} | ||
alt="Storybook integration for next-intl" | ||
/> | ||
|
||
<Callout> | ||
|
||
**Tip:** If you declare components that render as Server Components in your app via non-async functions, these components can render as Client Components in Storybook and will consume configuration from `NextIntlClientProvider` (see also: [Non-async components](/docs/environments/server-client-components#shared-components)). | ||
|
||
</Callout> |
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 |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/.next/ | ||
.DS_Store | ||
tsconfig.tsbuildinfo | ||
*storybook.log | ||
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,12 @@ | ||
import type {StorybookConfig} from '@storybook/nextjs'; | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.stories.tsx'], | ||
addons: ['storybook-next-intl'], | ||
framework: { | ||
name: '@storybook/nextjs', | ||
options: {} | ||
}, | ||
staticDirs: ['../public'] | ||
}; | ||
export default config; |
13 changes: 13 additions & 0 deletions
13
examples/example-app-router-playground/.storybook/next-intl.ts
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,13 @@ | ||
import en from '../messages/en.json'; | ||
import de from '../messages/de.json'; | ||
import es from '../messages/es.json'; | ||
import ja from '../messages/ja.json'; | ||
|
||
const messagesByLocale: Record<string, any> = {en, de, es, ja}; | ||
|
||
const nextIntl = { | ||
defaultLocale: 'en', | ||
messagesByLocale | ||
}; | ||
|
||
export default nextIntl; |
19 changes: 19 additions & 0 deletions
19
examples/example-app-router-playground/.storybook/preview.ts
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 {Preview} from '@storybook/react'; | ||
import nextIntl from './next-intl'; | ||
|
||
const preview: Preview = { | ||
initialGlobals: { | ||
locale: 'en', | ||
locales: { | ||
en: 'English', | ||
de: 'Deutsch', | ||
es: 'Español', | ||
ja: '日本語' | ||
} | ||
}, | ||
parameters: { | ||
nextIntl | ||
} | ||
}; | ||
|
||
export default preview; |
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
11 changes: 11 additions & 0 deletions
11
examples/example-app-router-playground/src/components/Navigation.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,11 @@ | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import Navigation from './Navigation'; | ||
|
||
const meta = { | ||
title: 'components/Navigation', | ||
component: Navigation | ||
} satisfies Meta<typeof Navigation>; | ||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
Oops, something went wrong.