Skip to content

Commit

Permalink
feat(plasma-web, plasma-b2c): Added isDragScrollDisabled property to …
Browse files Browse the repository at this point in the history
…control panel
  • Loading branch information
shuga2704 committed Dec 27, 2023
1 parent df6463f commit 4a98dfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const meta: Meta<typeof Carousel> = {
type: 'inline-radio',
},
},
isDragScrollDisabled: {
control: 'boolean',
},
...disableProps([
'onScroll',
'index',
Expand Down Expand Up @@ -88,7 +91,7 @@ const defaultCarouselStyle = { margin: '0 -0.5rem' };

const defaultCarouselItemStyle = { width: 550, padding: '0 0.5rem' };

const StoryDefault = ({ align }: { align: alignType }) => {
const StoryDefault = ({ align, isDragScrollDisabled }: { align: alignType; isDragScrollDisabled: boolean }) => {
const [index, setIndex] = useState(0);

const changeIndexDown = useCallback(() => {
Expand All @@ -107,6 +110,7 @@ const StoryDefault = ({ align }: { align: alignType }) => {
detectActive
onIndexChange={setIndex}
scrollAlign={align}
isDragScrollDisabled={isDragScrollDisabled}
>
{items.map((item) => (
<CarouselItem key={item.id} style={defaultCarouselItemStyle} scrollSnapAlign={align}>
Expand All @@ -130,9 +134,10 @@ const StoryDefault = ({ align }: { align: alignType }) => {
);
};

export const Default: StoryObj<{ align: alignType }> = {
export const Default: StoryObj<{ align: alignType; isDragScrollDisabled: boolean }> = {
args: {
align: 'center',
isDragScrollDisabled: false,
},
render: (args) => <StoryDefault {...args} />,
};
10 changes: 8 additions & 2 deletions packages/plasma-web/src/components/Carousel/Carousel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ const defaultCarouselItemStyle = { width: '20rem', padding: '0 0.5rem' };
export const Default: StoryObj<CarouselProps> = {
args: {
scrollAlign: 'start',
isDragScrollDisabled: false,
},
render: ({ scrollAlign }) => {
render: ({ scrollAlign, isDragScrollDisabled }) => {
return (
<Carousel index={0} style={defaultCarouselStyle} scrollAlign={scrollAlign}>
<Carousel
index={0}
style={defaultCarouselStyle}
scrollAlign={scrollAlign}
isDragScrollDisabled={isDragScrollDisabled}
>
{items.map((item) => (
<CarouselItem key={item.id} style={defaultCarouselItemStyle} scrollSnapAlign={scrollAlign}>
<CarouselCard
Expand Down

0 comments on commit 4a98dfe

Please sign in to comment.