Skip to content

Commit

Permalink
refactor(Slider): migrate CSF3
Browse files Browse the repository at this point in the history
  • Loading branch information
itwillwork committed May 23, 2024
1 parent 3345489 commit 7eb6a22
Show file tree
Hide file tree
Showing 63 changed files with 252 additions and 143 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 149 additions & 6 deletions src/components/Slider/__stories__/Slider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';

import {action} from '@storybook/addon-actions';
import {useArgs} from '@storybook/preview-api';
import type {Meta, StoryObj} from '@storybook/react';

import {Showcase} from '../../../demo/Showcase';
import {ShowcaseItem} from '../../../demo/ShowcaseItem';
import {Slider} from '../Slider';

import {SliderShowcase} from './SliderShowcase';
import type {SliderProps, SliderValue} from '../types';

type Story = StoryObj<typeof Slider>;

Expand All @@ -14,6 +17,21 @@ export default {
args: {
'aria-label': 'Example slider field',
},
decorators: [
function useTextValue(Story, ctx) {
const [, setArgs] = useArgs<typeof ctx.args>();

const handleUpdate = (value: SliderValue) => {
if (ctx.args.value !== undefined) {
setArgs({
value,
});
}
};

return <Story args={{...ctx.args, onUpdate: handleUpdate}} />;
},
],
parameters: {
a11y: {
element: '#storybook-root',
Expand All @@ -29,10 +47,135 @@ export default {
},
} as Meta<typeof Slider>;

export const Default: Story = {};
export const Default: Story = {
args: {
value: 20,
min: 0,
max: 100,
step: 1,
onFocus: action('onFocus'),
onBlur: action('onBlur'),
onUpdate: action('onUpdate'),
onUpdateComplete: action('onUpdateComplete'),
},
};

export const Showcase: Story = {
render: (args) => {
return <SliderShowcase {...args} />;
export const DefaultRange: Story = {
args: {
...Default.args,
value: [20, 80],
},
name: 'Default (for range value)',
};

const sizeCases: Array<NonNullable<SliderProps['size']>> = ['s', 'm', 'l', 'xl'];

export const Size: Story = {
render: (args) => (
<Showcase isVertical>
{sizeCases.map((size, index) => (
<ShowcaseItem title={size} key={index}>
<Slider {...args} size={size} />
</ShowcaseItem>
))}
</Showcase>
),
args: {
...Default.args,
},
};

export const SizeRange: Story = {
render: (args) => (
<Showcase isVertical>
{sizeCases.map((size, index) => (
<ShowcaseItem title={size} key={index}>
<Slider {...args} size={size} />
</ShowcaseItem>
))}
</Showcase>
),
args: {
...DefaultRange.args,
},
name: 'Size (for range value)',
};

export const Disabled: Story = {
args: {
...Default.args,
disabled: true,
},
};

export const DisabledRange: Story = {
args: {
...DefaultRange.args,
disabled: true,
},
name: 'Disabled (for range value)',
};

export const Error: Story = {
args: {
...Default.args,
errorMessage: 'Error message',
validationState: 'invalid',
},
};

export const ErrorRange: Story = {
args: {
...DefaultRange.args,
errorMessage: 'Error message',
validationState: 'invalid',
},
name: 'Error (for range value)',
};

export const Tooltip: Story = {
args: {
...Default.args,
hasTooltip: true,
},
};

export const TooltipRange: Story = {
args: {
...DefaultRange.args,
hasTooltip: true,
},
name: 'Tooltip (for range value)',
};

export const MarksCount: Story = {
args: {
...Default.args,
marksCount: 11,
},
name: 'Marks count',
};

export const MarksCountRange: Story = {
args: {
...DefaultRange.args,
marksCount: 11,
},
name: 'Marks count (for range value)',
};

export const AvailableValues: Story = {
args: {
...Default.args,
availableValues: [10, 20, 50, 55, 65, 80],
},
name: 'Available values',
};

export const AvailableValuesRange: Story = {
args: {
...DefaultRange.args,
availableValues: [10, 20, 50, 55, 65, 80],
},
name: 'Available values (for range value)',
};
23 changes: 0 additions & 23 deletions src/components/Slider/__stories__/SliderShowcase.scss

This file was deleted.

112 changes: 0 additions & 112 deletions src/components/Slider/__stories__/SliderShowcase.tsx

This file was deleted.

Loading

0 comments on commit 7eb6a22

Please sign in to comment.