Skip to content

Commit 311aac3

Browse files
authored
fix(theming)!: remove background.primary color variable (#1938)
1 parent 8c383a0 commit 311aac3

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

packages/avatars/demo/~patterns/stories/MenuStory.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8+
import { useTheme } from 'styled-components';
89
import React, { useCallback, useState } from 'react';
910
import { StoryFn } from '@storybook/react';
1011
import { Grid } from '@zendeskgarden/react-grid';
1112
import { Menu, Item } from '@zendeskgarden/react-dropdowns';
1213
import { Avatar, IAvatarProps } from '@zendeskgarden/react-avatars';
14+
import { getColor } from '@zendeskgarden/react-theming';
1315

1416
const items: {
1517
value: string;
@@ -49,6 +51,8 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
4951
focusedValue !== undefined && setHighlightedValue(focusedValue);
5052
}, []);
5153

54+
const theme = useTheme();
55+
5256
return (
5357
<Grid>
5458
<Grid.Row style={{ height: 'calc(100vh - 80px)' }}>
@@ -64,7 +68,14 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
6468
status={item.avatarProps.status}
6569
badge={item.avatarProps.badge}
6670
surfaceColor={
67-
highlightedValue === item.value ? 'background.primary' : 'background.raised'
71+
highlightedValue === item.value
72+
? getColor({
73+
theme,
74+
hue: 'primaryHue',
75+
light: { shade: 100 },
76+
dark: { shade: 900 }
77+
})
78+
: 'background.raised'
6879
}
6980
>
7081
<img alt={item.label} src={`images/avatars/${item.value}.png`} />

packages/avatars/src/styled/StyledAvatar.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ describe('StyledAvatar', () => {
5252

5353
it('renders surface color variable key as expected', () => {
5454
const { container, rerender } = render(
55-
<StyledAvatar $status="away" $surfaceColor="background.primary" />
55+
<StyledAvatar $status="away" $surfaceColor="background.primaryEmphasis" />
5656
);
5757

58-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.blue[100], {
58+
expect(container.firstChild).toHaveStyleRule('color', PALETTE.blue[700], {
5959
modifier: '&&'
6060
});
6161

62-
rerender(<StyledAvatar $surfaceColor="background.primary" />);
62+
rerender(<StyledAvatar $surfaceColor="background.primaryEmphasis" />);
6363

6464
expect(container.firstChild).toHaveStyleRule('color', 'transparent', {
6565
modifier: '&&'

packages/avatars/src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
2929
/**
3030
* Provides surface color for an avatar placed on a non-default background.
3131
* Accepts a [color variable](/components/theme-object#colors) key (i.e.
32-
* `background.primary`) to render based on light/dark mode, or any hex value.
32+
* `background.subtle`) to render based on light/dark mode, or any hex value.
3333
*/
3434
surfaceColor?: string;
3535
/** Applies system styling for representing objects, brands, or products */

packages/theming/demo/stories/ArrowStylesStory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ interface IArgs {
2222
const StyledDiv = styled.div<Omit<IArgs, 'isAnimated'>>`
2323
border: ${p =>
2424
p.hasBorder &&
25-
`${p.theme.borders.sm} ${getColor({ theme: p.theme, variable: 'border.primaryEmphasis' })}`};
25+
`${p.theme.borders.sm} ${getColor({ theme: p.theme, variable: 'border.default' })}`};
2626
box-shadow: ${p =>
2727
p.hasBoxShadow &&
2828
p.theme.shadows.lg(
2929
`${p.theme.space.base * (p.theme.colors.base === 'dark' ? 4 : 5)}px`,
3030
`${p.theme.space.base * (p.theme.colors.base === 'dark' ? 5 : 6)}px`,
3131
getColor({ variable: 'shadow.medium', theme: p.theme })
3232
)};
33-
background-color: ${p => getColor({ theme: p.theme, variable: 'background.primary' })};
33+
background-color: ${p => getColor({ theme: p.theme, variable: 'background.subtle' })};
3434
padding: ${p => p.theme.space.xxl};
3535
3636
${p =>

packages/theming/src/elements/theme/__snapshots__/index.spec.ts.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
3939
"default": "neutralHue.1100",
4040
"disabled": "rgba(neutralHue.500, 100)",
4141
"emphasis": "neutralHue.600",
42-
"primary": "primaryHue.900",
4342
"primaryEmphasis": "primaryHue.600",
4443
"raised": "neutralHue.1000",
4544
"recessed": "neutralHue.1200",
@@ -88,7 +87,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
8887
"default": "palette.white",
8988
"disabled": "rgba(neutralHue.700, 100)",
9089
"emphasis": "neutralHue.700",
91-
"primary": "primaryHue.100",
9290
"primaryEmphasis": "primaryHue.700",
9391
"raised": "palette.white",
9492
"recessed": "neutralHue.100",

packages/theming/src/elements/theme/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const colors = {
5252
recessed: 'neutralHue.1200',
5353
subtle: 'neutralHue.1000',
5454
emphasis: 'neutralHue.600',
55-
primary: 'primaryHue.900',
5655
success: 'successHue.1000',
5756
warning: 'warningHue.1000',
5857
danger: 'dangerHue.1000',
@@ -101,7 +100,6 @@ const colors = {
101100
recessed: 'neutralHue.100',
102101
subtle: 'neutralHue.100',
103102
emphasis: 'neutralHue.700',
104-
primary: 'primaryHue.100',
105103
success: 'successHue.100',
106104
warning: 'warningHue.100',
107105
danger: 'dangerHue.100',

0 commit comments

Comments
 (0)