2024-11-21 13:52:20 +03:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* Main file for Storybook configuration.
|
|
|
|
*/
|
|
|
|
import type { StorybookConfig as ReactStorybookConfig } from '@storybook/react-vite'
|
|
|
|
import type { StorybookConfig as VueStorybookConfig } from '@storybook/vue3-vite'
|
|
|
|
import z from 'zod'
|
|
|
|
|
|
|
|
const framework = z.enum(['vue', 'react']).parse(process.env.FRAMEWORK)
|
|
|
|
|
|
|
|
const sharedConfig: Partial<ReactStorybookConfig> = {
|
|
|
|
addons: [
|
|
|
|
'@storybook/addon-onboarding',
|
|
|
|
'@storybook/addon-essentials',
|
|
|
|
'@chromatic-com/storybook',
|
|
|
|
'@storybook/addon-interactions',
|
|
|
|
],
|
|
|
|
features: {},
|
|
|
|
core: { disableTelemetry: true },
|
|
|
|
env: { FRAMEWORK: framework },
|
|
|
|
|
|
|
|
previewHead: (head) => {
|
2024-11-22 17:03:41 +03:00
|
|
|
return /*html*/ `
|
|
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin />
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
|
|
<link
|
|
|
|
href="https://fonts.googleapis.com/css2?family=M+PLUS+1:wght@300;400;500;600;700&display=swap"
|
|
|
|
rel="preload"
|
|
|
|
as="style"
|
|
|
|
crossorigin
|
|
|
|
/>
|
|
|
|
|
2024-11-21 13:52:20 +03:00
|
|
|
<script>
|
|
|
|
window.global = window;
|
2024-11-22 17:03:41 +03:00
|
|
|
|
|
|
|
// Pass environment variables to the storybook
|
2024-11-21 13:52:20 +03:00
|
|
|
window.ENV = {
|
2024-11-22 17:03:41 +03:00
|
|
|
// The framework used to render the story
|
|
|
|
// Used by the preview to determine which framework to use
|
2024-11-21 13:52:20 +03:00
|
|
|
FRAMEWORK: '${framework}',
|
|
|
|
}
|
2024-11-22 17:03:41 +03:00
|
|
|
|
|
|
|
// Allow React DevTools to work in Storybook
|
|
|
|
if (window.parent !== window) {
|
|
|
|
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__
|
|
|
|
}
|
2024-11-28 00:20:36 +03:00
|
|
|
|
|
|
|
document.documentElement.classList.add('macos')
|
2024-11-21 13:52:20 +03:00
|
|
|
</script>
|
|
|
|
${head}
|
|
|
|
`
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const vueConfig: VueStorybookConfig = {
|
|
|
|
...sharedConfig,
|
|
|
|
stories: [
|
|
|
|
'../src/project-view/**/*.mdx',
|
|
|
|
'../src/project-view/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
|
|
],
|
|
|
|
framework: {
|
|
|
|
name: '@storybook/vue3-vite',
|
|
|
|
options: {},
|
|
|
|
},
|
|
|
|
refs: {
|
|
|
|
Dashboard: {
|
|
|
|
title: 'Dashboard',
|
|
|
|
url: 'http://localhost:6007',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
const reactConfig: ReactStorybookConfig = {
|
|
|
|
...sharedConfig,
|
|
|
|
stories: ['../src/dashboard/**/*.mdx', '../src/dashboard/**/*.stories.tsx'],
|
|
|
|
framework: {
|
|
|
|
name: '@storybook/react-vite',
|
|
|
|
options: { strictMode: true },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default framework === 'vue' ? vueConfig : reactConfig
|