Add new story for darkmode (#317)
* Add a new story for dark mode * Reorganize storybook menu * Fix command menu margins * Fix tests
This commit is contained in:
@ -4,7 +4,6 @@ import { ThemeProvider } from '@emotion/react';
|
|||||||
import { withThemeFromJSXProvider } from "@storybook/addon-styling";
|
import { withThemeFromJSXProvider } from "@storybook/addon-styling";
|
||||||
import { lightTheme, darkTheme } from '../src/modules/ui/layout/styles/themes';
|
import { lightTheme, darkTheme } from '../src/modules/ui/layout/styles/themes';
|
||||||
|
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
const preview: Preview = {
|
const preview: Preview = {
|
||||||
|
|||||||
30
front/src/__stories__/App.darkMode.stories.tsx
Normal file
30
front/src/__stories__/App.darkMode.stories.tsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { Meta } from '@storybook/react';
|
||||||
|
|
||||||
|
import { App } from '~/App';
|
||||||
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
|
import { mockedUserJWT } from '~/testing/mock-data/jwt';
|
||||||
|
|
||||||
|
import { Story } from './App.stories';
|
||||||
|
import { renderWithDarkMode } from './shared';
|
||||||
|
|
||||||
|
const meta: Meta<typeof App> = {
|
||||||
|
title: 'App/App/DarkMode',
|
||||||
|
component: App,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
export const DarkMode: Story = {
|
||||||
|
render: () => renderWithDarkMode(true),
|
||||||
|
loaders: [
|
||||||
|
async () => ({
|
||||||
|
accessTokenStored: window.localStorage.setItem(
|
||||||
|
'accessToken',
|
||||||
|
mockedUserJWT,
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
parameters: {
|
||||||
|
msw: graphqlMocks,
|
||||||
|
},
|
||||||
|
};
|
||||||
11
front/src/__stories__/App.mdx
Normal file
11
front/src/__stories__/App.mdx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ /* App.mdx */ }
|
||||||
|
|
||||||
|
import { Canvas, Meta } from '@storybook/blocks';
|
||||||
|
|
||||||
|
import * as App from './App.stories';
|
||||||
|
|
||||||
|
<Meta of={App} />
|
||||||
|
|
||||||
|
# App View
|
||||||
|
|
||||||
|
<Canvas of={App.Default} />
|
||||||
@ -1,14 +1,10 @@
|
|||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
import { ApolloProvider } from '@apollo/client';
|
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { RecoilRoot } from 'recoil';
|
|
||||||
|
|
||||||
import { App } from '~/App';
|
import { App } from '~/App';
|
||||||
import { AuthProvider } from '~/providers/AuthProvider';
|
|
||||||
import { FullHeightStorybookLayout } from '~/testing/FullHeightStorybookLayout';
|
|
||||||
import { graphqlMocks } from '~/testing/graphqlMocks';
|
import { graphqlMocks } from '~/testing/graphqlMocks';
|
||||||
import { mockedUserJWT } from '~/testing/mock-data/jwt';
|
import { mockedUserJWT } from '~/testing/mock-data/jwt';
|
||||||
import { mockedClient } from '~/testing/mockedClient';
|
|
||||||
|
import { render } from './shared';
|
||||||
|
|
||||||
const meta: Meta<typeof App> = {
|
const meta: Meta<typeof App> = {
|
||||||
title: 'App/App',
|
title: 'App/App',
|
||||||
@ -16,21 +12,7 @@ const meta: Meta<typeof App> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof App>;
|
export type Story = StoryObj<typeof App>;
|
||||||
|
|
||||||
const render = () => (
|
|
||||||
<RecoilRoot>
|
|
||||||
<ApolloProvider client={mockedClient}>
|
|
||||||
<MemoryRouter>
|
|
||||||
<FullHeightStorybookLayout>
|
|
||||||
<AuthProvider>
|
|
||||||
<App />
|
|
||||||
</AuthProvider>
|
|
||||||
</FullHeightStorybookLayout>
|
|
||||||
</MemoryRouter>
|
|
||||||
</ApolloProvider>
|
|
||||||
</RecoilRoot>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render,
|
render,
|
||||||
|
|||||||
36
front/src/__stories__/shared.tsx
Normal file
36
front/src/__stories__/shared.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import { ApolloProvider } from '@apollo/client';
|
||||||
|
import { ThemeProvider } from '@emotion/react';
|
||||||
|
import { RecoilRoot } from 'recoil';
|
||||||
|
|
||||||
|
import { darkTheme } from '@/ui/layout/styles/themes';
|
||||||
|
import { App } from '~/App';
|
||||||
|
import { AuthProvider } from '~/providers/AuthProvider';
|
||||||
|
import { FullHeightStorybookLayout } from '~/testing/FullHeightStorybookLayout';
|
||||||
|
import { mockedClient } from '~/testing/mockedClient';
|
||||||
|
|
||||||
|
export const render = () => renderWithDarkMode(false);
|
||||||
|
|
||||||
|
export const renderWithDarkMode = (forceDarkMode?: boolean) => {
|
||||||
|
const AppInStoryBook = (
|
||||||
|
<FullHeightStorybookLayout>
|
||||||
|
<AuthProvider>
|
||||||
|
<App />
|
||||||
|
</AuthProvider>
|
||||||
|
</FullHeightStorybookLayout>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RecoilRoot>
|
||||||
|
<ApolloProvider client={mockedClient}>
|
||||||
|
<MemoryRouter>
|
||||||
|
{forceDarkMode ? (
|
||||||
|
<ThemeProvider theme={darkTheme}>{AppInStoryBook}</ThemeProvider>
|
||||||
|
) : (
|
||||||
|
AppInStoryBook
|
||||||
|
)}
|
||||||
|
</MemoryRouter>
|
||||||
|
</ApolloProvider>
|
||||||
|
</RecoilRoot>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -7,7 +7,7 @@ import { CellCommentChip } from '../CellCommentChip';
|
|||||||
import { CommentChip } from '../CommentChip';
|
import { CommentChip } from '../CommentChip';
|
||||||
|
|
||||||
const meta: Meta<typeof CellCommentChip> = {
|
const meta: Meta<typeof CellCommentChip> = {
|
||||||
title: 'Comments/CellCommentChip',
|
title: 'Modules/Comments/CellCommentChip',
|
||||||
component: CellCommentChip,
|
component: CellCommentChip,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { getRenderWrapperForComponent } from '~/testing/renderWrappers';
|
|||||||
import { CommentHeader } from '../CommentHeader';
|
import { CommentHeader } from '../CommentHeader';
|
||||||
|
|
||||||
const meta: Meta<typeof CommentHeader> = {
|
const meta: Meta<typeof CommentHeader> = {
|
||||||
title: 'Comments/CommentHeader',
|
title: 'Modules/Comments/CommentHeader',
|
||||||
component: CommentHeader,
|
component: CommentHeader,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { getRenderWrapperForComponent } from '~/testing/renderWrappers';
|
|||||||
import { CommentThreadRelationPicker } from '../CommentThreadRelationPicker';
|
import { CommentThreadRelationPicker } from '../CommentThreadRelationPicker';
|
||||||
|
|
||||||
const meta: Meta<typeof CommentThreadRelationPicker> = {
|
const meta: Meta<typeof CommentThreadRelationPicker> = {
|
||||||
title: 'Comments/CommentThreadRelationPicker',
|
title: 'Modules/Comments/CommentThreadRelationPicker',
|
||||||
component: CommentThreadRelationPicker,
|
component: CommentThreadRelationPicker,
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
@ -10,7 +10,6 @@ export const StyledDialog = styled(Command.Dialog)`
|
|||||||
max-width: 640px;
|
max-width: 640px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
padding: 25px;
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { getRenderWrapperForPage } from '~/testing/renderWrappers';
|
|||||||
import { CommandMenu } from '../CommandMenu';
|
import { CommandMenu } from '../CommandMenu';
|
||||||
|
|
||||||
const meta: Meta<typeof CommandMenu> = {
|
const meta: Meta<typeof CommandMenu> = {
|
||||||
title: 'Pages/Search/CommandMenu',
|
title: 'Modules/Search/CommandMenu',
|
||||||
component: CommandMenu,
|
component: CommandMenu,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { DropdownMenuSelectableItem } from '../DropdownMenuSelectableItem';
|
|||||||
import { DropdownMenuSeparator } from '../DropdownMenuSeparator';
|
import { DropdownMenuSeparator } from '../DropdownMenuSeparator';
|
||||||
|
|
||||||
const meta: Meta<typeof DropdownMenu> = {
|
const meta: Meta<typeof DropdownMenu> = {
|
||||||
title: 'Components/DropdownMenu',
|
title: 'UI/Menu/DropdownMenu',
|
||||||
component: DropdownMenu,
|
component: DropdownMenu,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
import { atom } from 'recoil';
|
|
||||||
|
|
||||||
export const isThemeEnabledState = atom<boolean>({
|
|
||||||
key: 'isThemeEnabledState',
|
|
||||||
default: true,
|
|
||||||
});
|
|
||||||
@ -5,7 +5,7 @@ import { getRenderWrapperForComponent } from '~/testing/renderWrappers';
|
|||||||
import { Avatar } from '../Avatar';
|
import { Avatar } from '../Avatar';
|
||||||
|
|
||||||
const meta: Meta<typeof Avatar> = {
|
const meta: Meta<typeof Avatar> = {
|
||||||
title: 'Components/Common/Avatar',
|
title: 'Modules/Users/Avatar',
|
||||||
component: Avatar,
|
component: Avatar,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { SettingsProfile } from '../SettingsProfile';
|
|||||||
import { render } from './shared';
|
import { render } from './shared';
|
||||||
|
|
||||||
const meta: Meta<typeof SettingsProfile> = {
|
const meta: Meta<typeof SettingsProfile> = {
|
||||||
title: 'Pages/SettingsProfile',
|
title: 'Pages/Settings/SettingsProfile',
|
||||||
component: SettingsProfile,
|
component: SettingsProfile,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user