braid-design-system 31.0.0 → 31.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/CHANGELOG.md +58 -0
- package/color-mode/index.ts +9 -0
- package/css/atoms.docs.tsx +26 -20
- package/css/colorModeStyle.docs.tsx +81 -0
- package/css/index.ts +5 -1
- package/lib/components/Alert/Alert.css.ts +19 -0
- package/lib/components/Alert/Alert.docs.tsx +17 -5
- package/lib/components/Alert/Alert.tsx +61 -30
- package/lib/components/Badge/Badge.tsx +11 -31
- package/lib/components/Box/BackgroundContext.tsx +34 -17
- package/lib/components/Box/Box.docs.tsx +34 -14
- package/lib/components/Box/Box.playroom.tsx +37 -0
- package/lib/components/Box/Box.tsx +38 -7
- package/lib/components/Box/BoxRenderer.tsx +28 -9
- package/lib/components/Box/ColoredBox.tsx +168 -13
- package/lib/components/BraidPortal/BraidPortal.tsx +4 -1
- package/lib/components/BraidProvider/BraidProvider.tsx +11 -3
- package/lib/components/BraidProvider/VanillaThemeContainer.tsx +24 -0
- package/lib/components/Button/Button.css.ts +38 -5
- package/lib/components/Button/Button.screenshots.tsx +4 -1
- package/lib/components/Button/Button.tsx +102 -70
- package/lib/components/Card/Card.tsx +2 -13
- package/lib/components/Checkbox/Checkbox.screenshots.tsx +17 -8
- package/lib/components/Divider/Divider.css.ts +45 -4
- package/lib/components/Divider/Divider.tsx +20 -14
- package/lib/components/Dropdown/Dropdown.docs.tsx +0 -1
- package/lib/components/FieldLabel/FieldLabel.docs.tsx +1 -1
- package/lib/components/FieldMessage/FieldMessage.screenshots.tsx +6 -0
- package/lib/components/Heading/Heading.docs.tsx +6 -4
- package/lib/components/Heading/Heading.screenshots.tsx +4 -1
- package/lib/components/Loader/Loader.css.ts +3 -4
- package/lib/components/Loader/Loader.screenshots.tsx +4 -1
- package/lib/components/Loader/Loader.tsx +27 -30
- package/lib/components/MenuItem/MenuItemLink.tsx +9 -2
- package/lib/components/MenuItem/useMenuItem.tsx +4 -4
- package/lib/components/MenuItemCheckbox/MenuItemCheckbox.tsx +3 -1
- package/lib/components/MenuRenderer/testHelper.tsx +5 -2
- package/lib/components/Pagination/Pagination.css.ts +17 -3
- package/lib/components/Pagination/Pagination.tsx +6 -5
- package/lib/components/Rating/Rating.css.ts +16 -3
- package/lib/components/Rating/Rating.screenshots.tsx +4 -1
- package/lib/components/Rating/Rating.tsx +6 -1
- package/lib/components/Tabs/Tab.tsx +6 -2
- package/lib/components/Tabs/Tabs.css.ts +9 -1
- package/lib/components/Tabs/Tabs.tsx +4 -1
- package/lib/components/Text/Text.docs.tsx +4 -0
- package/lib/components/Text/Text.screenshots.tsx +8 -1
- package/lib/components/TextField/TextField.docs.tsx +0 -1
- package/lib/components/TextLink/TextLink.css.ts +139 -0
- package/lib/components/TextLink/TextLink.docs.tsx +1 -1
- package/lib/components/TextLink/TextLink.screenshots.tsx +3 -1
- package/lib/components/TextLink/TextLink.tsx +45 -37
- package/lib/components/Textarea/Highlight/Highlight.tsx +1 -1
- package/lib/components/Textarea/Textarea.docs.tsx +0 -1
- package/lib/components/Toggle/Toggle.css.ts +34 -7
- package/lib/components/Toggle/Toggle.tsx +8 -3
- package/lib/components/iconButtons/IconButton.css.ts +0 -32
- package/lib/components/iconButtons/IconButton.tsx +26 -48
- package/lib/components/icons/IconTip/IconTip.docs.tsx +20 -0
- package/lib/components/icons/IconTip/IconTip.tsx +12 -0
- package/lib/components/icons/IconTip/IconTipSvg.tsx +21 -0
- package/lib/components/icons/IconZoomIn/IconZoomIn.docs.tsx +20 -0
- package/lib/components/icons/IconZoomIn/IconZoomIn.tsx +12 -0
- package/lib/components/icons/IconZoomIn/IconZoomInSvg.tsx +20 -0
- package/lib/components/icons/IconZoomOut/IconZoomOut.docs.tsx +20 -0
- package/lib/components/icons/IconZoomOut/IconZoomOut.tsx +12 -0
- package/lib/components/icons/IconZoomOut/IconZoomOutSvg.tsx +20 -0
- package/lib/components/icons/Icons.screenshots.tsx +2 -2
- package/lib/components/icons/index.ts +3 -0
- package/lib/components/index.ts +3 -1
- package/lib/components/private/Field/Field.css.ts +2 -1
- package/lib/components/private/Field/Field.tsx +4 -6
- package/lib/components/private/InlineField/InlineField.css.ts +6 -6
- package/lib/components/private/InlineField/StyledInput.tsx +14 -9
- package/lib/components/private/Keyline/Keyline.css.ts +70 -0
- package/lib/components/private/Keyline/Keyline.tsx +38 -0
- package/lib/components/private/Placeholder/Placeholder.css.ts +44 -12
- package/lib/components/private/Placeholder/Placeholder.tsx +7 -3
- package/lib/components/private/touchable/debugTouchable.ts +7 -7
- package/lib/components/private/touchable/virtualTouchable.css.ts +12 -12
- package/lib/components/useToast/Toast.tsx +2 -8
- package/lib/css/atoms/atomicProperties.ts +7 -2
- package/lib/css/atoms/sprinkles.css.ts +24 -0
- package/lib/css/colorModeStyle.ts +33 -0
- package/lib/css/reset/reset.css.ts +12 -8
- package/lib/hooks/typography/index.ts +8 -61
- package/lib/hooks/typography/typography.css.ts +95 -93
- package/lib/hooks/useIcon/index.ts +4 -2
- package/lib/playroom/FrameComponent.tsx +50 -17
- package/lib/playroom/components.ts +1 -0
- package/lib/playroom/useScope.ts +44 -1
- package/lib/stories/all.stories.tsx +61 -30
- package/lib/themes/baseTokens/apac.ts +8 -0
- package/lib/themes/catho/tokens.ts +23 -6
- package/lib/themes/docs/tokens.ts +8 -0
- package/lib/themes/makeBraidTheme.ts +4 -1
- package/lib/themes/occ/tokens.ts +25 -5
- package/lib/themes/seekAnz/tokens.ts +25 -5
- package/lib/themes/tokenType.ts +8 -0
- package/lib/themes/wireframe/tokens.ts +22 -5
- package/package.json +2 -2
- package/sku.config.js +1 -0
- package/sku.routes.js +2 -0
- package/tsconfig.json +1 -0
- package/lib/components/Card/Card.css.ts +0 -6
|
@@ -11,6 +11,8 @@ import { vars } from '../../themes/vars.css';
|
|
|
11
11
|
import { breakpointQuery, responsiveStyle } from '../../css/responsiveStyle';
|
|
12
12
|
|
|
13
13
|
import { mapToProperty } from '../../utils';
|
|
14
|
+
import { colorModeStyle } from '../../css/colorModeStyle';
|
|
15
|
+
import { BoxBackgroundVariant } from '../../components/Box/Box';
|
|
14
16
|
|
|
15
17
|
type Vars = typeof vars;
|
|
16
18
|
type TextDefinition = Vars['textSize'];
|
|
@@ -96,115 +98,115 @@ export const heading = {
|
|
|
96
98
|
'4': makeTypographyRules(vars.headingLevel['4'], 'heading4'),
|
|
97
99
|
};
|
|
98
100
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
const textToneVars = createThemeContract({
|
|
102
|
+
critical: null,
|
|
103
|
+
caution: null,
|
|
104
|
+
info: null,
|
|
105
|
+
promote: null,
|
|
106
|
+
positive: null,
|
|
107
|
+
brandAccent: null,
|
|
108
|
+
formAccent: null,
|
|
109
|
+
neutral: null,
|
|
110
|
+
secondary: null,
|
|
111
|
+
link: null,
|
|
105
112
|
});
|
|
106
113
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
const lightContextToneVars = assignVars(textToneVars, {
|
|
115
|
+
critical: vars.foregroundColor.critical,
|
|
116
|
+
caution: vars.foregroundColor.caution,
|
|
117
|
+
info: vars.foregroundColor.info,
|
|
118
|
+
promote: vars.foregroundColor.promote,
|
|
119
|
+
positive: vars.foregroundColor.positive,
|
|
120
|
+
brandAccent: vars.foregroundColor.brandAccent,
|
|
121
|
+
formAccent: vars.foregroundColor.formAccent,
|
|
122
|
+
neutral: vars.foregroundColor.neutral,
|
|
123
|
+
secondary: vars.foregroundColor.secondary,
|
|
124
|
+
link: vars.foregroundColor.link,
|
|
113
125
|
});
|
|
114
126
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
const darkContextToneVars = assignVars(textToneVars, {
|
|
128
|
+
critical: vars.foregroundColor.criticalLight,
|
|
129
|
+
caution: vars.foregroundColor.cautionLight,
|
|
130
|
+
info: vars.foregroundColor.infoLight,
|
|
131
|
+
promote: vars.foregroundColor.promoteLight,
|
|
132
|
+
positive: vars.foregroundColor.positiveLight,
|
|
133
|
+
brandAccent: vars.foregroundColor.brandAccentLight,
|
|
134
|
+
formAccent: vars.foregroundColor.formAccentLight,
|
|
135
|
+
neutral: vars.foregroundColor.neutralInverted,
|
|
136
|
+
secondary: vars.foregroundColor.secondaryInverted,
|
|
137
|
+
link: vars.foregroundColor.linkLight,
|
|
121
138
|
});
|
|
122
139
|
|
|
123
|
-
export const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
':hover': {
|
|
128
|
-
color: textLinkVars.colorHover,
|
|
129
|
-
textDecoration: textLinkVars.textDecorationHover,
|
|
130
|
-
},
|
|
131
|
-
':focus': {
|
|
132
|
-
color: textLinkVars.colorHover,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
export const regularLink = style({
|
|
137
|
-
vars: regularLinkVars,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
export const weakLink = style({
|
|
141
|
-
vars: weakLinkVars,
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
export const textLinkVisited = style({
|
|
145
|
-
':visited': {
|
|
146
|
-
color: vars.foregroundColor.linkVisited,
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
export const tone = styleVariants(
|
|
151
|
-
{
|
|
152
|
-
brandAccent: vars.foregroundColor.brandAccent,
|
|
153
|
-
caution: vars.foregroundColor.caution,
|
|
154
|
-
critical: vars.foregroundColor.critical,
|
|
155
|
-
formAccent: vars.foregroundColor.formAccent,
|
|
156
|
-
info: vars.foregroundColor.info,
|
|
157
|
-
positive: vars.foregroundColor.positive,
|
|
158
|
-
promote: vars.foregroundColor.promote,
|
|
159
|
-
secondary: vars.foregroundColor.secondary,
|
|
160
|
-
link: vars.foregroundColor.link,
|
|
161
|
-
},
|
|
162
|
-
mapToProperty('color'),
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
export const invertableTone = {
|
|
166
|
-
neutral: styleVariants({
|
|
167
|
-
light: {
|
|
168
|
-
color: vars.foregroundColor.neutral,
|
|
169
|
-
},
|
|
170
|
-
dark: {
|
|
171
|
-
color: vars.foregroundColor.neutralInverted,
|
|
140
|
+
export const lightModeTone = styleVariants({
|
|
141
|
+
light: colorModeStyle({
|
|
142
|
+
lightMode: {
|
|
143
|
+
vars: lightContextToneVars,
|
|
172
144
|
},
|
|
173
145
|
}),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
},
|
|
178
|
-
dark: {
|
|
179
|
-
color: vars.foregroundColor.secondaryInverted,
|
|
180
|
-
},
|
|
181
|
-
}),
|
|
182
|
-
brandAccent: styleVariants({
|
|
183
|
-
light: {
|
|
184
|
-
color: vars.foregroundColor.brandAccent,
|
|
185
|
-
},
|
|
186
|
-
dark: {
|
|
187
|
-
color: vars.foregroundColor.brandAccentLight,
|
|
146
|
+
dark: colorModeStyle({
|
|
147
|
+
lightMode: {
|
|
148
|
+
vars: darkContextToneVars,
|
|
188
149
|
},
|
|
189
150
|
}),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export const darkModeTone = styleVariants({
|
|
154
|
+
light: colorModeStyle({
|
|
155
|
+
darkMode: {
|
|
156
|
+
vars: lightContextToneVars,
|
|
196
157
|
},
|
|
197
158
|
}),
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
},
|
|
202
|
-
dark: {
|
|
203
|
-
color: vars.foregroundColor.criticalLight,
|
|
159
|
+
dark: colorModeStyle({
|
|
160
|
+
darkMode: {
|
|
161
|
+
vars: darkContextToneVars,
|
|
204
162
|
},
|
|
205
163
|
}),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const neutralOverrideForBackground: Partial<
|
|
167
|
+
Record<BoxBackgroundVariant, keyof typeof textToneVars>
|
|
168
|
+
> = {
|
|
169
|
+
criticalLight: 'critical',
|
|
170
|
+
criticalSoft: 'critical',
|
|
171
|
+
criticalSoftActive: 'critical',
|
|
172
|
+
criticalSoftHover: 'critical',
|
|
173
|
+
caution: 'caution',
|
|
174
|
+
cautionLight: 'caution',
|
|
175
|
+
positiveLight: 'positive',
|
|
176
|
+
infoLight: 'info',
|
|
177
|
+
promoteLight: 'promote',
|
|
206
178
|
};
|
|
207
179
|
|
|
180
|
+
export const lightModeNeutralOverride = styleVariants(
|
|
181
|
+
neutralOverrideForBackground,
|
|
182
|
+
(textTone) =>
|
|
183
|
+
colorModeStyle({
|
|
184
|
+
lightMode: {
|
|
185
|
+
vars: {
|
|
186
|
+
[textToneVars.neutral]:
|
|
187
|
+
textToneVars[textTone as keyof typeof textToneVars],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
export const darkModeNeutralOverride = styleVariants(
|
|
194
|
+
neutralOverrideForBackground,
|
|
195
|
+
(textTone) =>
|
|
196
|
+
colorModeStyle({
|
|
197
|
+
darkMode: {
|
|
198
|
+
vars: {
|
|
199
|
+
[textToneVars.neutral]:
|
|
200
|
+
textToneVars[textTone as keyof typeof textToneVars],
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
export const tone = styleVariants(textToneVars, (toneVar) => ({
|
|
207
|
+
color: toneVar,
|
|
208
|
+
}));
|
|
209
|
+
|
|
208
210
|
const makeTouchableSpacing = (touchableHeight: string, textHeight: string) => {
|
|
209
211
|
const space = calc(touchableHeight).subtract(textHeight).divide(2).toString();
|
|
210
212
|
|
|
@@ -3,7 +3,7 @@ import assert from 'assert';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
|
|
5
5
|
import { OptionalTitle } from '../../components/icons/SVGTypes';
|
|
6
|
-
import {
|
|
6
|
+
import { PublicBoxProps } from '../../components/Box/Box';
|
|
7
7
|
import { TextContext } from '../../components/Text/TextContext';
|
|
8
8
|
import HeadingContext from '../../components/Heading/HeadingContext';
|
|
9
9
|
import { textSize, useTextTone, UseTextProps } from '../typography';
|
|
@@ -50,7 +50,9 @@ const detaultVerticalCorrection = {
|
|
|
50
50
|
export default (
|
|
51
51
|
{ size, tone, alignY, data, ...titleProps }: UseIconProps,
|
|
52
52
|
{ verticalCorrection = detaultVerticalCorrection }: PrivateIconProps = {},
|
|
53
|
-
|
|
53
|
+
// TODO: COLORMODE RELEASE
|
|
54
|
+
// Revert to BoxProps
|
|
55
|
+
): PublicBoxProps => {
|
|
54
56
|
const textContext = useContext(TextContext);
|
|
55
57
|
const headingContext = useContext(HeadingContext);
|
|
56
58
|
const inheritedTone =
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../../reset';
|
|
2
|
-
import React, { Fragment, ReactNode } from 'react';
|
|
2
|
+
import React, { useEffect, Fragment, ReactNode } from 'react';
|
|
3
3
|
import {
|
|
4
4
|
BraidProvider,
|
|
5
5
|
makeLinkComponent,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '../components';
|
|
9
9
|
import { BraidTheme } from '../themes/BraidTheme';
|
|
10
10
|
import { PlayroomStateProvider } from './playroomState';
|
|
11
|
+
import { darkMode } from '../css/atoms/sprinkles.css';
|
|
11
12
|
|
|
12
13
|
interface Props {
|
|
13
14
|
theme: BraidTheme;
|
|
@@ -39,19 +40,51 @@ const ResponsiveReady = ({ children }: { children: ReactNode }) => {
|
|
|
39
40
|
return <>{responsiveReady ? children : null}</>;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
export default ({ theme, children }: Props) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
43
|
+
export default ({ theme, children }: Props) => {
|
|
44
|
+
// TODO: COLORMODE RELEASE
|
|
45
|
+
// Remove color mode toggle
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
let code = '';
|
|
48
|
+
const darkTrigger = 'braiddark';
|
|
49
|
+
const lightTrigger = 'braidlight';
|
|
50
|
+
const longestTrigger = Math.max(lightTrigger.length, darkTrigger.length);
|
|
51
|
+
const colorModeToggle = (ev: KeyboardEvent) => {
|
|
52
|
+
code += ev.key;
|
|
53
|
+
if (code.substr(code.length - darkTrigger.length) === darkTrigger) {
|
|
54
|
+
document.documentElement.classList.add(darkMode);
|
|
55
|
+
code = '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (code.substr(code.length - lightTrigger.length) === lightTrigger) {
|
|
59
|
+
document.documentElement.classList.remove(darkMode);
|
|
60
|
+
code = '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (code.length > longestTrigger) {
|
|
64
|
+
code = code.substr(code.length - longestTrigger);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener('keydown', colorModeToggle);
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener('keydown', colorModeToggle);
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Fragment>
|
|
76
|
+
<div
|
|
77
|
+
dangerouslySetInnerHTML={{
|
|
78
|
+
__html: theme.webFonts.map((font) => font.linkTag).join(''),
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
<PlayroomStateProvider>
|
|
82
|
+
<BraidProvider theme={theme} linkComponent={PlayroomLink}>
|
|
83
|
+
<ToastProvider>
|
|
84
|
+
<ResponsiveReady>{children}</ResponsiveReady>
|
|
85
|
+
</ToastProvider>
|
|
86
|
+
</BraidProvider>
|
|
87
|
+
</PlayroomStateProvider>
|
|
88
|
+
</Fragment>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
@@ -6,6 +6,7 @@ export { AccordionItem } from '../components/Accordion/AccordionItem.playroom';
|
|
|
6
6
|
export { Alert } from '../components/Alert/Alert.playroom';
|
|
7
7
|
export { Autosuggest } from '../components/Autosuggest/Autosuggest.playroom';
|
|
8
8
|
export { Badge } from '../components/Badge/Badge.playroom';
|
|
9
|
+
export { Box } from '../components/Box/Box.playroom';
|
|
9
10
|
export { Button } from '../components/Button/Button.playroom';
|
|
10
11
|
export { ButtonLink } from '../components/ButtonLink/ButtonLink.playroom';
|
|
11
12
|
export { Card } from '../components/Card/Card.playroom';
|
package/lib/playroom/useScope.ts
CHANGED
|
@@ -1,12 +1,54 @@
|
|
|
1
1
|
import '../../reset';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
2
3
|
import { useToast, useResponsiveValue } from '../components';
|
|
3
4
|
import { vars, atoms, breakpoints } from '../../css';
|
|
4
5
|
import { usePlayroomStore } from './playroomState';
|
|
5
|
-
import { RequiredResponsiveObject } from '../css/atoms/sprinkles.css';
|
|
6
|
+
import { darkMode, RequiredResponsiveObject } from '../css/atoms/sprinkles.css';
|
|
6
7
|
|
|
7
8
|
export default function useScope() {
|
|
8
9
|
const responsiveValue = useResponsiveValue();
|
|
9
10
|
|
|
11
|
+
// TODO: COLORMODE RELEASE
|
|
12
|
+
// Revisit when dark mode frames are first class
|
|
13
|
+
const [colorMode, setColorMode] = useState<'lightMode' | 'darkMode'>(
|
|
14
|
+
'lightMode',
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const observer = new MutationObserver((mutationsList) => {
|
|
19
|
+
for (const mutation of mutationsList) {
|
|
20
|
+
if (
|
|
21
|
+
mutation.type === 'attributes' &&
|
|
22
|
+
mutation.attributeName === 'class'
|
|
23
|
+
) {
|
|
24
|
+
setColorMode(
|
|
25
|
+
document.documentElement.classList.contains(darkMode)
|
|
26
|
+
? 'darkMode'
|
|
27
|
+
: 'lightMode',
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
observer.observe(document.documentElement, { attributes: true });
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
observer.disconnect();
|
|
37
|
+
};
|
|
38
|
+
}, [colorMode]);
|
|
39
|
+
|
|
40
|
+
function playroomColorModeValue(
|
|
41
|
+
value: Record<'lightMode' | 'darkMode', any>,
|
|
42
|
+
) {
|
|
43
|
+
if (typeof value !== 'object' || !(value.darkMode || value.lightMode)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return document.documentElement.classList.contains(darkMode)
|
|
48
|
+
? value.darkMode
|
|
49
|
+
: value.lightMode;
|
|
50
|
+
}
|
|
51
|
+
|
|
10
52
|
function playroomResponsiveValue<Value>(
|
|
11
53
|
value: RequiredResponsiveObject<Value>,
|
|
12
54
|
): Value {
|
|
@@ -36,6 +78,7 @@ export default function useScope() {
|
|
|
36
78
|
breakpoints,
|
|
37
79
|
showToast: useToast(),
|
|
38
80
|
responsiveValue: playroomResponsiveValue,
|
|
81
|
+
colorModeValue: playroomColorModeValue,
|
|
39
82
|
...usePlayroomStore(),
|
|
40
83
|
};
|
|
41
84
|
}
|
|
@@ -7,7 +7,11 @@ import * as themes from '../themes';
|
|
|
7
7
|
import { ComponentExample, ComponentScreenshot } from '../../site/src/types';
|
|
8
8
|
import { PlayroomStateProvider } from '../playroom/playroomState';
|
|
9
9
|
import { useSourceFromExample } from '../utils/useSourceFromExample';
|
|
10
|
-
import { BraidProvider, ToastProvider
|
|
10
|
+
import { BraidProvider, ToastProvider } from '../components';
|
|
11
|
+
// TODO: COLORMODE RELEASE
|
|
12
|
+
// Use public import
|
|
13
|
+
import { Box } from '../components/Box/Box';
|
|
14
|
+
import { darkMode } from '../css/atoms/sprinkles.css';
|
|
11
15
|
|
|
12
16
|
const webFontLinkTags = uniq(
|
|
13
17
|
flatten(values(themes).map((theme) => theme.webFonts)).map(
|
|
@@ -105,40 +109,67 @@ Object.keys(allStories)
|
|
|
105
109
|
: theme.name !== 'wireframe';
|
|
106
110
|
});
|
|
107
111
|
|
|
112
|
+
if (!docs.screenshotOnlyInWireframe) {
|
|
113
|
+
storyThemes.unshift({
|
|
114
|
+
...themes.apac,
|
|
115
|
+
displayName: 'apacDark',
|
|
116
|
+
name: 'apacDark',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
108
120
|
storyThemes.forEach((theme) => {
|
|
109
|
-
const renderStory = () =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
const renderStory = () => {
|
|
122
|
+
if (theme.name === 'apacDark') {
|
|
123
|
+
document.documentElement.classList.add(darkMode);
|
|
124
|
+
} else {
|
|
125
|
+
document.documentElement.classList.remove(darkMode);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<BrowserRouter>
|
|
130
|
+
<BraidProvider theme={theme}>
|
|
131
|
+
<ToastProvider>
|
|
132
|
+
<style type="text/css">
|
|
133
|
+
{`
|
|
115
134
|
.noAnimation * {
|
|
116
135
|
animation-delay: -0.0001s !important;
|
|
117
136
|
animation-duration: 0s !important;
|
|
118
137
|
animation-play-state: paused !important;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
}
|
|
139
|
+
.artboard {
|
|
140
|
+
--deepColor: ${
|
|
141
|
+
theme.name === 'apacDark'
|
|
142
|
+
? `rgba(255, 255, 255, .1)`
|
|
143
|
+
: `rgba(0, 0, 0, .05)`
|
|
144
|
+
};
|
|
145
|
+
--cubeSize: 12px;
|
|
146
|
+
background-color: ${
|
|
147
|
+
theme.name === 'apacDark' ? `black` : `white`
|
|
148
|
+
};
|
|
149
|
+
background-image: linear-gradient(45deg, var(--deepColor) 25%, transparent 25%, transparent 75%, var(--deepColor) 75%, var(--deepColor)),
|
|
150
|
+
linear-gradient(45deg, var(--deepColor) 25%, transparent 25%, transparent 75%, var(--deepColor) 75%, var(--deepColor));
|
|
151
|
+
background-size: calc(var(--cubeSize) * 2) calc(var(--cubeSize) * 2);
|
|
152
|
+
background-position: 0 0, var(--cubeSize) var(--cubeSize);
|
|
153
|
+
}
|
|
154
|
+
`}
|
|
155
|
+
</style>
|
|
156
|
+
<div className="noAnimation artboard">
|
|
157
|
+
{docs.examples.map((example, i) => (
|
|
158
|
+
<PlayroomStateProvider key={i}>
|
|
159
|
+
<RenderExample
|
|
160
|
+
example={{
|
|
161
|
+
...example,
|
|
162
|
+
label: example.label ?? componentName,
|
|
163
|
+
}}
|
|
164
|
+
/>
|
|
165
|
+
</PlayroomStateProvider>
|
|
166
|
+
))}
|
|
167
|
+
</div>
|
|
168
|
+
</ToastProvider>
|
|
169
|
+
</BraidProvider>
|
|
170
|
+
</BrowserRouter>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
142
173
|
|
|
143
174
|
stories.add(theme.name, renderStory, {
|
|
144
175
|
layout: 'fullscreen',
|
|
@@ -225,24 +225,31 @@ export const makeTokens = ({
|
|
|
225
225
|
brandAccent,
|
|
226
226
|
brandAccentLight,
|
|
227
227
|
caution: palette.yellow['900'],
|
|
228
|
+
cautionLight: palette.yellow['300'],
|
|
228
229
|
critical,
|
|
229
230
|
criticalLight: palette.red['300'],
|
|
230
231
|
formAccent,
|
|
231
232
|
formAccentLight: palette.indigo['300'],
|
|
232
233
|
info: palette.blue['700'],
|
|
234
|
+
infoLight: palette.blue['300'],
|
|
233
235
|
link: formAccent,
|
|
236
|
+
linkLight: palette.indigo['300'],
|
|
234
237
|
linkHover: formAccent,
|
|
235
238
|
linkVisited: palette.purple['700'],
|
|
239
|
+
linkLightVisited: palette.purple['300'],
|
|
236
240
|
neutral: palette.grey['700'],
|
|
237
241
|
neutralInverted: white,
|
|
238
242
|
positive: palette.mint['700'],
|
|
243
|
+
positiveLight: palette.mint['300'],
|
|
239
244
|
promote: palette.purple['700'],
|
|
245
|
+
promoteLight: palette.purple['300'],
|
|
240
246
|
rating: '#f57c00',
|
|
241
247
|
secondary: palette.grey['500'],
|
|
242
248
|
secondaryInverted: rgba('#fff', 0.65),
|
|
243
249
|
},
|
|
244
250
|
background: {
|
|
245
251
|
body: palette.grey['50'],
|
|
252
|
+
bodyDark: palette.grey['900'],
|
|
246
253
|
brand,
|
|
247
254
|
brandAccent,
|
|
248
255
|
brandAccentActive,
|
|
@@ -279,6 +286,7 @@ export const makeTokens = ({
|
|
|
279
286
|
promote: palette.purple['700'],
|
|
280
287
|
promoteLight: palette.purple['100'],
|
|
281
288
|
surface: white,
|
|
289
|
+
surfaceDark: palette.grey['800'],
|
|
282
290
|
},
|
|
283
291
|
},
|
|
284
292
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { darken, lighten,
|
|
1
|
+
import { darken, lighten, tint } from 'polished';
|
|
2
2
|
import {
|
|
3
3
|
findClosestAccessibleLighterColor,
|
|
4
4
|
getAccessibleVariant,
|
|
@@ -30,6 +30,15 @@ const brandAccentLight = findClosestAccessibleLighterColor(
|
|
|
30
30
|
);
|
|
31
31
|
const formAccentLight = findClosestAccessibleLighterColor(formAccent, neutral);
|
|
32
32
|
const criticalLight = findClosestAccessibleLighterColor(critical, neutral);
|
|
33
|
+
const cautionLight = findClosestAccessibleLighterColor(caution, neutral);
|
|
34
|
+
const infoLight = findClosestAccessibleLighterColor(info, neutral);
|
|
35
|
+
const linkLight = findClosestAccessibleLighterColor(link, neutral);
|
|
36
|
+
const linkLightVisited = findClosestAccessibleLighterColor(
|
|
37
|
+
linkVisited,
|
|
38
|
+
neutral,
|
|
39
|
+
);
|
|
40
|
+
const positiveLight = findClosestAccessibleLighterColor(positive, neutral);
|
|
41
|
+
const promoteLight = findClosestAccessibleLighterColor(promote, neutral);
|
|
33
42
|
|
|
34
43
|
const getActiveColor = (x: string) =>
|
|
35
44
|
isLight(x) ? darken(0.1, x) : darken(0.05, x);
|
|
@@ -185,7 +194,7 @@ const tokens: BraidTokens = {
|
|
|
185
194
|
brandAccent,
|
|
186
195
|
brandAccentLight,
|
|
187
196
|
caution,
|
|
188
|
-
cautionLight
|
|
197
|
+
cautionLight,
|
|
189
198
|
critical,
|
|
190
199
|
criticalLight,
|
|
191
200
|
field: '#999999',
|
|
@@ -193,14 +202,14 @@ const tokens: BraidTokens = {
|
|
|
193
202
|
formAccent,
|
|
194
203
|
formAccentLight,
|
|
195
204
|
info,
|
|
196
|
-
infoLight
|
|
205
|
+
infoLight,
|
|
197
206
|
neutral,
|
|
198
207
|
neutralInverted: white,
|
|
199
208
|
neutralLight: '#e0e0e0',
|
|
200
209
|
positive,
|
|
201
|
-
positiveLight
|
|
210
|
+
positiveLight,
|
|
202
211
|
promote,
|
|
203
|
-
promoteLight
|
|
212
|
+
promoteLight,
|
|
204
213
|
},
|
|
205
214
|
},
|
|
206
215
|
focusRingSize: 2,
|
|
@@ -217,18 +226,24 @@ const tokens: BraidTokens = {
|
|
|
217
226
|
brandAccent,
|
|
218
227
|
brandAccentLight,
|
|
219
228
|
caution: getAccessibleVariant(caution, caution),
|
|
229
|
+
cautionLight,
|
|
220
230
|
critical: getAccessibleVariant(critical),
|
|
221
231
|
criticalLight,
|
|
222
232
|
formAccent,
|
|
223
233
|
formAccentLight,
|
|
224
234
|
info: getAccessibleVariant(info),
|
|
235
|
+
infoLight,
|
|
225
236
|
link,
|
|
226
237
|
linkHover: link,
|
|
238
|
+
linkLight,
|
|
227
239
|
linkVisited,
|
|
240
|
+
linkLightVisited,
|
|
228
241
|
neutral,
|
|
229
242
|
neutralInverted: white,
|
|
230
243
|
positive: getAccessibleVariant(positive),
|
|
244
|
+
positiveLight,
|
|
231
245
|
promote: getAccessibleVariant(promote),
|
|
246
|
+
promoteLight,
|
|
232
247
|
rating: '#f36e23',
|
|
233
248
|
secondary,
|
|
234
249
|
secondaryInverted: 'hsla(0, 0%, 100%, 0.65)',
|
|
@@ -236,6 +251,7 @@ const tokens: BraidTokens = {
|
|
|
236
251
|
background: {
|
|
237
252
|
body: '#f2f2f2',
|
|
238
253
|
brand: '#0037e9',
|
|
254
|
+
bodyDark: 'black',
|
|
239
255
|
brandAccent,
|
|
240
256
|
brandAccentActive: getActiveColor(brandAccent),
|
|
241
257
|
brandAccentHover: getHoverColor(brandAccent),
|
|
@@ -270,7 +286,8 @@ const tokens: BraidTokens = {
|
|
|
270
286
|
positiveLight: getLightVariant(positive),
|
|
271
287
|
promote,
|
|
272
288
|
promoteLight: getLightVariant(promote),
|
|
273
|
-
surface:
|
|
289
|
+
surface: white,
|
|
290
|
+
surfaceDark: '#222',
|
|
274
291
|
},
|
|
275
292
|
},
|
|
276
293
|
};
|
|
@@ -192,24 +192,31 @@ const tokens: BraidTokens = {
|
|
|
192
192
|
brandAccent,
|
|
193
193
|
brandAccentLight: palette.grey['200'],
|
|
194
194
|
caution: palette.yellow['900'],
|
|
195
|
+
cautionLight: palette.yellow['300'],
|
|
195
196
|
critical: palette.red['700'],
|
|
196
197
|
criticalLight: palette.red['400'],
|
|
197
198
|
formAccent,
|
|
198
199
|
formAccentLight: palette.indigo['400'],
|
|
199
200
|
info: palette.blue['700'],
|
|
201
|
+
infoLight: palette.blue['400'],
|
|
200
202
|
link,
|
|
201
203
|
linkHover: link,
|
|
204
|
+
linkLight: palette.indigo['300'],
|
|
202
205
|
linkVisited,
|
|
206
|
+
linkLightVisited: linkVisited,
|
|
203
207
|
neutral: black,
|
|
204
208
|
neutralInverted: palette.grey['100'],
|
|
205
209
|
positive: palette.mint['700'],
|
|
210
|
+
positiveLight: palette.mint['400'],
|
|
206
211
|
promote: palette.purple['700'],
|
|
212
|
+
promoteLight: palette.purple['400'],
|
|
207
213
|
rating: black,
|
|
208
214
|
secondary,
|
|
209
215
|
secondaryInverted: rgba('#fff', 0.65),
|
|
210
216
|
},
|
|
211
217
|
background: {
|
|
212
218
|
body: white,
|
|
219
|
+
bodyDark: darken(0.04, palette.grey['900']),
|
|
213
220
|
brand: palette.grey['900'],
|
|
214
221
|
brandAccent,
|
|
215
222
|
brandAccentActive: brandAccent,
|
|
@@ -246,6 +253,7 @@ const tokens: BraidTokens = {
|
|
|
246
253
|
promote: palette.purple['600'],
|
|
247
254
|
promoteLight: palette.purple['100'],
|
|
248
255
|
surface: white,
|
|
256
|
+
surfaceDark: palette.grey['900'],
|
|
249
257
|
},
|
|
250
258
|
},
|
|
251
259
|
};
|