overleaf/services/web/frontend/stories/pdf-log-entry.stories.tsx
Antoine Clausse 30860ae9f9 [web] Migrate PDF Logs to BS5 (#21062)
* [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
2024-10-23 08:06:32 +00:00

75 lines
2.1 KiB
TypeScript

import PdfLogEntry from '@/features/pdf-preview/components/pdf-log-entry'
import type { Meta, StoryObj } from '@storybook/react'
import { bsVersionDecorator } from '../../.storybook/utils/with-bootstrap-switcher'
import { ruleIds } from '@/ide/human-readable-logs/HumanReadableLogsHints'
import { ScopeDecorator } from './decorators/scope'
import { useMeta } from './hooks/use-meta'
import { FC, ReactNode } from 'react'
import { useScope } from './hooks/use-scope'
import { EditorView } from '@codemirror/view'
const fakeSourceLocation = {
file: 'file.tex',
line: 12,
column: 5,
}
const fakeLogEntry = {
key: 'fake',
ruleId: 'hint_misplaced_alignment_tab_character',
message: 'Fake message',
messageComponent: 'Fake message component',
content: 'Fake content',
type: 'Error: ',
level: 'error',
contentDetails: ['Fake detail 1', 'Fake detail 2'],
file: 'fake.tex',
line: 12,
column: 5,
raw: 'Fake raw',
}
const fakeArgs = {
headerTitle: 'PDF Preview',
formattedContent: 'This is a log entry',
level: 'error' as const,
extraInfoURL: 'https://example.com',
showCloseButton: true,
showSourceLocationLink: true,
rawContent: 'This is a raw log entry',
contentDetails: ['detail 1', 'detail 2'],
ruleId: 'hint_misplaced_alignment_tab_character' as const,
sourceLocation: fakeSourceLocation,
logEntry: fakeLogEntry,
logType: 'Fake type',
}
const meta: Meta<typeof PdfLogEntry> = {
title: 'Editor / PDF Preview / Logs',
component: PdfLogEntry,
// @ts-ignore
decorators: [ScopeDecorator],
argTypes: {
ruleId: { control: 'select', options: [...ruleIds, 'other'] },
...bsVersionDecorator.argTypes,
},
args: fakeArgs,
}
export default meta
type Story = StoryObj<typeof PdfLogEntry>
const Provider: FC<{ children: ReactNode }> = ({ children }) => {
useMeta({ 'ol-showAiErrorAssistant': true })
useScope({ 'editor.view': new EditorView({ doc: '\\begin{document' }) })
return <div className="logs-pane p-2">{children}</div>
}
export const PdfLogEntryWithControls: Story = {
render: args => (
<Provider>
<PdfLogEntry {...args} />
</Provider>
),
}