-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change default series icon shape to circle
- Loading branch information
Showing
12 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/polaris-viz/src/components/DefaultPreview/DefaultPreview.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import '../../styles/common'; | ||
|
||
.ColorPreview { | ||
border-radius: 100%; | ||
display: block; | ||
flex: none; | ||
@include print-color; | ||
overflow: hidden; | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/polaris-viz/src/components/DefaultPreview/DefaultPreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type {Color} from '@shopify/polaris-viz-core'; | ||
|
||
import {getCSSBackgroundFromColor} from '../../utilities/getCSSBackgroundFromColor'; | ||
|
||
import styles from './DefaultPreview.scss'; | ||
|
||
const ANGLE = 305; | ||
|
||
export interface DefaultPreviewProps { | ||
color: Color; | ||
} | ||
|
||
const ICON_SIZE = 8; | ||
|
||
export function DefaultPreview({color}: DefaultPreviewProps) { | ||
const background = getCSSBackgroundFromColor(color, ANGLE); | ||
|
||
return ( | ||
<span | ||
className={styles.ColorPreview} | ||
style={{background, height: ICON_SIZE, width: ICON_SIZE}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {DefaultPreview} from './DefaultPreview'; | ||
export type {DefaultPreviewProps} from './DefaultPreview'; |
33 changes: 33 additions & 0 deletions
33
packages/polaris-viz/src/components/DefaultPreview/stories/DefaultPreview.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type {Story} from '@storybook/react'; | ||
import {COLOR_VARIABLES} from '@shopify/polaris-viz-core'; | ||
|
||
export {META as default} from './meta'; | ||
|
||
import type {DefaultPreviewProps} from '../..'; | ||
|
||
import {Template} from './data'; | ||
|
||
export const Solid: Story<DefaultPreviewProps> = Template.bind({}); | ||
|
||
Solid.args = { | ||
color: COLOR_VARIABLES.colorTeal80, | ||
}; | ||
|
||
export const Gradient: Story<DefaultPreviewProps> = Template.bind({}); | ||
|
||
Gradient.args = { | ||
color: [ | ||
{ | ||
color: '#39337f', | ||
offset: 0, | ||
}, | ||
{ | ||
color: '#5052b3', | ||
offset: 50, | ||
}, | ||
{ | ||
color: '#1bbe9e', | ||
offset: 100, | ||
}, | ||
], | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/polaris-viz/src/components/DefaultPreview/stories/data.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type {Story} from '@storybook/react'; | ||
|
||
import type {DefaultPreviewProps} from '../DefaultPreview'; | ||
import {DefaultPreview} from '../DefaultPreview'; | ||
|
||
export const Template: Story<DefaultPreviewProps> = ( | ||
args: DefaultPreviewProps, | ||
) => { | ||
return <DefaultPreview {...args} />; | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/polaris-viz/src/components/DefaultPreview/stories/meta.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type {Meta} from '@storybook/react'; | ||
|
||
import {CONTROLS_ARGS} from '../../../storybook/constants'; | ||
import {DefaultPreview} from '../DefaultPreview'; | ||
|
||
export const META: Meta = { | ||
title: 'Shared/Subcomponents/DefaultPreview', | ||
component: DefaultPreview, | ||
argTypes: { | ||
color: { | ||
description: | ||
'The CSS color or gradient array color to be displayed in the square.', | ||
}, | ||
}, | ||
parameters: { | ||
controls: CONTROLS_ARGS, | ||
docs: { | ||
description: { | ||
component: | ||
'Used to connect chart colors and gradients to information in tooltips and legends.', | ||
}, | ||
}, | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
packages/polaris-viz/src/components/DefaultPreview/tests/DefaultPreview.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {mount} from '@shopify/react-testing'; | ||
|
||
import {DefaultPreview} from '../DefaultPreview'; | ||
|
||
describe('<DefaultPreview/>', () => { | ||
it('renders a div with a background color', () => { | ||
const actual = mount(<DefaultPreview color="rgb(222, 54, 24)" />); | ||
|
||
expect(actual).toContainReactComponent('span', { | ||
style: { | ||
background: 'rgb(222, 54, 24)', | ||
height: 8, | ||
width: 8, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,5 @@ | |
.IconContainer { | ||
display: flex; | ||
align-items: center; | ||
justify-items: center; | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const LEGEND_ITEM_LEFT_PADDING = 8; | ||
export const LEGEND_ITEM_RIGHT_PADDING = 16; | ||
export const LEGEND_ITEM_GAP = 8; | ||
export const LEGEND_ITEM_GAP = 6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters