-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/react dictionary docs (#201)
* build(react-media):set publish config to public * docs(react-dictionary): add usedictionary story
- Loading branch information
1 parent
1d8cb40
commit 4fe44b9
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
apps/storybook/stories/react-dictionary/useDictionary.docs.mdx
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 { Canvas, Meta, Story } from "@storybook/blocks"; | ||
|
||
import * as useDictionaryStories from "./useDictionary.stories"; | ||
|
||
<Meta of={useDictionaryStories} /> | ||
|
||
<Canvas of={useDictionaryStories.Default} /> | ||
|
||
# useDictionary | ||
|
||
Simple localized key value storage. |
60 changes: 60 additions & 0 deletions
60
apps/storybook/stories/react-dictionary/useDictionary.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,60 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import docs from "./useDictionary.docs.mdx"; | ||
import { DictionaryProvider, useDictionary } from "@codedazur/react-dictionary"; | ||
import { Button, Row } from "@codedazur/react-components"; | ||
|
||
const meta: Meta = { | ||
title: "React-Dictionary/useDictionary", | ||
parameters: { | ||
docs: { | ||
page: docs, | ||
}, | ||
}, | ||
args: { | ||
locale: "de", | ||
}, | ||
argTypes: { | ||
locale: { | ||
control: "select", | ||
options: ["nl", "de", "en"], | ||
}, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const DictionaryConsumer = () => { | ||
const dictionary = useDictionary(); | ||
const register = dictionary.get("register"); | ||
|
||
return ( | ||
<Row> | ||
<Button>{register}</Button> | ||
</Row> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<{ locale: string }> = { | ||
render: function Default({ locale, ...rest }) { | ||
return ( | ||
<> | ||
<DictionaryProvider | ||
{...rest} | ||
locale={locale} | ||
dictionaries={{ | ||
en: { | ||
register: "Register", | ||
}, | ||
nl: { | ||
register: "Registreren", | ||
}, | ||
de: { | ||
register: "Registrieren", | ||
}, | ||
}} | ||
> | ||
<DictionaryConsumer /> | ||
</DictionaryProvider> | ||
</> | ||
); | ||
}, | ||
}; |