Skip to content

Commit

Permalink
Remove random page story to prevent chromatic problems
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot committed Apr 8, 2024
1 parent 67e5fee commit 4184caf
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions packages/nuka/src/Carousel/Carousel.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { Meta, StoryObj } from '@storybook/react';
import { useRef, useState } from 'react';
import { useRef } from 'react';

import { Carousel, CarouselProps, SlideHandle } from './Carousel';
import { Carousel } from './Carousel';
import {
ExampleSlide,
FocusableLinkSlide,
FullWidthSlide,
} from './ExampleSlide';

import './CarouselStories.css';
import { CarouselProps, SlideHandle } from '../types';

const StorybookComponent = (props: CarouselProps) => {
const ref = useRef<SlideHandle>(null);
Expand Down Expand Up @@ -115,11 +116,6 @@ export const PageIndicators: Story = {
args: {
scrollDistance: 'screen',
showDots: true,
pageIndicatorProps: {
currentPageIndicatorClassName: 'indicator__current',
pageIndicatorClassName: 'indicator',
containerClassName: 'indicator-container',
},
children: (
<>
{[...Array(10)].map((_, index) => (
Expand All @@ -142,30 +138,26 @@ export const FocusableCards: Story = {
},
};

const CustomGoToIndexRenderComponent = (props: CarouselProps) => {
const CustomGoToPageRenderComponent = (props: CarouselProps) => {
const ref = useRef<SlideHandle>(null);
const [randomInRangeIndex, setRandomInRangeIndex] = useState(
Math.floor(Math.random() * 7),
);
return (
<div>
<button
onClick={() => {
if (ref.current) {
ref.current.goToIndex(randomInRangeIndex);
setRandomInRangeIndex(Math.floor(Math.random() * 7));
ref.current.goToPage(2);
}
}}
>
Go to Random Index {randomInRangeIndex}
Go to Page 2
</button>
<Carousel ref={ref} {...props} />
</div>
);
};

export const GoToIndex: Story = {
render: CustomGoToIndexRenderComponent,
export const GoToPage: Story = {
render: CustomGoToPageRenderComponent,
args: {
children: (
<>
Expand Down

0 comments on commit 4184caf

Please sign in to comment.