2021-02-09 10:39:29 -05:00
|
|
|
import './preview.css'
|
2020-09-25 04:40:19 -04: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: {
|
2021-04-27 03:52:58 -04:00
|
|
|
en: { translation: en },
|
2020-09-25 04:40:19 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
react: {
|
2021-04-27 03:52:58 -04:00
|
|
|
useSuspense: false,
|
2020-09-25 04:40:19 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
interpolation: {
|
|
|
|
prefix: '__',
|
|
|
|
suffix: '__',
|
|
|
|
unescapeSuffix: 'HTML',
|
2021-03-25 06:11:31 -04:00
|
|
|
skipOnVariables: true,
|
|
|
|
defaultVariables: {
|
2021-04-27 03:52:58 -04:00
|
|
|
appName: 'Overleaf',
|
|
|
|
},
|
|
|
|
},
|
2020-09-25 04:40:19 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
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 05:23:17 -05:00
|
|
|
actions: { argTypesRegex: '^on.*' },
|
|
|
|
docs: {
|
|
|
|
// render stories in iframes, to isolate modals
|
2021-04-27 03:52:58 -04:00
|
|
|
inlineStories: false,
|
|
|
|
},
|
2020-09-25 04:40:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export const globalTypes = {
|
|
|
|
theme: {
|
|
|
|
name: 'Theme',
|
|
|
|
description: 'Editor theme',
|
2021-02-09 10:39:29 -05:00
|
|
|
defaultValue: 'default-',
|
2020-09-25 04:40:19 -04:00
|
|
|
toolbar: {
|
|
|
|
icon: 'circlehollow',
|
2021-02-09 10:39:29 -05:00
|
|
|
items: [
|
|
|
|
{ value: 'default-', title: 'Default' },
|
|
|
|
{ value: 'light-', title: 'Light' },
|
2021-04-27 03:52:58 -04:00
|
|
|
{ value: 'ieee-', title: 'IEEE' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-09-25 04:40:19 -04:00
|
|
|
}
|
|
|
|
|
2021-02-09 10:39:29 -05: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(
|
2021-10-12 04:49:07 -04:00
|
|
|
`!!to-string-loader!css-loader!less-loader!../frontend/stylesheets/${
|
|
|
|
theme === 'default-' ? '' : theme
|
|
|
|
}style.less`
|
2021-04-27 03:52:58 -04:00
|
|
|
),
|
2021-02-09 10:39:29 -05:00
|
|
|
}
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2021-02-09 10:39:29 -05:00
|
|
|
]
|
|
|
|
|
2020-09-25 04:40:19 -04:00
|
|
|
const withTheme = (Story, context) => {
|
2021-02-09 10:39:29 -05:00
|
|
|
const { activeStyle } = context.loaded
|
|
|
|
|
2020-09-25 04:40:19 -04:00
|
|
|
return (
|
|
|
|
<>
|
2021-02-09 10:39:29 -05:00
|
|
|
{activeStyle && <style>{activeStyle.default}</style>}
|
2020-09-25 04:40:19 -04:00
|
|
|
<Story {...context} />
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2021-02-09 10:39:29 -05:00
|
|
|
|
2020-09-25 04:40:19 -04:00
|
|
|
export const decorators = [withTheme]
|
2020-12-09 06:56:34 -05:00
|
|
|
|
2021-03-18 05:52:36 -04:00
|
|
|
window.ExposedSettings = {
|
|
|
|
maxEntitiesPerProject: 10,
|
2021-04-27 03:52:58 -04:00
|
|
|
maxUploadSize: 5 * 1024 * 1024,
|
2021-04-30 16:20:16 -04:00
|
|
|
enableSubscriptions: true,
|
2021-05-21 07:32:42 -04:00
|
|
|
textExtensions: [
|
|
|
|
'tex',
|
|
|
|
'latex',
|
|
|
|
'sty',
|
|
|
|
'cls',
|
|
|
|
'bst',
|
|
|
|
'bib',
|
|
|
|
'bibtex',
|
|
|
|
'txt',
|
|
|
|
'tikz',
|
|
|
|
'mtx',
|
|
|
|
'rtex',
|
|
|
|
'md',
|
|
|
|
'asy',
|
|
|
|
'latexmkrc',
|
|
|
|
'lbx',
|
|
|
|
'bbx',
|
|
|
|
'cbx',
|
|
|
|
'm',
|
|
|
|
'lco',
|
|
|
|
'dtx',
|
|
|
|
'ins',
|
|
|
|
'ist',
|
|
|
|
'def',
|
|
|
|
'clo',
|
|
|
|
'ldf',
|
|
|
|
'rmd',
|
|
|
|
'lua',
|
|
|
|
'gv',
|
|
|
|
'mf',
|
|
|
|
],
|
2021-04-30 16:20:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
window.user = {
|
|
|
|
id: 'storybook',
|
2021-03-18 05:52:36 -04:00
|
|
|
}
|
2021-09-17 06:58:30 -04:00
|
|
|
|
|
|
|
window.project_id = 'storybook-project'
|
2021-10-21 04:10:25 -04:00
|
|
|
window.showNewPdfPreview = true
|