Skip to content
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
18 changes: 14 additions & 4 deletions packages/strapi-design-system/.storybook/components/Theme.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useDarkMode } from 'storybook-dark-mode';
import { parse } from 'qs';
import { ThemeProvider } from '../../src/ThemeProvider';
import { Box } from '../../src/Box';
import { lightTheme } from '../../src/themes/lightTheme';
import { darkTheme } from '../../src/themes/darkTheme';
import { useThemeType } from '../hooks/useThemeType';

const themeQueryURL = parse(document.location.search).theme;

const Theme = ({ children }) => {
const themeType = useThemeType();
const isDarkAddon = useDarkMode();
const [isDark, setIsDark] = useState(themeQueryURL || isDarkAddon);

useEffect(() => {
if(!themeQueryURL && isDarkAddon !== isDark) {
setIsDark(isDarkAddon);
}
}, [isDarkAddon, isDark]);

return (
<ThemeProvider theme={themeType === 'dark' ? darkTheme : lightTheme}>
<ThemeProvider theme={isDark ? darkTheme : lightTheme}>
<Box padding={2} background='neutral0'>{children}</Box>
</ThemeProvider>
)
Expand Down
26 changes: 0 additions & 26 deletions packages/strapi-design-system/.storybook/hooks/useThemeType.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/strapi-design-system/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
darkMode: {
// Override the default dark theme
current: 'light',
dark: createCustomTheme({ theme: darkTheme, asStorybookTheme: false }),
// Override the default light theme
light: createCustomTheme({ theme: lightTheme, asStorybookTheme: false }),
Expand Down
54 changes: 40 additions & 14 deletions packages/strapi-design-system/src/Accordion/Accordion.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AccordionContent } from './AccordionContent';
import { AccordionGroup } from './AccordionGroup';
import { Box } from '../Box';
import { Flex } from '../Flex';
import { Text } from '../Typography';
import { Typography } from '../Typography';
import { IconButton } from '../IconButton';
import { TextButton } from '../TextButton';
import { Stack } from '../Stack';
Expand Down Expand Up @@ -63,7 +63,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
>
<AccordionToggle title="User informations" />
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -75,7 +77,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
action={<IconButton onClick={() => console.log('edit')} label="Edit" icon={<Pencil />} />}
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -87,7 +91,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
description="The following contains information about the current user 3"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -99,7 +105,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
action={<IconButton onClick={() => console.log('edit')} label="Edit" icon={<Pencil />} />}
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand Down Expand Up @@ -162,7 +170,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
togglePosition="left"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
<Accordion
Expand All @@ -174,13 +184,17 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
>
<AccordionToggle title="User informations" togglePosition="left" />
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
<Accordion expanded={expanded} onToggle={() => setExpanded((s) => !s)} id="acc-3" size="S">
<AccordionToggle title="User informations" togglePosition="left" />
<AccordionContent>
<Box padding={3}>My name is Michka</Box>
<Box padding={3}>
<Typography>My name is Michka</Typography>
</Box>
</AccordionContent>
</Accordion>
<Accordion expanded={false} onToggle={() => setExpanded((s) => !s)} id="acc-2" size="S">
Expand All @@ -190,7 +204,9 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
togglePosition="left"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</AccordionGroup>
Expand All @@ -217,7 +233,9 @@ The accordion component has two main states: collapsed and expanded. By default
description="The following contains information about the current user"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -229,7 +247,9 @@ The accordion component has two main states: collapsed and expanded. By default
description="The following contains information about the current user 2"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -241,7 +261,9 @@ The accordion component has two main states: collapsed and expanded. By default
description="The following contains information about the current user 3"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -254,7 +276,9 @@ The accordion component has two main states: collapsed and expanded. By default
action={<IconButton onClick={() => console.log('edit')} label="Edit" icon={<Pencil />} />}
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Box>
Expand All @@ -276,7 +300,9 @@ The Accordion component can also be open by default using the parameter `expande
description="The following contains information about the current user"
/>
<AccordionContent>
<Box padding={3}>My name is John Duff</Box>
<Box padding={3}>
<Typography>My name is John Duff</Typography>
</Box>
</AccordionContent>
</Accordion>
</Story>
Expand Down
14 changes: 14 additions & 0 deletions packages/strapi-design-system/test-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ window.IntersectionObserver = () => ({
disconnect: () => {},
});

window.matchMedia = () => ({
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

const realConsoleError = console.error.bind(console);
console.error = (msg) => {
// This errors pops when we try to test portals with testing-library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,12 @@ exports[`Storyshots Design System/Components/Accordion expanded 1`] = `
line-height: 1.43;
}

.c22 {
color: #32324d;
font-size: 0.875rem;
line-height: 1.43;
}

.c7 {
display: -webkit-box;
display: -webkit-flex;
Expand Down Expand Up @@ -1990,7 +1996,11 @@ exports[`Storyshots Design System/Components/Accordion expanded 1`] = `
<div
class="c21"
>
My name is John Duff
<span
class="c22"
>
My name is John Duff
</span>
</div>
</div>
</div>
Expand Down