mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 20:21:07 +08:00
34 lines
790 B
TypeScript
34 lines
790 B
TypeScript
import { global as globalThis } from '@storybook/global';
|
|
import type { PartialStoryFn, StoryContext } from '@storybook/types';
|
|
|
|
const greetingForLocale = (locale: string) => {
|
|
switch (locale) {
|
|
case 'es':
|
|
return 'Hola!';
|
|
case 'fr':
|
|
return 'Bonjour !';
|
|
case 'zh':
|
|
return '你好!';
|
|
case 'kr':
|
|
return '안녕하세요!';
|
|
case 'en':
|
|
default:
|
|
return 'Hello';
|
|
}
|
|
};
|
|
|
|
export default {
|
|
component: globalThis.Components.Pre,
|
|
decorators: [
|
|
(storyFn: PartialStoryFn, { globals }: StoryContext) => {
|
|
const object = {
|
|
...globals,
|
|
caption: `Locale is '${globals.locale}', so I say: ${greetingForLocale(globals.locale)}`,
|
|
};
|
|
return storyFn({ args: { object } });
|
|
},
|
|
],
|
|
};
|
|
|
|
export const Basic = {};
|