Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure storybook for data router #524

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import type { Preview } from '@storybook/react'
import { ThemeProvider } from '@iqss/dataverse-design-system'
import { MemoryRouter } from 'react-router-dom'
import { createBrowserRouter, RouteObject, RouterProvider } from 'react-router-dom'
import { FakerHelper } from '../tests/component/shared/FakerHelper'
import 'react-loading-skeleton/dist/skeleton.css'

Expand All @@ -17,11 +18,18 @@ const preview: Preview = {
decorators: [
(Story) => {
FakerHelper.setFakerSeed()

const routes: RouteObject[] = [
{
element: <Story />,
path: '/*'
}
]
const browserRouter = createBrowserRouter(routes)

return (
<ThemeProvider>
<MemoryRouter>
<Story />
</MemoryRouter>
<RouterProvider router={browserRouter} />
</ThemeProvider>
)
}
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig({
},
env: {
codeCoverage: {
exclude: 'tests/**/*.*'
exclude: ['tests/**/*.*', '**/ErrorPage.tsx']
}
}
})
1 change: 1 addition & 0 deletions packages/design-system/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import type { Preview } from '@storybook/react'
import { ThemeProvider } from '../src/lib/components/theme/ThemeProvider'
import DocumentationTemplate from '../src/lib/stories/DocumentationTemplate.mdx'
Expand Down
12 changes: 12 additions & 0 deletions src/sections/error-page/ErrorPage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@
justify-content: center;
width: 100%;
padding-block: 2rem;

h1 {
display: flex;
flex-direction: column;
gap: 0.5rem;
margin: 0;

span {
display: block;
font-size: 22px;
}
}
}
8 changes: 4 additions & 4 deletions src/sections/error-page/ErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export function ErrorPage({ fullViewport = false }: AppLoaderProps) {
<div className={styles['middle-errorMessage-wrapper']}>
<div className={styles['icon-layout']}>
<ExclamationCircle color={theme.color.dangerColor} size={62} />
<div aria-label="error-page">
<h1>{t('message.heading')}</h1>
<h4>{t('message.errorText')}</h4>
</div>
<h1>
{t('message.heading')}
<span>{t('message.errorText')}</span>
</h1>
</div>

<Link to="/" className="btn btn-secondary">
Expand Down
20 changes: 20 additions & 0 deletions src/stories/error-page/ErrorPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Meta, StoryObj } from '@storybook/react'
import { ErrorPage } from '@/sections/error-page/ErrorPage'
import { WithI18next } from '../WithI18next'

const meta: Meta<typeof ErrorPage> = {
title: 'Pages/ErrorPage',
component: ErrorPage,
decorators: [WithI18next],
parameters: {
// Sets the delay for all stories.
chromatic: { delay: 15000, pauseAnimationAtEnd: true }
}
}

export default meta
type Story = StoryObj<typeof ErrorPage>

export const Default: Story = {
render: () => <ErrorPage />
}
Loading