-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
1 deletion.
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
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
24 changes: 24 additions & 0 deletions
24
packages/polaris-viz/src/components/DonutChart/stories/playground/AnimationSpeed.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,24 @@ | ||
import type {Story} from '@storybook/react'; | ||
|
||
import {DonutChart, DonutChartProps} from '../../../../components'; | ||
import {META} from '../meta'; | ||
|
||
export default { | ||
...META, | ||
title: `${META.title}/Playground`, | ||
}; | ||
|
||
const Template: Story<DonutChartProps> = (args: DonutChartProps) => { | ||
return <DonutChart {...args} />; | ||
}; | ||
|
||
export const AnimationSpeed = Template.bind({}); | ||
|
||
AnimationSpeed.args = { | ||
data: [...Array(100).keys()].map((num) => { | ||
return { | ||
name: `${num}`, | ||
data: [{key: 'april - march', value: 10}], | ||
}; | ||
}), | ||
}; |
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
10 changes: 10 additions & 0 deletions
10
packages/polaris-viz/src/utilities/getAnimationDelayForItems.ts
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 {DEFAULT_ANIMATION_DELAY} from '../constants'; | ||
|
||
export function getAnimationDelayForItems(count: number) { | ||
const scalingFactor = count * 0.1; | ||
|
||
return Math.min( | ||
DEFAULT_ANIMATION_DELAY / scalingFactor, | ||
DEFAULT_ANIMATION_DELAY, | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/polaris-viz/src/utilities/tests/getAnimationDelayForItems.test.ts
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,14 @@ | ||
import {getAnimationDelayForItems} from '../getAnimationDelayForItems'; | ||
|
||
describe('getAnimationDelayForItems()', () => { | ||
it.each([ | ||
{count: 1, expected: 100}, | ||
{count: 10, expected: 100}, | ||
{count: 50, expected: 20}, | ||
{count: 100, expected: 10}, | ||
{count: 250, expected: 4}, | ||
{count: 1000, expected: 1}, | ||
])('generates a delay for $count items', ({count, expected}) => { | ||
expect(getAnimationDelayForItems(count)).toBe(expected); | ||
}); | ||
}); |