2020-09-25 08:40:19 +00:00
|
|
|
import React from 'react'
|
|
|
|
|
2021-02-09 15:39:29 +00:00
|
|
|
import './preview.css'
|
2020-09-25 08:40:19 +00:00
|
|
|
|
|
|
|
// Storybook does not (currently) support async loading of "stories". Therefore
|
|
|
|
// the strategy in frontend/js/i18n.js does not work (because we cannot wait on
|
|
|
|
// the promise to resolve).
|
|
|
|
// Therefore we have to use the synchronous method for configuring
|
|
|
|
// react-i18next. Because this, we can only hard-code a single language.
|
|
|
|
import i18n from 'i18next'
|
|
|
|
import { initReactI18next } from 'react-i18next'
|
|
|
|
import en from '../locales/en.json'
|
|
|
|
i18n.use(initReactI18next).init({
|
|
|
|
lng: 'en',
|
|
|
|
|
|
|
|
resources: {
|
|
|
|
en: { translation: en }
|
|
|
|
},
|
|
|
|
|
|
|
|
react: {
|
|
|
|
useSuspense: false
|
|
|
|
},
|
|
|
|
|
|
|
|
interpolation: {
|
|
|
|
prefix: '__',
|
|
|
|
suffix: '__',
|
|
|
|
unescapeSuffix: 'HTML',
|
|
|
|
skipOnVariables: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export const parameters = {
|
|
|
|
// Automatically mark prop-types like onClick, onToggle, etc as Storybook
|
|
|
|
// "actions", so that they are logged in the Actions pane at the bottom of the
|
|
|
|
// viewer
|
2021-02-03 10:23:17 +00:00
|
|
|
actions: { argTypesRegex: '^on.*' },
|
|
|
|
docs: {
|
|
|
|
// render stories in iframes, to isolate modals
|
|
|
|
inlineStories: false
|
|
|
|
}
|
2020-09-25 08:40:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const globalTypes = {
|
|
|
|
theme: {
|
|
|
|
name: 'Theme',
|
|
|
|
description: 'Editor theme',
|
2021-02-09 15:39:29 +00:00
|
|
|
defaultValue: 'default-',
|
2020-09-25 08:40:19 +00:00
|
|
|
toolbar: {
|
|
|
|
icon: 'circlehollow',
|
2021-02-09 15:39:29 +00:00
|
|
|
items: [
|
|
|
|
{ value: 'default-', title: 'Default' },
|
|
|
|
{ value: 'light-', title: 'Light' },
|
|
|
|
{ value: 'ieee-', title: 'IEEE' }
|
|
|
|
]
|
2020-09-25 08:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-09 15:39:29 +00:00
|
|
|
export const loaders = [
|
|
|
|
async ({ globals }) => {
|
|
|
|
const { theme } = globals
|
|
|
|
|
|
|
|
return {
|
|
|
|
// NOTE: this uses `${theme}style.less` rather than `${theme}.less`
|
|
|
|
// so that webpack only bundles files ending with "style.less"
|
|
|
|
activeStyle: await import(
|
|
|
|
`../frontend/stylesheets/${theme === 'default-' ? '' : theme}style.less`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2020-09-25 08:40:19 +00:00
|
|
|
const withTheme = (Story, context) => {
|
2021-02-09 15:39:29 +00:00
|
|
|
const { activeStyle } = context.loaded
|
|
|
|
|
2020-09-25 08:40:19 +00:00
|
|
|
return (
|
|
|
|
<>
|
2021-02-09 15:39:29 +00:00
|
|
|
{activeStyle && <style>{activeStyle.default}</style>}
|
2020-09-25 08:40:19 +00:00
|
|
|
<Story {...context} />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2021-02-09 15:39:29 +00:00
|
|
|
|
2020-09-25 08:40:19 +00:00
|
|
|
export const decorators = [withTheme]
|
2020-12-09 11:56:34 +00:00
|
|
|
|
|
|
|
window.ExposedSettings = {}
|