This repository was archived by the owner on Jun 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Use gradients and subduing in MultiSeriesBarChart #311
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0f244bd
Remove <Bar> duplication, remove highlight color
krystalcampioni 431a17c
use mask and gradients in grouped bar chart
krystalcampioni 02720c3
allow gradients and solid colors on stacked bar chart'
krystalcampioni 09c91d5
prevent focusing on aria hidden items
krystalcampioni ad338b6
update tests and types
krystalcampioni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 +1,7 @@ | ||
| @import 'node_modules/@shopify/polaris-tokens/dist/index'; | ||
| @import '../../styles/common'; | ||
|
|
||
| .BarNoOutline { | ||
| .Bar { | ||
| @include no-outline; | ||
| transition: fill $duration-fast ease; | ||
| transition: fill $duration-slow ease; | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,133 +3,93 @@ import {mount} from '@shopify/react-testing'; | |
| import {scaleBand} from 'd3-scale'; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as mentioned above, just moving the Bar from |
||
|
|
||
| import {Bar} from '../Bar'; | ||
| import {MASK_HIGHLIGHT_COLOR} from '../../../constants'; | ||
|
|
||
| jest.mock('d3-scale', () => ({ | ||
| scaleBand: jest.fn(() => jest.fn((value) => value)), | ||
| })); | ||
|
|
||
| const defaultProps = { | ||
| height: 1000, | ||
| color: MASK_HIGHLIGHT_COLOR, | ||
| isSelected: false, | ||
| x: 0, | ||
| rawValue: 1000, | ||
| width: 100, | ||
| yScale: scaleBand() as any, | ||
| index: 1, | ||
| onFocus: jest.fn(), | ||
| tabIndex: 0, | ||
| }; | ||
|
|
||
| describe('<Bar/>', () => { | ||
| it('renders a path', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar | ||
| height={1000} | ||
| color="colorPurple" | ||
| highlightColor="colorPurple" | ||
| isSelected={false} | ||
| x={0} | ||
| rawValue={1000} | ||
| width={100} | ||
| yScale={scaleBand() as any} | ||
| index={1} | ||
| onFocus={jest.fn()} | ||
| tabIndex={0} | ||
| /> | ||
| , | ||
| </svg>, | ||
| ); | ||
| describe('hasRoundedCorners', () => { | ||
| it('renders sharp corners if false', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar {...defaultProps} hasRoundedCorners={false} />, | ||
| </svg>, | ||
| ); | ||
|
|
||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: `M0 0 | ||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: `M0 0 | ||
| h100 | ||
| a0 0 0 010 0 | ||
| v1000 | ||
| H0 | ||
| V0 | ||
| a0 0 0 010-0 | ||
| Z`, | ||
| fill: 'rgb(156, 106, 222)', | ||
| style: {transform: 'translate(0px, -1000px) rotate(0deg)'}, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('rounds the corners if hasRoundedCorners is true', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar | ||
| height={1000} | ||
| color="colorPurple" | ||
| highlightColor="colorPurple" | ||
| isSelected={false} | ||
| x={0} | ||
| rawValue={1000} | ||
| width={100} | ||
| yScale={scaleBand() as any} | ||
| index={1} | ||
| onFocus={jest.fn()} | ||
| tabIndex={0} | ||
| hasRoundedCorners | ||
| /> | ||
| , | ||
| </svg>, | ||
| ); | ||
| it('rounds the corners if true', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar {...defaultProps} hasRoundedCorners />, | ||
| </svg>, | ||
| ); | ||
|
|
||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: `M3 0 | ||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: `M3 0 | ||
| h94 | ||
| a3 3 0 013 3 | ||
| v997 | ||
| H0 | ||
| V3 | ||
| a3 3 0 013-3 | ||
| Z`, | ||
| fill: 'rgb(156, 106, 222)', | ||
| style: {transform: 'translate(0px, -1000px) rotate(0deg)'}, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('gives a 0 value an empty path d attribute and 0 height', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar | ||
| height={0} | ||
| color="colorPurple" | ||
| highlightColor="colorPurple" | ||
| isSelected={false} | ||
| x={0} | ||
| rawValue={0} | ||
| width={100} | ||
| yScale={scaleBand() as any} | ||
| index={1} | ||
| onFocus={jest.fn()} | ||
| tabIndex={0} | ||
| /> | ||
| , | ||
| </svg>, | ||
| ); | ||
| describe('rawValue', () => { | ||
| it('gives a 0 value an empty path d attribute and 0 height', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar {...defaultProps} rawValue={0} />, | ||
| </svg>, | ||
| ); | ||
|
|
||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: ``, | ||
| fill: 'rgb(156, 106, 222)', | ||
| style: {transform: `translate(0px, 0px) rotate(0deg)`}, | ||
| expect(bar).toContainReactComponent('path', { | ||
| // eslint-disable-next-line id-length | ||
| d: ``, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('uses the primary color when the bar is not selected', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar | ||
| height={1000} | ||
| color="colorPurple" | ||
| highlightColor="colorRed" | ||
| isSelected={false} | ||
| x={0} | ||
| rawValue={1} | ||
| width={100} | ||
| yScale={scaleBand() as any} | ||
| index={1} | ||
| onFocus={jest.fn()} | ||
| tabIndex={0} | ||
| /> | ||
| , | ||
| </svg>, | ||
| ); | ||
| describe('color', () => { | ||
| it('gets passed to the underlying path', () => { | ||
| const bar = mount( | ||
| <svg> | ||
| <Bar {...defaultProps} color="rgb(156, 106, 222)" />, | ||
| </svg>, | ||
| ); | ||
|
|
||
| expect(bar).toContainReactComponent('path', { | ||
| fill: 'rgb(156, 106, 222)', | ||
| expect(bar).toContainReactComponent('path', { | ||
| fill: 'rgb(156, 106, 222)', | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same component that lived in
BarChart/components. I've just moved it up, since all Bars now use the same API