Skip to content

Commit 92693df

Browse files
authored
[LG-4998] feat: Shadow Tokens (#3249)
* [LG-4998] feat: Shadow Tokens * updated token maps, updated card, code, menu, modal, expandable card * updates searchpanetl * updates * updated overflwo shadow value * updated cbox, menu, formfooter, tablehead, toast * added chat. menu, select * updated dependencies * updated lock file, updated shadow1 * pr feedback pt 1 * fixed deprecated comment * updates * udpated titleBar and tableHEad shadows * rm 100 value, updated changeset * rm datePicker changes, rm shadow from titleBar * updated tableHead
1 parent 6bb6c00 commit 92693df

File tree

33 files changed

+330
-219
lines changed

33 files changed

+330
-219
lines changed

.changeset/cold-rivers-drive.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@leafygreen-ui/tokens': major
3+
'@leafygreen-ui/confirmation-modal': minor
4+
'@leafygreen-ui/expandable-card': minor
5+
'@leafygreen-ui/search-input': minor
6+
'@leafygreen-ui/code-editor': minor
7+
'@leafygreen-ui/form-footer': minor
8+
'@leafygreen-ui/combobox': minor
9+
'@lg-chat/chat-window': minor
10+
'@leafygreen-ui/emotion': minor
11+
'@leafygreen-ui/select': minor
12+
'@lg-chat/title-bar': minor
13+
'@leafygreen-ui/modal': minor
14+
'@leafygreen-ui/table': minor
15+
'@leafygreen-ui/toast': minor
16+
'@leafygreen-ui/card': minor
17+
'@leafygreen-ui/menu': minor
18+
'@lg-chat/message': minor
19+
---
20+
21+
Updated major version to Shadow tokens. `shadow` object and its key/values have been changed. Other packages utilizing the shadow values have had a minor update to accommodate the changes.

chat/chat-window/src/ChatWindow/ChatWindow.styles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Theme } from '@leafygreen-ui/lib';
33
import { palette } from '@leafygreen-ui/palette';
44
import {
55
borderRadius,
6+
boxShadows,
67
breakpoints,
78
color,
89
InteractionState,
@@ -27,7 +28,7 @@ const getSpaciousContainerStyles = (theme: Theme) => css`
2728
overflow: hidden;
2829
border: 1px solid
2930
${color[theme].border[Variant.Secondary][InteractionState.Default]};
30-
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.05);
31+
box-shadow: ${boxShadows[theme][3]};
3132
background-color: ${theme === Theme.Dark
3233
? palette.black
3334
: palette.gray.light3};

chat/message/src/MessageContainer/MessageContainer.styles.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { css, cx } from '@leafygreen-ui/emotion';
22
import { Theme } from '@leafygreen-ui/lib';
33
import { palette } from '@leafygreen-ui/palette';
4-
import { borderRadius, spacing } from '@leafygreen-ui/tokens';
4+
import { borderRadius, boxShadows, spacing } from '@leafygreen-ui/tokens';
55

66
import { Variant } from './MessageContainer.types';
77

@@ -32,10 +32,10 @@ const getCompactStyles = ({
3232
[getCompactPrimaryVariantStyles(theme)]: variant === Variant.Primary,
3333
});
3434

35-
const baseSpaciousContainerStyles = css`
35+
const getBaseSpaciousContainerStyles = (theme: Theme) => css`
3636
border-radius: ${borderRadius[300]}px;
3737
/* Card Shadow */
38-
box-shadow: 0px 4px 10px -4px ${palette.black}4D; // 4D is 30% opacity
38+
box-shadow: ${boxShadows[theme][1]};
3939
padding: ${spacing[600]}px;
4040
`;
4141

@@ -65,7 +65,10 @@ const getSpaciousContainerStyles = ({
6565
theme: Theme;
6666
variant: Variant;
6767
}) =>
68-
cx(baseSpaciousContainerStyles, spaciousVariantThemeStyles[variant][theme]);
68+
cx(
69+
getBaseSpaciousContainerStyles(theme),
70+
spaciousVariantThemeStyles[variant][theme],
71+
);
6972

7073
export const getMessageContainerStyles = ({
7174
className,
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { css } from '@leafygreen-ui/emotion';
1+
import { css, cx } from '@leafygreen-ui/emotion';
22
import { Theme } from '@leafygreen-ui/lib';
33
import { palette } from '@leafygreen-ui/palette';
44
import { spacing } from '@leafygreen-ui/tokens';
55

6-
export const baseStyles = css`
6+
import { Align } from './TitleBar.types';
7+
8+
const baseStyles = css`
79
width: 100%;
810
display: flex;
911
justify-content: space-between;
@@ -12,7 +14,7 @@ export const baseStyles = css`
1214
border-bottom: 1px solid;
1315
`;
1416

15-
export const themeStyles: Record<Theme, string> = {
17+
const themeStyles: Record<Theme, string> = {
1618
[Theme.Dark]: css`
1719
background-color: ${palette.black};
1820
border-color: ${palette.gray.dark2};
@@ -23,13 +25,28 @@ export const themeStyles: Record<Theme, string> = {
2325
`,
2426
};
2527

26-
export const contentContainerStyles = css`
28+
export const getTitleBarStyles = ({
29+
className,
30+
theme,
31+
}: {
32+
theme: Theme;
33+
className?: string;
34+
}) => {
35+
return cx(baseStyles, themeStyles[theme], className);
36+
};
37+
38+
const contentContainerStyles = css`
2739
display: flex;
2840
align-items: center;
2941
justify-content: center;
30-
gap: ${spacing[2]}px;
42+
gap: ${spacing[200]}px;
3143
`;
3244

33-
export const contentAlignmentStyles = css`
45+
const contentAlignmentStyles = css`
3446
margin: auto;
3547
`;
48+
49+
export const getContentContainerStyles = ({ align }: { align: Align }) =>
50+
cx(contentContainerStyles, {
51+
[contentAlignmentStyles]: align === Align.Center,
52+
});

chat/title-bar/src/TitleBar/TitleBar.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import React, { ForwardedRef, forwardRef } from 'react';
22
import { Avatar, Variant as ChatAvatarVariant } from '@lg-chat/avatar';
33

4-
import Badge from '@leafygreen-ui/badge';
5-
import { cx } from '@leafygreen-ui/emotion';
4+
import { Badge } from '@leafygreen-ui/badge';
65
import XIcon from '@leafygreen-ui/icon/dist/X';
7-
import IconButton from '@leafygreen-ui/icon-button';
6+
import { IconButton } from '@leafygreen-ui/icon-button';
87
import LeafyGreenProvider, {
98
useDarkMode,
109
} from '@leafygreen-ui/leafygreen-provider';
1110
import { Body } from '@leafygreen-ui/typography';
1211

1312
import {
14-
baseStyles,
15-
contentAlignmentStyles,
16-
contentContainerStyles,
17-
themeStyles,
13+
getContentContainerStyles,
14+
getTitleBarStyles,
1815
} from './TitleBar.styles';
1916
import { Align, TitleBarProps } from '.';
2017

@@ -36,15 +33,11 @@ export const TitleBar = forwardRef(
3633
return (
3734
<LeafyGreenProvider darkMode={darkMode}>
3835
<div
39-
className={cx(baseStyles, themeStyles[theme], className)}
36+
className={getTitleBarStyles({ theme, className })}
4037
{...rest}
4138
ref={ref}
4239
>
43-
<div
44-
className={cx(contentContainerStyles, {
45-
[contentAlignmentStyles]: align === Align.Center,
46-
})}
47-
>
40+
<div className={getContentContainerStyles({ align })}>
4841
<Avatar variant={ChatAvatarVariant.Mongo} sizeOverride={24} />
4942
<Body>
5043
<strong>{title}</strong>

packages/card/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"@leafygreen-ui/lib": "workspace:^",
2020
"@leafygreen-ui/palette": "workspace:^",
2121
"@leafygreen-ui/polymorphic": "workspace:^",
22-
"@leafygreen-ui/tokens": "workspace:^",
23-
"polished": "^4.2.2"
22+
"@leafygreen-ui/tokens": "workspace:^"
2423
},
2524
"peerDependencies": {
2625
"@leafygreen-ui/leafygreen-provider": ">=3.2.0"

packages/card/src/Card.stories.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { storybookArgTypes, StoryMetaType } from '@lg-tools/storybook-utils';
33
import { StoryFn } from '@storybook/react';
44

5-
import Card, { CardProps } from '.';
5+
import { Card, CardProps, ContentStyle } from '.';
66

77
const loremIpsum = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy children ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.`;
88

@@ -27,6 +27,11 @@ const meta: StoryMetaType<typeof Card> = {
2727
as: storybookArgTypes.as,
2828
darkMode: storybookArgTypes.darkMode,
2929
children: storybookArgTypes.children,
30+
contentStyle: {
31+
options: Object.values(ContentStyle),
32+
control: { type: 'radio' },
33+
defaultValue: ContentStyle.None,
34+
},
3035
},
3136
};
3237
export default meta;

packages/card/src/Card/styles.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
import { transparentize } from 'polished';
2-
3-
import { css } from '@leafygreen-ui/emotion';
1+
import { css, cx } from '@leafygreen-ui/emotion';
42
import { Theme } from '@leafygreen-ui/lib';
53
import { palette } from '@leafygreen-ui/palette';
64
import {
5+
boxShadows,
76
focusRing,
87
fontFamilies,
98
transitionDuration,
109
typeScales,
1110
} from '@leafygreen-ui/tokens';
1211

12+
import { ContentStyle } from './types';
13+
1314
interface ColorSet {
1415
containerStyle: string;
1516
clickableStyle: string;
1617
}
1718

18-
const lightBaseBoxShadow = `0 4px 10px -4px ${transparentize(
19-
0.7,
20-
palette.black,
21-
)}`;
22-
const lightHoverBoxShadow = `0 4px 20px -4px ${transparentize(
23-
0.8,
24-
palette.black,
25-
)}`;
19+
const lightBaseBoxShadow = boxShadows[Theme.Light][1];
20+
const lightHoverBoxShadow = boxShadows[Theme.Light][2];
21+
const darkBaseBoxShadow = boxShadows[Theme.Dark][1];
22+
const darkHoverBoxShadow = boxShadows[Theme.Dark][2];
23+
2624
const lightFocusBoxShadow = focusRing.light.default;
27-
const darkBaseBoxShadow = `0 4px 20px -4px #01121A`;
28-
const darkHoverBoxShadow = `0 4px 20px -4px ${transparentize(0.3, '#000000')}`;
2925
const darkFocusBoxShadow = focusRing.dark.default;
3026

3127
export const colorSet: Record<Theme, ColorSet> = {
@@ -50,7 +46,7 @@ export const colorSet: Record<Theme, ColorSet> = {
5046
box-shadow: ${lightHoverBoxShadow};
5147
5248
&:focus {
53-
box-shadow: ${lightFocusBoxShadow}, ${lightHoverBoxShadow};
49+
box-shadow: ${lightFocusBoxShadow}, ${lightBaseBoxShadow};
5450
}
5551
}
5652
`,
@@ -74,7 +70,7 @@ export const colorSet: Record<Theme, ColorSet> = {
7470
box-shadow: ${darkHoverBoxShadow};
7571
7672
&:focus {
77-
box-shadow: ${darkHoverBoxShadow}, ${darkFocusBoxShadow};
73+
box-shadow: ${darkBaseBoxShadow}, ${darkFocusBoxShadow};
7874
}
7975
}
8076
`,
@@ -92,3 +88,21 @@ export const containerStyle = css`
9288
padding: 24px;
9389
min-height: 68px; // 48px + 20px (padding + line-height)
9490
`;
91+
92+
export const getCardStyles = ({
93+
theme,
94+
contentStyle,
95+
className,
96+
}: {
97+
theme: Theme;
98+
contentStyle: ContentStyle;
99+
className?: string;
100+
}) =>
101+
cx(
102+
containerStyle,
103+
{
104+
[colorSet[theme].containerStyle]: true,
105+
[colorSet[theme].clickableStyle]: contentStyle === ContentStyle.Clickable,
106+
},
107+
className,
108+
);

packages/code-editor/src/CodeEditorTooltip/CodeEditorTooltip.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { css } from '@leafygreen-ui/emotion';
22
import { Theme } from '@leafygreen-ui/lib';
33
import {
44
borderRadius,
5+
boxShadows,
56
color,
67
fontFamilies,
78
InteractionState,
8-
shadow,
99
spacing,
1010
Variant,
1111
} from '@leafygreen-ui/tokens';
@@ -19,7 +19,7 @@ export const getTooltipStyles = (theme: Theme) => css`
1919
border-radius: ${borderRadius[200]}px;
2020
border: 1px solid
2121
${color[theme].border[Variant.Secondary][InteractionState.Default]};
22-
box-shadow: ${shadow[theme][100]};
22+
box-shadow: ${boxShadows[theme][1]};
2323
line-height: ${MESSAGE_LINE_HEIGHT}px;
2424
width: fit-content;
2525
`;

packages/code-editor/src/SearchPanel/SearchPanel.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Theme } from '@leafygreen-ui/lib';
33
import {
44
BaseFontSize,
55
borderRadius,
6+
boxShadows,
67
InteractionState,
7-
shadow,
88
spacing,
99
transitionDuration,
1010
Variant,
@@ -48,7 +48,7 @@ const getBaseContainerStyles = (
4848
height: 100%;
4949
5050
/** Apply the shadow to the pseudo-element */
51-
box-shadow: ${shadow[theme][100]};
51+
box-shadow: ${boxShadows[theme][1]};
5252
5353
/** Negative values expand the clipping area outward, revealing the shadow. */
5454
/** A zero value clips the shadow exactly at the element's edge. */

0 commit comments

Comments
 (0)