Skip to content

Commit d2b7c8e

Browse files
authored
feat(theming)!: update PALETTE with redesigned 100-1200 shades (#1762)
1 parent 78f531b commit d2b7c8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+963
-427
lines changed

.storybook/preview.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import styled, { createGlobalStyle } from 'styled-components';
1010
import { create } from '@storybook/theming/create';
1111
import { ThemeProvider, DEFAULT_THEME, getColorV8 } from '../packages/theming/src';
1212

13+
const DARK_THEME = { ...DEFAULT_THEME, colors: { ...DEFAULT_THEME.colors, base: 'dark' } };
14+
const DARK = getColorV8('foreground', 600 /* default shade */, DARK_THEME);
15+
const LIGHT = getColorV8('background', 600 /* default shade */, DEFAULT_THEME);
16+
1317
export const parameters = {
1418
actions: { argTypesRegex: '^on[A-Z].*' },
1519
backgrounds: {
1620
grid: { disable: true },
1721
values: [
18-
{ name: 'light', value: DEFAULT_THEME.colors.background },
19-
{ name: 'dark', value: DEFAULT_THEME.colors.foreground }
22+
{ name: 'light', value: LIGHT },
23+
{ name: 'dark', value: DARK }
2024
]
2125
},
2226
controls: {
@@ -57,7 +61,7 @@ const withThemeProvider = (story, context) => {
5761

5862
if (
5963
context.globals.backgrounds && context.globals.backgrounds.value !== 'transparent'
60-
? context.globals.backgrounds.value === DEFAULT_THEME.colors.foreground
64+
? context.globals.backgrounds.value === DARK
6165
: context.parameters.backgrounds.default === 'dark'
6266
) {
6367
colors.base = 'dark';

docs/migration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ consider additional positioning prop support on a case-by-case basis.
173173
- The default `theme` object has removed values for `colors.background` and
174174
`colors.foreground`. Use the `'background.default'` and `'foreground.default'`
175175
variables together with the v9 `getColor` utility instead.
176+
- The theming `palette` has undergone a comprehensive redesign and now includes
177+
enhanced support for both light and dark modes. To facilitate a smoother
178+
transition, we have introduced a temporary utility, `getColorV8`, which is
179+
deprecated. This utility enables the application of the legacy version 8 color
180+
scheme to custom components that are not part of the Garden framework. It is
181+
recommended to utilize this stopgap measure until such components can be updated
182+
to leverage the full capabilities of v9 `getColor`.
176183
- Utility function `getDocument` has been removed. Use `useDocument` instead.
177184
- Utility function `isRtl` has been removed. Use `props.theme.rtl` instead.
178185
- The following exports have changed:

packages/accordions/src/styled/accordion/StyledButton.spec.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react';
99
import { render, renderRtl } from 'garden-test-utils';
10-
import { getColorV8, DEFAULT_THEME } from '@zendeskgarden/react-theming';
10+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1111
import { StyledButton } from './StyledButton';
1212

1313
describe('StyledButton', () => {
@@ -16,7 +16,7 @@ describe('StyledButton', () => {
1616

1717
expect(container.firstChild).toHaveStyleRule('padding', '20px');
1818
expect(container.firstChild).toHaveStyleRule('text-align', 'left');
19-
expect(container.firstChild).toHaveStyleRule('color', '#2f3941');
19+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
2020
expect(container.firstChild).not.toHaveStyleRule('cursor');
2121
});
2222

@@ -35,10 +35,7 @@ describe('StyledButton', () => {
3535
it('renders isHovered styling correctly', () => {
3636
const { container } = render(<StyledButton isHovered />);
3737

38-
expect(container.firstChild).toHaveStyleRule(
39-
'color',
40-
getColorV8('primaryHue', 600, DEFAULT_THEME)
41-
);
38+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.blue[600]);
4239

4340
expect(container.firstChild).toHaveStyleRule('cursor', 'pointer', {
4441
modifier: '&:hover'

packages/accordions/src/styled/stepper/StyledIcon.spec.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,23 @@
88
import React from 'react';
99
import { render } from 'garden-test-utils';
1010
import { StyledIcon } from './StyledIcon';
11-
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
11+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1212

1313
describe('StyledIcon', () => {
1414
it('renders default styles', () => {
1515
const { container } = render(<StyledIcon />);
1616

17-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
18-
expect(container.firstChild).toHaveStyleRule(
19-
'background',
20-
getColorV8('neutralHue', 200, DEFAULT_THEME)
21-
);
17+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
18+
expect(container.firstChild).toHaveStyleRule('background', PALETTE_V8.grey[200]);
2219
expect(container.firstChild).toHaveStyleRule('margin-right', '12px');
2320
expect(container.firstChild).not.toHaveStyleRule('margin-bottom');
2421
});
22+
2523
it('renders active color styles', () => {
2624
const { container } = render(<StyledIcon isActive />);
2725

28-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.white);
29-
expect(container.firstChild).toHaveStyleRule(
30-
'background',
31-
getColorV8('neutralHue', 600, DEFAULT_THEME)
32-
);
26+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.white);
27+
expect(container.firstChild).toHaveStyleRule('background', PALETTE_V8.grey[600]);
3328
});
3429

3530
it('renders correct icon styles for horizontal stepper', () => {

packages/accordions/src/styled/stepper/StyledLabel.spec.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React from 'react';
99
import { render } from 'garden-test-utils';
1010
import { StyledLabel } from './StyledLabel';
11-
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
11+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1212

1313
describe('StyledLabel', () => {
1414
it('renders default styles', () => {
@@ -18,10 +18,7 @@ describe('StyledLabel', () => {
1818
expect(container.firstChild).not.toHaveStyleRule('text-align');
1919
expect(container.firstChild).toHaveStyleRule('display', 'flex');
2020
expect(container.firstChild).toHaveStyleRule('align-items', 'center');
21-
expect(container.firstChild).toHaveStyleRule(
22-
'color',
23-
getColorV8('neutralHue', 600, DEFAULT_THEME)
24-
);
21+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
2522
});
2623

2724
it('renders styles for horizontal label', () => {
@@ -36,7 +33,7 @@ describe('StyledLabel', () => {
3633
it('renders styles for active label', () => {
3734
const { container } = render(<StyledLabel isActive />);
3835

39-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
36+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
4037
expect(container.firstChild).toHaveStyleRule('font-weight', '600');
4138
});
4239
});

packages/buttons/src/styled/StyledButton.spec.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react';
99
import { render } from 'garden-test-utils';
10-
import { getColorV8, PALETTE } from '@zendeskgarden/react-theming';
10+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1111
import { StyledButton } from './StyledButton';
1212

1313
describe('StyledButton', () => {
@@ -32,13 +32,13 @@ describe('StyledButton', () => {
3232
it('renders danger styling if provided', () => {
3333
const { container } = render(<StyledButton isDanger />);
3434

35-
expect(container.firstChild).toHaveStyleRule('color', getColorV8('dangerHue'));
35+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.red[600]);
3636
});
3737

3838
it('renders disabled styling if provided', () => {
3939
const { container } = render(<StyledButton disabled />);
4040

41-
expect(container.firstChild).toHaveStyleRule('color', getColorV8('neutralHue'));
41+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
4242
});
4343

4444
it('renders link styling if provided', () => {
@@ -51,13 +51,13 @@ describe('StyledButton', () => {
5151
it('renders primary styling if provided', () => {
5252
const { container } = render(<StyledButton isPrimary />);
5353

54-
expect(container.firstChild).toHaveStyleRule('background-color', getColorV8('primaryHue'));
54+
expect(container.firstChild).toHaveStyleRule('background-color', PALETTE_V8.blue[600]);
5555
});
5656

5757
it('renders neutral styling if provided', () => {
5858
const { container } = render(<StyledButton isNeutral />);
5959

60-
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE.grey[300]);
60+
expect(container.firstChild).toHaveStyleRule('border-color', PALETTE_V8.grey[300]);
6161
});
6262

6363
it('renders pill styling if provided', () => {

packages/buttons/src/styled/StyledIconButton.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { css } from 'styled-components';
1010
import { render } from 'garden-test-utils';
1111
import { StyledIconButton } from './StyledIconButton';
1212
import { StyledIcon } from './StyledIcon';
13-
import { PALETTE } from '@zendeskgarden/react-theming';
13+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1414

1515
describe('StyledIconButton', () => {
1616
it('renders the expected element', () => {
@@ -28,7 +28,7 @@ describe('StyledIconButton', () => {
2828
it('renders basic color styling', () => {
2929
const { container } = render(<StyledIconButton isBasic />);
3030

31-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[600]);
31+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
3232
});
3333

3434
describe('disabled', () => {
@@ -43,7 +43,7 @@ describe('StyledIconButton', () => {
4343
it('renders expected primary styling', () => {
4444
const { container } = render(<StyledIconButton disabled isPrimary />);
4545

46-
expect(container.firstChild).toHaveStyleRule('background-color', PALETTE.grey[200], {
46+
expect(container.firstChild).toHaveStyleRule('background-color', PALETTE_V8.grey[200], {
4747
modifier: ':disabled'
4848
});
4949
});

packages/buttons/src/styled/StyledSplitButton.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { render, renderRtl, screen } from 'garden-test-utils';
1010
import { StyledSplitButton } from './StyledSplitButton';
1111
import { StyledButton } from './StyledButton';
1212
import { StyledIconButton } from './StyledIconButton';
13-
import { PALETTE } from '@zendeskgarden/react-theming';
13+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1414

1515
describe('StyledSplitButton', () => {
1616
it('renders the expected element', () => {
@@ -50,7 +50,7 @@ describe('StyledSplitButton', () => {
5050
</StyledSplitButton>
5151
);
5252

53-
expect(screen.getByText('test')).toHaveStyleRule('background-color', PALETTE.grey[200], {
53+
expect(screen.getByText('test')).toHaveStyleRule('background-color', PALETTE_V8.grey[200], {
5454
modifier: `${StyledSplitButton} &&:disabled`
5555
});
5656
});

packages/dropdowns.legacy/src/elements/Combobox/Combobox.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react';
99
import userEvent from '@testing-library/user-event';
10-
import { PALETTE } from '@zendeskgarden/react-theming';
10+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1111
import { fireEvent, render } from 'garden-test-utils';
1212
import { KEY_CODES } from '@zendeskgarden/container-utilities';
1313

@@ -45,7 +45,7 @@ describe('Combobox', () => {
4545

4646
await user.hover(label);
4747

48-
expect(combobox).toHaveStyleRule('border-color', PALETTE.blue[600], { modifier: ':hover' });
48+
expect(combobox).toHaveStyleRule('border-color', PALETTE_V8.blue[600], { modifier: ':hover' });
4949
});
5050

5151
it('focuses input on label click', async () => {

packages/dropdowns.legacy/src/styled/items/StyledItem.spec.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
*/
77

88
import React from 'react';
9+
import { rgba } from 'polished';
910
import { render } from 'garden-test-utils';
10-
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
11+
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
1112
import { StyledItem } from './StyledItem';
1213

1314
describe('StyledItem', () => {
@@ -20,21 +21,21 @@ describe('StyledItem', () => {
2021
it('renders default styling', () => {
2122
const { container } = render(<StyledItem />);
2223

23-
expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
24+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
2425
});
2526

2627
it('renders danger styling if provided', () => {
2728
const { container } = render(<StyledItem isDanger />);
2829

29-
expect(container.firstChild).toHaveStyleRule('color', getColorV8('dangerHue'));
30+
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.red[600]);
3031
});
3132

3233
it('render danger focus styling if provided', () => {
3334
const { container } = render(<StyledItem isDanger isFocused />);
3435

3536
expect(container.firstChild).toHaveStyleRule(
3637
'background-color',
37-
getColorV8('dangerHue', 600, DEFAULT_THEME, 0.08)
38+
rgba(PALETTE_V8.red[600], 0.08)
3839
);
3940
});
4041
});

0 commit comments

Comments
 (0)