Skip to content

arckit-dev/storybook

Repository files navigation

@arckit/storybook

Storybook decorators and utilities for i18n-enabled component stories.

npm version npm downloads bundle size codecov TypeScript

📑 Table of Contents

🪧 About

Provides a translation helper and a withI18nProvider Storybook decorator for rendering stories with i18n support. Built on @arckit/i18n and i18next.

📦 Installation

pnpm add -D @arckit/storybook

🚀 Usage

Decorator for stories

import { withI18nProvider } from '@arckit/storybook';
import translations from '@public/locales/en-US/my-namespace.json';

const meta = {
  decorators: [withI18nProvider('en-US', { 'my-namespace': translations })]
};

Translation helper for tests

import { translation } from '@arckit/storybook';

const t = translation('en-US', { 'my-namespace': translations });

📖 API

Export Description
translation(lng, resources) Creates a typed translation function from locale resources. Returns a t function.
withI18nProvider(lng, resources) Storybook decorator that wraps a story with I18nProvider and provides the translation function via injection.

🤗 Contributing

See CONTRIBUTING.md for details.

📝 License

MIT © Marc Gavanier

About

Storybook decorators and utilities for i18n-enabled component stories

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors