Skip to content

Commit 39d5247

Browse files
committed
Change default series icon shape to circle
1 parent 7a02eb8 commit 39d5247

File tree

12 files changed

+131
-6
lines changed

12 files changed

+131
-6
lines changed

Diff for: packages/polaris-viz/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
<!-- ## Unreleased -->
8+
## Unreleased
9+
10+
### Changed
11+
12+
- Changed default series icon indicator for non-line charts to a circle from a square.
913

1014
## [15.8.1] - 2025-01-21
1115

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import '../../styles/common';
2+
3+
.ColorPreview {
4+
border-radius: 100%;
5+
display: block;
6+
flex: none;
7+
@include print-color;
8+
overflow: hidden;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type {Color} from '@shopify/polaris-viz-core';
2+
3+
import {getCSSBackgroundFromColor} from '../../utilities/getCSSBackgroundFromColor';
4+
5+
import styles from './DefaultPreview.scss';
6+
7+
const ANGLE = 305;
8+
9+
export interface DefaultPreviewProps {
10+
color: Color;
11+
}
12+
13+
const ICON_SIZE = 8;
14+
15+
export function DefaultPreview({color}: DefaultPreviewProps) {
16+
const background = getCSSBackgroundFromColor(color, ANGLE);
17+
18+
return (
19+
<span
20+
className={styles.ColorPreview}
21+
style={{background, height: ICON_SIZE, width: ICON_SIZE}}
22+
/>
23+
);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {DefaultPreview} from './DefaultPreview';
2+
export type {DefaultPreviewProps} from './DefaultPreview';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type {Story} from '@storybook/react';
2+
import {COLOR_VARIABLES} from '@shopify/polaris-viz-core';
3+
4+
export {META as default} from './meta';
5+
6+
import type {DefaultPreviewProps} from '../..';
7+
8+
import {Template} from './data';
9+
10+
export const Solid: Story<DefaultPreviewProps> = Template.bind({});
11+
12+
Solid.args = {
13+
color: COLOR_VARIABLES.colorTeal80,
14+
};
15+
16+
export const Gradient: Story<DefaultPreviewProps> = Template.bind({});
17+
18+
Gradient.args = {
19+
color: [
20+
{
21+
color: '#39337f',
22+
offset: 0,
23+
},
24+
{
25+
color: '#5052b3',
26+
offset: 50,
27+
},
28+
{
29+
color: '#1bbe9e',
30+
offset: 100,
31+
},
32+
],
33+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type {Story} from '@storybook/react';
2+
3+
import type {DefaultPreviewProps} from '../DefaultPreview';
4+
import {DefaultPreview} from '../DefaultPreview';
5+
6+
export const Template: Story<DefaultPreviewProps> = (
7+
args: DefaultPreviewProps,
8+
) => {
9+
return <DefaultPreview {...args} />;
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type {Meta} from '@storybook/react';
2+
3+
import {CONTROLS_ARGS} from '../../../storybook/constants';
4+
import {DefaultPreview} from '../DefaultPreview';
5+
6+
export const META: Meta = {
7+
title: 'Shared/Subcomponents/DefaultPreview',
8+
component: DefaultPreview,
9+
argTypes: {
10+
color: {
11+
description:
12+
'The CSS color or gradient array color to be displayed in the square.',
13+
},
14+
},
15+
parameters: {
16+
controls: CONTROLS_ARGS,
17+
docs: {
18+
description: {
19+
component:
20+
'Used to connect chart colors and gradients to information in tooltips and legends.',
21+
},
22+
},
23+
},
24+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {mount} from '@shopify/react-testing';
2+
3+
import {DefaultPreview} from '../DefaultPreview';
4+
import {PREVIEW_ICON_SIZE} from '../../../constants';
5+
6+
describe('<DefaultPreview/>', () => {
7+
it('renders a div with a background color', () => {
8+
const actual = mount(<DefaultPreview color="rgb(222, 54, 24)" />);
9+
10+
expect(actual).toContainReactComponent('span', {
11+
style: {
12+
background: 'rgb(222, 54, 24)',
13+
height: PREVIEW_ICON_SIZE,
14+
width: PREVIEW_ICON_SIZE,
15+
},
16+
});
17+
});
18+
});

Diff for: packages/polaris-viz/src/components/Legend/components/LegendItem/LegendItem.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
.IconContainer {
3939
display: flex;
4040
align-items: center;
41-
justify-items: center;
41+
justify-content: center;
4242
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const LEGEND_ITEM_LEFT_PADDING = 8;
22
export const LEGEND_ITEM_RIGHT_PADDING = 16;
3-
export const LEGEND_ITEM_GAP = 8;
3+
export const LEGEND_ITEM_GAP = 6;

Diff for: packages/polaris-viz/src/components/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export type {SimpleNormalizedChartProps} from './SimpleNormalizedChart';
1212
export {YAxis} from './YAxis';
1313
export {SquareColorPreview} from './SquareColorPreview';
1414
export type {SquareColorPreviewProps} from './SquareColorPreview';
15+
export {DefaultPreview} from './DefaultPreview';
16+
export type {DefaultPreviewProps} from './DefaultPreview';
1517
export {StackedAreaChart} from './StackedAreaChart';
1618
export type {StackedAreaChartProps} from './StackedAreaChart';
1719
export {BarChart} from './BarChart';

Diff for: packages/polaris-viz/src/components/shared/SeriesIcon/SeriesIcon.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {Shape, Color, LineStyle} from '@shopify/polaris-viz-core';
22

33
import {LinePreview} from '../../LinePreview';
4-
import {SquareColorPreview} from '../../SquareColorPreview';
4+
import {DefaultPreview} from '../../DefaultPreview';
55

66
interface Props {
77
color: Color;
@@ -16,8 +16,7 @@ export function SeriesIcon({color, lineStyle, shape = 'Bar'}: Props) {
1616

1717
return <LinePreview color={color} lineStyle={style} />;
1818
}
19-
case 'Bar':
2019
default:
21-
return <SquareColorPreview color={color} />;
20+
return <DefaultPreview color={color} />;
2221
}
2322
}

0 commit comments

Comments
 (0)