mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 19:24:53 -05:00
30860ae9f9
* [web] Migrate Logs components JSX to Bootstrap 5 * [web] Migrate logs.less to logs.scss * [web] Remove unused class names * [storybook] Define default Bootstrap version in Storybook This prevents some warning in the console * [storybook] Update pdf-preview.stories.jsx * [storybook] Add pdf-log-entry.stories.tsx * [storybook] Force re-renders when switching BS version * [web] Keep files dropdown menu in bounds * [web] Make files dropdown items not bold in BS5 * [web] Revert unrelated change * [web] Fixup PreviewLogsPaneMaxEntries * [web] Add style for log-entry-content-link * [web] Replace log-entry by OLNotification in `PdfCodeCheckFailedNotice` * [web] Use `BootstrapVersionSwitcher` instead of `isBootstrap5` * [web] Rename `DropdownBS3` to `BS3Dropdown` * [web] Reuse variables for `toolbar-height` and `toolbar-small-height` * [web] Set `id` on `DropdownToggle` not `Dropdown` * [web] Set `log-entry-btn-expand-collapse` in BS3 only * [web] Remove `block: true` from StartFreeTrialButton in BS3 * [web] Remove unnecessary CSS in `.log-entry-header-link` * [web] Use semantic color names * Migrate the downloadable pdf file list to Bootstrap 5 * Remove nested BootstrapVersionSwitcher, fix "key" prop * Update roles to: `<li role="menuitem">` `<a role="link">` * Update `log-entry-header-link`: variant ghost and fix colors --------- Co-authored-by: Rebeka <o.dekany@gmail.com> GitOrigin-RevId: 89848970ab5d8a8c135335386caf24363f69a34c
194 lines
5.2 KiB
TypeScript
194 lines
5.2 KiB
TypeScript
import type { Preview } from '@storybook/react'
|
|
|
|
// 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'
|
|
// @ts-ignore
|
|
import en from '../../../services/web/locales/en.json'
|
|
import { bootstrapVersionArg } from './utils/with-bootstrap-switcher'
|
|
|
|
function resetMeta(bootstrapVersion?: 3 | 5) {
|
|
window.metaAttributesCache = new Map()
|
|
window.metaAttributesCache.set('ol-i18n', { currentLangCode: 'en' })
|
|
if (bootstrapVersion) {
|
|
window.metaAttributesCache.set('ol-bootstrapVersion', bootstrapVersion)
|
|
}
|
|
window.metaAttributesCache.set('ol-ExposedSettings', {
|
|
adminEmail: 'placeholder@example.com',
|
|
appName: 'Overleaf',
|
|
cookieDomain: '.overleaf.stories',
|
|
dropboxAppName: 'Overleaf-Stories',
|
|
emailConfirmationDisabled: false,
|
|
enableSubscriptions: true,
|
|
hasAffiliationsFeature: false,
|
|
hasLinkUrlFeature: true,
|
|
hasLinkedProjectFileFeature: true,
|
|
hasLinkedProjectOutputFileFeature: true,
|
|
hasSamlFeature: true,
|
|
ieeeBrandId: 15,
|
|
isOverleaf: true,
|
|
labsEnabled: true,
|
|
maxEntitiesPerProject: 10,
|
|
maxUploadSize: 5 * 1024 * 1024,
|
|
recaptchaDisabled: {
|
|
invite: true,
|
|
login: true,
|
|
passwordReset: true,
|
|
register: true,
|
|
addEmail: true,
|
|
},
|
|
sentryAllowedOriginRegex: '',
|
|
siteUrl: 'http://localhost',
|
|
templateLinks: [],
|
|
textExtensions: [
|
|
'tex',
|
|
'latex',
|
|
'sty',
|
|
'cls',
|
|
'bst',
|
|
'bib',
|
|
'bibtex',
|
|
'txt',
|
|
'tikz',
|
|
'mtx',
|
|
'rtex',
|
|
'md',
|
|
'asy',
|
|
'lbx',
|
|
'bbx',
|
|
'cbx',
|
|
'm',
|
|
'lco',
|
|
'dtx',
|
|
'ins',
|
|
'ist',
|
|
'def',
|
|
'clo',
|
|
'ldf',
|
|
'rmd',
|
|
'lua',
|
|
'gv',
|
|
'mf',
|
|
'lhs',
|
|
'mk',
|
|
'xmpdata',
|
|
'cfg',
|
|
'rnw',
|
|
'ltx',
|
|
'inc',
|
|
],
|
|
editableFilenames: ['latexmkrc', '.latexmkrc', 'makefile', 'gnumakefile'],
|
|
validRootDocExtensions: ['tex', 'Rtex', 'ltx', 'Rnw'],
|
|
fileIgnorePattern:
|
|
'**/{{__MACOSX,.git,.texpadtmp,.R}{,/**},.!(latexmkrc),*.{dvi,aux,log,toc,out,pdfsync,synctex,synctex(busy),fdb_latexmk,fls,nlo,ind,glo,gls,glg,bbl,blg,doc,docx,gz,swp}}',
|
|
projectUploadTimeout: 12000,
|
|
})
|
|
}
|
|
|
|
i18n.use(initReactI18next).init({
|
|
lng: 'en',
|
|
|
|
// still using the v3 plural suffixes
|
|
compatibilityJSON: 'v3',
|
|
|
|
resources: {
|
|
en: { translation: en },
|
|
},
|
|
|
|
react: {
|
|
useSuspense: false,
|
|
transSupportBasicHtmlNodes: false,
|
|
},
|
|
|
|
interpolation: {
|
|
prefix: '__',
|
|
suffix: '__',
|
|
unescapeSuffix: 'HTML',
|
|
skipOnVariables: true,
|
|
escapeValue: false,
|
|
defaultVariables: {
|
|
appName: 'Overleaf',
|
|
},
|
|
},
|
|
})
|
|
|
|
const preview: Preview = {
|
|
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
|
|
actions: { argTypesRegex: '^on.*' },
|
|
docs: {
|
|
// render stories in iframes, to isolate modals
|
|
inlineStories: false,
|
|
},
|
|
// Default to Bootstrap 3 styles
|
|
bootstrap5: false,
|
|
},
|
|
globalTypes: {
|
|
theme: {
|
|
name: 'Theme',
|
|
description: 'Editor theme',
|
|
defaultValue: 'main-',
|
|
toolbar: {
|
|
icon: 'circlehollow',
|
|
items: [
|
|
{ value: 'main-', title: 'Default' },
|
|
{ value: 'main-light-', title: 'Light' },
|
|
{ value: 'main-ieee-', title: 'IEEE' },
|
|
],
|
|
},
|
|
},
|
|
},
|
|
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"
|
|
bootstrap3Style: await import(
|
|
`!!to-string-loader!css-loader!less-loader!../../../services/web/frontend/stylesheets/${theme}style.less`
|
|
),
|
|
// NOTE: this uses `${theme}style.scss` rather than `${theme}.scss`
|
|
// so that webpack only bundles files ending with "style.scss"
|
|
bootstrap5Style: await import(
|
|
`!!to-string-loader!css-loader!resolve-url-loader!sass-loader!../../../services/web/frontend/stylesheets/bootstrap-5/${theme}style.scss`
|
|
),
|
|
}
|
|
},
|
|
],
|
|
decorators: [
|
|
(Story, context) => {
|
|
const { bootstrap3Style, bootstrap5Style } = context.loaded
|
|
const bootstrapVersion = Number(
|
|
context.args[bootstrapVersionArg] ||
|
|
(context.parameters.bootstrap5 ? 5 : 3)
|
|
) as 3 | 5
|
|
const activeStyle =
|
|
bootstrapVersion === 5 ? bootstrap5Style : bootstrap3Style
|
|
|
|
resetMeta(bootstrapVersion)
|
|
|
|
return (
|
|
<>
|
|
{activeStyle && <style>{activeStyle.default}</style>}
|
|
<Story
|
|
{...context}
|
|
// force re-renders when switching between Bootstrap versions
|
|
key={bootstrapVersion}
|
|
/>
|
|
</>
|
|
)
|
|
},
|
|
],
|
|
}
|
|
|
|
export default preview
|
|
|
|
// Populate meta for top-level access in modules on import
|
|
resetMeta()
|