Skip to content

Commit

Permalink
[Upd #209] Storybook global locale setting on the top toolbar; Proof …
Browse files Browse the repository at this point in the history
…of concept
  • Loading branch information
VojtechLunak committed Jul 3, 2023
1 parent 4d07c05 commit 2656432
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ export const globalTypes = {
],
control: { type: "radio" },
},
locale2: {
description: "Internationalization locale",
defaultValue: "en",
toolbar: {
icon: "globe",
items: [
{ value: "en", right: "🇺🇸", title: "English" },
{ value: "cs", right: "🇨🇿", title: "Česky" },
],
dynamicTitle: true,
},
},
locale: {
name: "Locale",
description: "Internationalization locale",
Expand Down Expand Up @@ -105,10 +117,10 @@ const fetchTypeAheadValues = () => {

export const preview = {
decorators: [
(Story) => (
(Story, context) => (
<ConfigurationContextProvider options={options}>
<FormGenContextProvider fetchTypeAheadValues={fetchTypeAheadValues}>
<IntlContextProvider locale={globalTypes.locale.defaultValue}>
<IntlContextProvider locale={context.globals.locale2}>
<Story />
</IntlContextProvider>
</FormGenContextProvider>
Expand Down
4 changes: 3 additions & 1 deletion src/stories/Answer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import Answer from "../components/Answer";
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { preview } from "../../.storybook/preview";

import question from "./assets/question/questionWithMedia.json";
import questionTypeHead from "./assets/question/questionTypeHead.json";
Expand All @@ -13,7 +14,8 @@ import questionTurtleInput from "./assets/question/questionTurtleInput.json";
export default {
title: "Components/Answer",
component: Answer,
} as ComponentMeta<typeof Answer>;
decorators: preview.decorators,
};

const Template: ComponentStory<typeof Answer> = (args) => {
return (
Expand Down

0 comments on commit 2656432

Please sign in to comment.