Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit eb05fce

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

File tree

13 files changed

+135
-11
lines changed

13 files changed

+135
-11
lines changed

packages/polaris-viz/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
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

Lines changed: 9 additions & 0 deletions
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+
}
Lines changed: 24 additions & 0 deletions
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+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {DefaultPreview} from './DefaultPreview';
2+
export type {DefaultPreviewProps} from './DefaultPreview';
Lines changed: 33 additions & 0 deletions
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+
};
Lines changed: 10 additions & 0 deletions
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+
};
Lines changed: 24 additions & 0 deletions
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+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {mount} from '@shopify/react-testing';
2+
3+
import {DefaultPreview} from '../DefaultPreview';
4+
5+
describe('<DefaultPreview/>', () => {
6+
it('renders a div with a background color', () => {
7+
const actual = mount(<DefaultPreview color="rgb(222, 54, 24)" />);
8+
9+
expect(actual).toContainReactComponent('span', {
10+
style: {
11+
background: 'rgb(222, 54, 24)',
12+
height: 8,
13+
width: 8,
14+
},
15+
});
16+
});
17+
});

packages/polaris-viz/src/components/Legend/components/LegendItem/LegendItem.scss

Lines changed: 1 addition & 1 deletion
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
}
Lines changed: 1 addition & 1 deletion
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;

0 commit comments

Comments
 (0)