Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import React from 'react';
import styled, { createGlobalStyle } from 'styled-components';
import { create } from '@storybook/theming/create';
import { ThemeProvider, DEFAULT_THEME, getColorV8 } from '../packages/theming/src';
import { ThemeProvider, DEFAULT_THEME, getColor } from '../packages/theming/src';

const DARK_THEME = { ...DEFAULT_THEME, colors: { ...DEFAULT_THEME.colors, base: 'dark' } };
const DARK = getColor({ theme: DARK_THEME, variable: 'background.default' });
const LIGHT = getColor({ theme: DEFAULT_THEME, variable: 'background.default' });

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
backgrounds: {
grid: { disable: true },
values: [
{ name: 'light', value: DEFAULT_THEME.colors.background },
{ name: 'dark', value: DEFAULT_THEME.colors.foreground }
{ name: 'light', value: LIGHT },
{ name: 'dark', value: DARK }
]
},
controls: {
Expand All @@ -32,7 +36,7 @@ export const parameters = {

const GlobalPreviewStyling = createGlobalStyle`
body {
background-color: ${p => getColorV8('background', 600 /* default shade */, p.theme)};
background-color: ${p => getColor({ theme: p.theme, variable: 'background.default' })};
/* stylelint-disable-next-line declaration-no-important */
padding: 0 !important;
font-family: ${p => p.theme.fonts.system};
Expand All @@ -57,12 +61,10 @@ const withThemeProvider = (story, context) => {

if (
context.globals.backgrounds && context.globals.backgrounds.value !== 'transparent'
? context.globals.backgrounds.value === DEFAULT_THEME.colors.foreground
? context.globals.backgrounds.value === DARK
: context.parameters.backgrounds.default === 'dark'
) {
colors.base = 'dark';
colors.background = getColorV8('neutralHue', 900, DEFAULT_THEME);
colors.foreground = getColorV8('neutralHue', 200, DEFAULT_THEME);
}

const theme = { ...DEFAULT_THEME, colors, rtl };
Expand Down
5 changes: 5 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ consider additional positioning prop support on a case-by-case basis.
- The default `theme` object has removed values for `colors.background` and
`colors.foreground`. Use the `'background.default'` and `'foreground.default'`
variables together with the v9 `getColor` utility instead.
- The default theming `palette` has been redesigned and expanded to support
light/dark modes. A temporary, deprecated `getColorV8` utility has been added.
Use the temporary utility to apply legacy version 8 colors to custom
(non-Garden) components they can be upgraded to use the enhanced version 9
`getColor` utility.
- Utility function `getDocument` has been removed. Use `useDocument` instead.
- Utility function `isRtl` has been removed. Use `props.theme.rtl` instead.
- The following exports have changed:
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

describe('StyledButton', () => {
Expand All @@ -16,7 +16,7 @@ describe('StyledButton', () => {

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

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

expect(container.firstChild).toHaveStyleRule(
'color',
getColorV8('primaryHue', 600, DEFAULT_THEME)
);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.blue[600]);

expect(container.firstChild).toHaveStyleRule('cursor', 'pointer', {
modifier: '&:hover'
Expand Down
17 changes: 6 additions & 11 deletions packages/accordions/src/styled/stepper/StyledIcon.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,23 @@
import React from 'react';
import { render } from 'garden-test-utils';
import { StyledIcon } from './StyledIcon';
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';

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

expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
expect(container.firstChild).toHaveStyleRule(
'background',
getColorV8('neutralHue', 200, DEFAULT_THEME)
);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
expect(container.firstChild).toHaveStyleRule('background', PALETTE_V8.grey[200]);
expect(container.firstChild).toHaveStyleRule('margin-right', '12px');
expect(container.firstChild).not.toHaveStyleRule('margin-bottom');
});

it('renders active color styles', () => {
const { container } = render(<StyledIcon isActive />);

expect(container.firstChild).toHaveStyleRule('color', PALETTE.white);
expect(container.firstChild).toHaveStyleRule(
'background',
getColorV8('neutralHue', 600, DEFAULT_THEME)
);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.white);
expect(container.firstChild).toHaveStyleRule('background', PALETTE_V8.grey[600]);
});

it('renders correct icon styles for horizontal stepper', () => {
Expand Down
9 changes: 3 additions & 6 deletions packages/accordions/src/styled/stepper/StyledLabel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { render } from 'garden-test-utils';
import { StyledLabel } from './StyledLabel';
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';

describe('StyledLabel', () => {
it('renders default styles', () => {
Expand All @@ -18,10 +18,7 @@ describe('StyledLabel', () => {
expect(container.firstChild).not.toHaveStyleRule('text-align');
expect(container.firstChild).toHaveStyleRule('display', 'flex');
expect(container.firstChild).toHaveStyleRule('align-items', 'center');
expect(container.firstChild).toHaveStyleRule(
'color',
getColorV8('neutralHue', 600, DEFAULT_THEME)
);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
});

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

expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
expect(container.firstChild).toHaveStyleRule('font-weight', '600');
});
});
10 changes: 5 additions & 5 deletions packages/buttons/src/styled/StyledButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { render } from 'garden-test-utils';
import { getColorV8, PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
import { StyledButton } from './StyledButton';

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

expect(container.firstChild).toHaveStyleRule('color', getColorV8('dangerHue'));
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.red[600]);
});

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

expect(container.firstChild).toHaveStyleRule('color', getColorV8('neutralHue'));
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
});

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

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

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

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

it('renders pill styling if provided', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/buttons/src/styled/StyledIconButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { css } from 'styled-components';
import { render } from 'garden-test-utils';
import { StyledIconButton } from './StyledIconButton';
import { StyledIcon } from './StyledIcon';
import { PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';

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

expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[600]);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[600]);
});

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

expect(container.firstChild).toHaveStyleRule('background-color', PALETTE.grey[200], {
expect(container.firstChild).toHaveStyleRule('background-color', PALETTE_V8.grey[200], {
modifier: ':disabled'
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/buttons/src/styled/StyledSplitButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render, renderRtl, screen } from 'garden-test-utils';
import { StyledSplitButton } from './StyledSplitButton';
import { StyledButton } from './StyledButton';
import { StyledIconButton } from './StyledIconButton';
import { PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';

describe('StyledSplitButton', () => {
it('renders the expected element', () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('StyledSplitButton', () => {
</StyledSplitButton>
);

expect(screen.getByText('test')).toHaveStyleRule('background-color', PALETTE.grey[200], {
expect(screen.getByText('test')).toHaveStyleRule('background-color', PALETTE_V8.grey[200], {
modifier: `${StyledSplitButton} &&:disabled`
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Combobox', () => {

await user.hover(label);

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

it('focuses input on label click', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/

import React from 'react';
import { rgba } from 'polished';
import { render } from 'garden-test-utils';
import { getColorV8, DEFAULT_THEME, PALETTE } from '@zendeskgarden/react-theming';
import { PALETTE_V8 } from '@zendeskgarden/react-theming';
import { StyledItem } from './StyledItem';

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

expect(container.firstChild).toHaveStyleRule('color', PALETTE.grey[800]);
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.grey[800]);
});

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

expect(container.firstChild).toHaveStyleRule('color', getColorV8('dangerHue'));
expect(container.firstChild).toHaveStyleRule('color', PALETTE_V8.red[600]);
});

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

expect(container.firstChild).toHaveStyleRule(
'background-color',
getColorV8('dangerHue', 600, DEFAULT_THEME, 0.08)
rgba(PALETTE_V8.red[600], 0.08)
);
});
});
Loading