/* Registering of global Storybook decorators. * Copyright (C) 2024 André Jaenisch * SPDX-FileCopyrightText: 2024 André Jaenisch * SPDX-License-Identifier: AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ import type { Preview } from '@storybook/svelte'; import { init, locale, register } from 'svelte-i18n'; import { mapLocaleToDir } from '../src/lib/i18n/index.ts'; // See src/routes/+layout.svelte // Order is important! import '../src/theme.postcss'; //import '@skeletonlabs/skeleton/styles/skeleton.css'; import '../src/app.postcss'; import './fix.css'; register('de', () => import('../src/lib/i18n/locales/de.json')); register('en', () => import('../src/lib/i18n/locales/en.json')); register('he', () => import('../src/lib/i18n/locales/he.json')); init({ fallbackLocale: 'en', initialLocale: 'en' }); locale.set('en'); function withI18n(storyFn, context) { const l = context.globals.locale; locale.set(l); document.dir = mapLocaleToDir(l); return storyFn(); } const preview: Preview = { globalTypes: { locale: { description: 'Internationalization locale', defaultValue: 'en', toolbar: { icon: 'globe', items: [ { value: 'de', title: 'German' }, { value: 'en', title: 'English' }, { value: 'he', title: 'Hebrew' } ] } } }, parameters: { actions: { argTypesRegex: '^on[A-Z].*' }, controls: { matchers: { color: /(background|color)$/i, date: /Date$/i } } } }; export const decorators = [withI18n]; export default preview;