Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default theme to Light theme #1658

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 4 additions & 13 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {themes} from '@storybook/theming';
import {PolarisVizProvider} from '@shopify/polaris-viz';
import {
DEFAULT_THEME,
LIGHT_THEME,
UPLIFT_THEME,
} from '../packages/polaris-viz/src/constants';
import {DARK_THEME, LIGHT_THEME} from '../packages/polaris-viz/src/constants';
import {useTheme} from '../packages/polaris-viz/src/hooks';

// https://github.com/storybookjs/storybook/issues/548
Expand All @@ -26,7 +22,7 @@ const storiesOrder = {
Hooks: null,
Utilities: null,
Themes: {
'Default Themes': null,
'Available Themes': null,
Customizing: null,
'createTheme Utility': null,
'Theme Definition': {
Expand Down Expand Up @@ -134,14 +130,14 @@ export const decorators = [
return (
<PolarisVizProvider
themes={{
Default: {
Dark: {
chartContainer: {
padding: '20px',
},
grid: {
horizontalMargin:
context.parameters.horizontalMargin ??
DEFAULT_THEME.grid.horizontalMargin,
DARK_THEME.grid.horizontalMargin,
horizontalOverflow: true,
},
},
Expand All @@ -150,11 +146,6 @@ export const decorators = [
padding: '20px',
},
},
Uplift: {
chartContainer: {
padding: '20px',
},
},
NoSpline: {
line: {hasSpline: false},
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@
},
"dependencies": {
"concurrently": "^7.0.0"
}
},
"version": "1.0.0-light-theme-default-beta.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import '@shopify/react-testing/matchers';
import type {LineSeriesProps} from '../LineSeries';
import {LineSeries} from '../LineSeries';
import {Area} from '../components';
import {SHAPE_ANIMATION_HEIGHT_BUFFER} from '../../../constants';
import {
DEFAULT_THEME_NAME,
SHAPE_ANIMATION_HEIGHT_BUFFER,
} from '../../../constants';

const someScale = scaleLinear().domain([0, 100]).range([0, 100]);

Expand All @@ -30,7 +33,7 @@ const defaultProps: LineSeriesProps = {
data: mockData,
svgDimensions: {width: 100, height: 100},
index: 0,
theme: 'Default',
theme: DEFAULT_THEME_NAME,
};

describe('<LineSeries />', () => {
Expand All @@ -52,7 +55,7 @@ describe('<LineSeries />', () => {
</svg>,
{
themes: {
Default: {
[DEFAULT_THEME_NAME]: {
line: {
width: 10,
},
Expand Down Expand Up @@ -105,7 +108,7 @@ describe('<LineSeries />', () => {
</svg>,
{
themes: {
Default: {
[DEFAULT_THEME_NAME]: {
seriesColors: {
comparison: 'red',
},
Expand Down Expand Up @@ -140,7 +143,7 @@ describe('<LineSeries />', () => {
</svg>,
{
themes: {
Default: {
[DEFAULT_THEME_NAME]: {
line: {
hasSpline: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import type {
SvgComponents,
} from '../../types';
import {
DEFAULT_THEME as Default,
DARK_THEME as Dark,
LIGHT_THEME as Light,
PRINT_THEME as Print,
UPLIFT_THEME as Uplift,
DEFAULT_COMPONENTS as DefaultComponents,
DEFAULT_THEME_NAME,
} from '../../constants';
Expand Down Expand Up @@ -41,10 +40,9 @@ export function PolarisVizProvider({
...components,
},
themes: createThemes({
Default,
Dark,
Light,
Print,
Uplift,
...themes,
}),
animated,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import {createHost} from '@react-spring/animated';
import {usePolarisVizContext} from '../../../hooks';
import {PolarisVizProvider} from '../PolarisVizProvider';
import {PolarisVizContext} from '../../../contexts';
import {DEFAULT_THEME, DEFAULT_COMPONENTS} from '../../../constants';
import {
DEFAULT_COMPONENTS,
DEFAULT_THEME_NAME,
LIGHT_THEME,
} from '../../../constants';

const MockChild = ({theme = 'Default'}) => {
const MockChild = ({theme = DEFAULT_THEME_NAME}) => {
const {themes} = usePolarisVizContext();
return <div>{JSON.stringify(themes[theme])}</div>;
};
Expand Down Expand Up @@ -41,30 +45,30 @@ describe('<PolarisVizProvider />', () => {
</PolarisVizProvider>,
);

expect(vizProvider).toContainReactText(JSON.stringify(DEFAULT_THEME));
expect(vizProvider).toContainReactText(JSON.stringify(LIGHT_THEME));
});

it('passes custom themes to children', () => {
const vizProvider = mount(
<PolarisVizProvider
themes={{
Dark: {
Light: {
bar: {
borderRadius: 3,
},
},
}}
animated={host.animated}
>
<MockChild theme="Dark" />
<MockChild theme="Light" />
</PolarisVizProvider>,
);

expect(vizProvider).toContainReactText(
JSON.stringify({
...DEFAULT_THEME,
...LIGHT_THEME,
bar: {
...DEFAULT_THEME.bar,
...LIGHT_THEME.bar,
borderRadius: 3,
},
}),
Expand Down
Loading
Loading