Skip to content

Commit 7d765d7

Browse files
author
Lucas
authored
[LW 9606] Add dark mode to stories (#1122)
* feat: add dark mode to stories * feat: add missing core storybook theme styles
1 parent 5302962 commit 7d765d7

File tree

33 files changed

+324
-88
lines changed

33 files changed

+324
-88
lines changed

packages/core/.storybook/index.scss

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@import './theme.scss';
2+
3+
:global(.ant-radio:hover .ant-radio-inner) {
4+
border-color: var(--light-mode-dark-grey, var(--dark-mode-light-grey)) !important;
5+
background: var(--color-white, var(--dark-mode-grey));
6+
}
7+
:global(.ant-tooltip) {
8+
color: var(--light-mode-dark-grey, var(--dark-mode-light-grey)) !important;
9+
font-weight: 400 !important;
10+
font-size: var(--bodySmall) !important;
11+
}
12+
:global(.ant-tooltip-inner) {
13+
background-color: var(--dark-mode-mid-grey, #ffffff) !important;
14+
border-radius: 11px !important;
15+
color: var(--dark-mode-light-grey, --light-mode-dark-grey) !important;
16+
padding: size_unit(1) size_unit(2) !important;
17+
}
18+
:global(.ant-tooltip-arrow-content) {
19+
background-color: var(--dark-mode-mid-grey, #ffffff) !important;
20+
}
21+
22+
:global(.ant-tooltip-arrow-content:before) {
23+
background: var(--dark-mode-mid-grey, #ffffff) !important;
24+
}
25+
26+
:global(.ant-modal-mask) {
27+
background: var(--light-mode-black, var(--dark-mode-bg-black)) !important;
28+
opacity: 0.9;
29+
}
30+
31+
:global(.ant-drawer.ant-drawer-open .ant-drawer-mask) {
32+
animation: none;
33+
}
34+
35+
:global(.ant-drawer) {
36+
transition: none;
37+
}
38+
39+
:global {
40+
.ant-checkbox-checked .ant-checkbox-inner {
41+
background-color: var(--primary-default) !important;
42+
border-color: var(--primary-default) !important;
43+
}
44+
}
45+
46+
body {
47+
background-color: var(--bg-color-body, #ffffff) !important;
48+
color: var(--text-color-primary, #3d3b39);
49+
}

packages/core/.storybook/preview.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
2-
import { ThemeColorScheme, ThemeProvider } from '@lace/ui';
2+
import { ThemeColorScheme, ThemeProvider, colorSchemaDecorator } from '@lace/ui';
33
import 'antd/dist/antd.css';
44
import 'normalize.css';
5-
import './theme.scss';
5+
import './index.scss';
66

77
export const preview = {
88
actions: { argTypesRegex: '^on[A-Z].*' },
@@ -19,9 +19,16 @@ export const preview = {
1919
};
2020

2121
export const decorators = [
22-
(Story) => (
23-
<ThemeProvider colorScheme={ThemeColorScheme.Light}>
24-
<Story />
25-
</ThemeProvider>
26-
)
22+
(Story, args) => {
23+
const { decorators: { colorSchema = true } = {} } = args.parameters;
24+
return colorSchema ? colorSchemaDecorator(Story, args) : <Story />;
25+
},
26+
(Story, args) => {
27+
const { decorators: { theme } = {} } = args.parameters;
28+
return (
29+
<ThemeProvider colorScheme={theme ?? ThemeColorScheme.Light}>
30+
<Story />
31+
</ThemeProvider>
32+
);
33+
}
2734
];

packages/core/.storybook/theme.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
/*
77
in case the theme provider is not being used, this media query allows us to use the theme set on the user system
88
*/
9-
@media (prefers-color-scheme: dark) {
9+
@media (prefers-color-scheme: dark) and (data-theme: dark) {
1010
:root {
1111
@include theme-custom-properties($dark-theme);
1212
}
1313
}
1414

15-
html[data-theme='dark'] {
15+
html[data-theme='dark'],
16+
div[data-theme='dark'] {
1617
@include theme-custom-properties($dark-theme);
1718
}
1819
}
@@ -21,13 +22,14 @@
2122
/*
2223
in case the theme provider is not being used, this media query allows us to use the theme set on the user system
2324
*/
24-
@media (prefers-color-scheme: light) {
25+
@media (prefers-color-scheme: light) and (data-theme: light) {
2526
:root {
2627
@include theme-custom-properties($light-theme);
2728
}
2829
}
2930

30-
html[data-theme='light'] {
31+
html[data-theme='light'],
32+
div[data-theme='light'] {
3133
@include theme-custom-properties($light-theme);
3234
}
3335
}

packages/core/src/ui/components/Account/DisableAccountConfirmation/DisableAccountConfirmation.stories.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
22

33
import { DisableAccountConfirmation } from './DisableAccountConfirmation';
44
import { ComponentProps } from 'react';
5+
import { ThemeColorScheme } from '@lace/ui';
56

67
const meta: Meta<typeof DisableAccountConfirmation> = {
78
title: 'Accounts/DisableAccountConfirmation',
@@ -29,5 +30,22 @@ const data: ComponentProps<typeof DisableAccountConfirmation> = {
2930
export const Overview: Story = {
3031
args: {
3132
...data
33+
},
34+
parameters: {
35+
decorators: {
36+
colorSchema: false
37+
}
38+
}
39+
};
40+
41+
export const WithDarkMode: Story = {
42+
args: {
43+
...data
44+
},
45+
parameters: {
46+
decorators: {
47+
colorSchema: false,
48+
theme: ThemeColorScheme.Dark
49+
}
3250
}
3351
};

packages/core/src/ui/components/Account/EditAccount/EditAccountDrawer.stories.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
22

33
import { EditAccountDrawer } from './EditAccountDrawer';
44
import { ComponentProps } from 'react';
5+
import { ThemeColorScheme } from '@lace/ui';
56

67
const meta: Meta<typeof EditAccountDrawer> = {
78
title: 'Accounts/EditAccountDrawer',
@@ -31,5 +32,22 @@ const data: ComponentProps<typeof EditAccountDrawer> = {
3132
export const Overview: Story = {
3233
args: {
3334
...data
35+
},
36+
parameters: {
37+
decorators: {
38+
colorSchema: false
39+
}
40+
}
41+
};
42+
43+
export const WithDarkMode: Story = {
44+
args: {
45+
...data
46+
},
47+
parameters: {
48+
decorators: {
49+
colorSchema: false,
50+
theme: ThemeColorScheme.Dark
51+
}
3452
}
3553
};

packages/core/src/ui/components/Account/EnableAccountConfirmWithHW/EnableAccountConfirmWithHW.stories.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentProps } from 'react';
22
import type { Meta, StoryObj } from '@storybook/react';
33

44
import { EnableAccountConfirmWithHW } from './EnableAccountConfirmWithHW';
5+
import { ThemeColorScheme } from '@lace/ui';
56

67
const meta: Meta<typeof EnableAccountConfirmWithHW> = {
78
title: 'Accounts/EnableAccountConfirmWithHW',
@@ -37,19 +38,44 @@ const data: ComponentProps<typeof EnableAccountConfirmWithHW> = {
3738
};
3839

3940
export const Waiting: Story = {
40-
args: data
41+
args: data,
42+
parameters: {
43+
decorators: {
44+
colorSchema: false
45+
}
46+
}
4147
};
4248

4349
export const Signing: Story = {
4450
args: {
4551
...data,
4652
state: 'signing'
53+
},
54+
parameters: {
55+
decorators: {
56+
colorSchema: false
57+
}
4758
}
4859
};
4960

5061
export const ErrorCase: Story = {
5162
args: {
5263
...data,
5364
state: 'error'
65+
},
66+
parameters: {
67+
decorators: {
68+
colorSchema: false
69+
}
70+
}
71+
};
72+
73+
export const WithDarkMode: Story = {
74+
args: data,
75+
parameters: {
76+
decorators: {
77+
colorSchema: false,
78+
theme: ThemeColorScheme.Dark
79+
}
5480
}
5581
};

packages/core/src/ui/components/Account/EnableAccountPasswordPrompt/EnableAccountPasswordPrompt.stories.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
22

33
import { EnableAccountPasswordPrompt } from './EnableAccountPasswordPrompt';
44
import { ComponentProps } from 'react';
5+
import { ThemeColorScheme } from '@lace/ui';
56

67
const meta: Meta<typeof EnableAccountPasswordPrompt> = {
78
title: 'Accounts/EnableAccountPasswordPrompt',
@@ -34,19 +35,46 @@ const data: ComponentProps<typeof EnableAccountPasswordPrompt> = {
3435
export const Overview: Story = {
3536
args: {
3637
...data
38+
},
39+
parameters: {
40+
decorators: {
41+
colorSchema: false
42+
}
3743
}
3844
};
3945

4046
export const PopUp: Story = {
4147
args: {
4248
...data,
4349
isPopup: true
50+
},
51+
parameters: {
52+
decorators: {
53+
colorSchema: false
54+
}
4455
}
4556
};
4657

4758
export const IncorrectPassword: Story = {
4859
args: {
4960
...data,
5061
wasPasswordIncorrect: true
62+
},
63+
parameters: {
64+
decorators: {
65+
colorSchema: false
66+
}
67+
}
68+
};
69+
70+
export const WithDarkMode: Story = {
71+
args: {
72+
...data
73+
},
74+
parameters: {
75+
decorators: {
76+
colorSchema: false,
77+
theme: ThemeColorScheme.Dark
78+
}
5179
}
5280
};

packages/core/src/ui/components/ConfirmDRepRegistration/ConfirmDRepRegistration.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const customViewports = {
77
popup: {
88
name: 'Popup',
99
styles: {
10-
width: '360px',
10+
width: '720px',
1111
height: '600'
1212
}
1313
}

packages/core/src/ui/components/ConfirmDRepRetirement/ConfirmDRepRetirement.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const customViewports = {
77
popup: {
88
name: 'Popup',
99
styles: {
10-
width: '360px',
10+
width: '720px',
1111
height: '600'
1212
}
1313
}

packages/core/src/ui/components/ConfirmDRepUpdate/ConfirmDRepUpdate.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const customViewports = {
77
popup: {
88
name: 'Popup',
99
styles: {
10-
width: '360px',
10+
width: '720px',
1111
height: '600'
1212
}
1313
}

0 commit comments

Comments
 (0)