Skip to content

Commit

Permalink
Feature/react dictionary docs (#201)
Browse files Browse the repository at this point in the history
* build(react-media):set publish config to public

* docs(react-dictionary): add usedictionary story
  • Loading branch information
sayinserdar authored Oct 13, 2023
1 parent 1d8cb40 commit 4fe44b9
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/storybook/stories/react-dictionary/useDictionary.docs.mdx
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 apps/storybook/stories/react-dictionary/useDictionary.stories.tsx
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>
</>
);
},
};

0 comments on commit 4fe44b9

Please sign in to comment.