diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ed62afd..fc376308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to - ♻️ Allow null titles on documents for easier creation #234 - 🛂(backend) stop to list public doc to everyone #234 - 🚚(frontend) change visibility in share modal #235 +- ⚡️(frontend) Improve summary #244 ## Fixed diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-summary.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-summary.spec.ts index 18770e99..a2f6c33a 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-summary.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-summary.spec.ts @@ -15,7 +15,7 @@ test.describe('Doc Summary', () => { await page.getByLabel('Open the document options').click(); await page .getByRole('button', { - name: 'Summary', + name: 'Table of content', }) .click(); @@ -29,7 +29,7 @@ test.describe('Doc Summary', () => { await page.locator('.bn-block-outer').last().click(); // Create space to fill the viewport - for (let i = 0; i < 6; i++) { + for (let i = 0; i < 5; i++) { await page.keyboard.press('Enter'); } @@ -40,7 +40,7 @@ test.describe('Doc Summary', () => { await page.locator('.bn-block-outer').last().click(); // Create space to fill the viewport - for (let i = 0; i < 4; i++) { + for (let i = 0; i < 5; i++) { await page.keyboard.press('Enter'); } @@ -48,17 +48,41 @@ test.describe('Doc Summary', () => { await page.getByText('Heading 3').click(); await page.keyboard.type('Another World'); - await expect(panel.getByText('Hello World')).toBeVisible(); - await expect(panel.getByText('Super World')).toBeVisible(); + const hello = panel.getByText('Hello World'); + const superW = panel.getByText('Super World'); + const another = panel.getByText('Another World'); - await panel.getByText('Another World').click(); + await expect(hello).toBeVisible(); + await expect(hello).toHaveCSS('font-size', '19.2px'); + await expect(hello).toHaveAttribute('aria-selected', 'true'); + + await expect(superW).toBeVisible(); + await expect(superW).toHaveCSS('font-size', '16px'); + await expect(superW).toHaveAttribute('aria-selected', 'false'); + + await expect(another).toBeVisible(); + await expect(another).toHaveCSS('font-size', '12.8px'); + await expect(another).toHaveAttribute('aria-selected', 'false'); + + await hello.click(); + + await expect(editor.getByText('Hello World')).toBeInViewport(); + await expect(hello).toHaveAttribute('aria-selected', 'true'); + await expect(superW).toHaveAttribute('aria-selected', 'false'); + + await another.click(); await expect(editor.getByText('Hello World')).not.toBeInViewport(); + await expect(hello).toHaveAttribute('aria-selected', 'false'); + await expect(superW).toHaveAttribute('aria-selected', 'true'); await panel.getByText('Back to top').click(); await expect(editor.getByText('Hello World')).toBeInViewport(); + await expect(hello).toHaveAttribute('aria-selected', 'true'); + await expect(superW).toHaveAttribute('aria-selected', 'false'); await panel.getByText('Go to bottom').click(); await expect(editor.getByText('Hello World')).not.toBeInViewport(); + await expect(superW).toHaveAttribute('aria-selected', 'true'); }); }); diff --git a/src/frontend/apps/impress/src/components/Panel.tsx b/src/frontend/apps/impress/src/components/Panel.tsx index 37c7ca55..7335cb08 100644 --- a/src/frontend/apps/impress/src/components/Panel.tsx +++ b/src/frontend/apps/impress/src/components/Panel.tsx @@ -5,7 +5,7 @@ import { Box, Card, IconBG, Text } from '@/components'; import { useCunninghamTheme } from '@/cunningham'; interface PanelProps { - title: string; + title?: string; setIsPanelOpen: (isOpen: boolean) => void; } @@ -53,11 +53,14 @@ export const Panel = ({ {...closedOverridingStyles} > - - {title} - + {title && ( + + {title} + + )} {children} diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx index 883702c8..b379ba11 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/DocEditor.tsx @@ -9,7 +9,7 @@ import { Panel } from '@/components/Panel'; import { useCunninghamTheme } from '@/cunningham'; import { DocHeader } from '@/features/docs/doc-header'; import { Doc } from '@/features/docs/doc-management'; -import { Summary, useDocSummaryStore } from '@/features/docs/doc-summary'; +import { Summary } from '@/features/docs/doc-summary'; import { VersionList, Versions, @@ -28,8 +28,6 @@ export const DocEditor = ({ doc }: DocEditorProps) => { query: { versionId }, } = useRouter(); const { isPanelVersionOpen, setIsPanelVersionOpen } = useDocVersionStore(); - const { isPanelSummaryOpen, setIsPanelSummaryOpen } = useDocSummaryStore(); - const { t } = useTranslation(); const isVersion = versionId && typeof versionId === 'string'; @@ -72,11 +70,7 @@ export const DocEditor = ({ doc }: DocEditorProps) => { )} - {isPanelSummaryOpen && ( - - - - )} + ); diff --git a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx index 9e00a88a..2cd02d5a 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-header/components/DocToolBox.tsx @@ -91,7 +91,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => { icon={summarize} size="small" > - {t('Summary')} + {t('Table of content')}