Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbars: Generic example stories #19166

Merged
merged 4 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions code/addons/toolbars/template/stories/globals.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import globalThis from 'global';
import { PartialStoryFn, StoryContext } from '@storybook/csf';

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: null,
decorators: [
(storyFn: PartialStoryFn, { globals }: StoryContext) => {
const object = {
...globals,
caption: `Locale is '${globals.locale}', so I say: ${greetingForLocale(globals.locale)}`,
};
return storyFn({ component: globalThis.Components.Pre, args: { object } });
shilman marked this conversation as resolved.
Show resolved Hide resolved
},
],
};

export const Basic = {};
44 changes: 44 additions & 0 deletions code/addons/toolbars/template/stories/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const globalTypes = {
theme: {
name: 'Theme',
description: 'Global theme for components',
toolbar: {
icon: 'circlehollow',
title: 'Theme',
items: [
{ value: 'light', icon: 'circlehollow', title: 'light' },
{ value: 'dark', icon: 'circle', title: 'dark' },
{ value: 'side-by-side', icon: 'sidebar', title: 'side by side' },
{ value: 'stacked', icon: 'bottombar', title: 'stacked' },
],
},
},
locale: {
name: 'Locale',
description: 'Internationalization locale',
toolbar: {
icon: 'globe',
shortcuts: {
next: {
label: 'Go to next language',
keys: ['L'],
},
previous: {
label: 'Go to previous language',
keys: ['K'],
},
reset: {
label: 'Reset language',
keys: ['meta', 'shift', 'L'],
},
},
items: [
{ title: 'Reset locale', type: 'reset' },
{ value: 'en', right: '🇺🇸', title: 'English' },
{ value: 'es', right: '🇪🇸', title: 'Español' },
{ value: 'zh', right: '🇨🇳', title: '中文' },
{ value: 'kr', right: '🇰🇷', title: '한국어' },
],
},
},
};