|
1 |
| -/* eslint-disable @typescript-eslint/no-explicit-any */ |
2 |
| -import { app } from "@storybook/vue3"; |
3 |
| -import vueRouter from "storybook-vue3-router"; |
4 |
| -import { createI18n } from "vue-i18n"; |
| 1 | +import { setup } from "@storybook/vue3"; |
| 2 | +import { vueRouter } from "storybook-vue3-router"; |
| 3 | +import { useLanguages } from "../client-app/core/composables"; |
5 | 4 | import { setGlobals } from "../client-app/core/globals";
|
6 |
| -import * as UIKitComponents from "../client-app/ui-kit/components"; |
7 |
| -import SettingsData from "../config/settings_data.json"; |
8 |
| -import en from "../locales/en.json"; |
| 5 | +import { configPlugin } from "../client-app/core/plugins"; |
| 6 | +import { createI18n } from "../client-app/i18n"; |
| 7 | +import { uiKit } from "../client-app/ui-kit"; |
| 8 | +import type { IThemeConfig } from "../client-app/core/types"; |
9 | 9 | import type { I18n } from "../client-app/i18n";
|
10 |
| - |
11 |
| -/* Project Styles */ |
| 10 | +import type { Preview } from "@storybook/vue3"; |
| 11 | +import type { App } from "vue"; |
12 | 12 | import "../client-app/assets/styles/main.scss";
|
13 | 13 |
|
14 |
| -const i18n: I18n = createI18n({ |
15 |
| - legacy: false, |
16 |
| - locale: "en", |
17 |
| - messages: { |
18 |
| - en, |
19 |
| - }, |
20 |
| -}); |
| 14 | +const i18n: I18n = createI18n("en", "USD"); |
21 | 15 |
|
22 | 16 | setGlobals({ i18n });
|
23 | 17 |
|
24 |
| -app.use(i18n); |
25 |
| - |
26 |
| -/* Setting project CSS variables */ |
27 |
| -const settings = |
28 |
| - typeof SettingsData.current === "string" |
29 |
| - ? (<Record<string, any>>SettingsData).presets[SettingsData.current] |
30 |
| - : SettingsData.current; |
31 |
| - |
32 |
| -Object.entries(settings) |
33 |
| - .filter(([key]) => /^color/.test(key)) |
34 |
| - .forEach(([key, value]) => { |
35 |
| - document.documentElement.style.setProperty(`--${key.replace(/_/g, "-")}`, `${value}`); |
36 |
| - }); |
37 |
| - |
38 |
| -// Register UI Kit components |
39 |
| -Object.entries(UIKitComponents).forEach(([name, component]) => app.component(name, component)); |
40 |
| - |
41 |
| -export const parameters = { |
42 |
| - actions: { argTypesRegex: "^on[A-Z].*" }, |
43 |
| - controls: { |
44 |
| - matchers: { |
45 |
| - color: /(background|color)$/i, |
46 |
| - date: /Date$/, |
| 18 | +async function configureThemeSettings(app: App) { |
| 19 | + const settings: IThemeConfig = await import("../config/settings_data.json"); |
| 20 | + const themeSettings = settings.presets[settings.current as string]; |
| 21 | + |
| 22 | + app.use(configPlugin, themeSettings); |
| 23 | +} |
| 24 | + |
| 25 | +async function configureI18N() { |
| 26 | + const { setLocale } = useLanguages(); |
| 27 | + |
| 28 | + await setLocale(i18n, "en"); |
| 29 | +} |
| 30 | + |
| 31 | +setup((app) => { |
| 32 | + configureThemeSettings(app); |
| 33 | + |
| 34 | + configureI18N(); |
| 35 | + app.use(i18n); |
| 36 | + |
| 37 | + app.use(uiKit); |
| 38 | +}); |
| 39 | + |
| 40 | +const preview: Preview = { |
| 41 | + decorators: [vueRouter()], |
| 42 | + parameters: { |
| 43 | + actions: { argTypesRegex: "^on[A-Z].*" }, |
| 44 | + controls: { |
| 45 | + matchers: { |
| 46 | + color: /(background|color)$/i, |
| 47 | + date: /Date$/, |
| 48 | + }, |
| 49 | + expanded: true, |
47 | 50 | },
|
48 |
| - expanded: true, |
49 |
| - }, |
50 |
| - options: { |
51 |
| - storySort: { |
52 |
| - order: ["*", "Components", ["Atoms", "Molecules", "Organisms", "Templates", "Pages"]], |
| 51 | + options: { |
| 52 | + storySort: { |
| 53 | + order: ["*", "Components", ["Atoms", "Molecules", "Organisms", "Templates", "Pages"]], |
| 54 | + }, |
53 | 55 | },
|
54 | 56 | },
|
55 |
| - previewTabs: { "storybook/docs/panel": { index: -1 } }, |
56 |
| - viewMode: "docs", |
57 | 57 | };
|
58 | 58 |
|
59 |
| -export const decorators = [vueRouter()]; |
| 59 | +export default preview; |
0 commit comments