Skip to content

Commit 86060ee

Browse files
committed
SQUASHME: resolve linter warnings
1 parent b56ddb2 commit 86060ee

File tree

2 files changed

+65
-35
lines changed

2 files changed

+65
-35
lines changed

src/stories/CustomArrows.jsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33

4-
const CustomArrows = ({ nextSlide, prevSlide, overrideArrowStyle = {}, infinite, numSlides, selectedIndex, topArrowImage, bottomArrowImage, arrowDivStyle }) => {
4+
const CustomArrows = ({
5+
nextSlide,
6+
prevSlide,
7+
overrideArrowStyle = {},
8+
infinite,
9+
numSlides,
10+
selectedIndex,
11+
topArrowImage,
12+
bottomArrowImage,
13+
arrowDivStyle
14+
}) => {
515
const hasNext = (direction) => {
616
return infinite || (['top', 'left'].includes(direction) ? selectedIndex > 0 : selectedIndex < numSlides - 1);
717
};
@@ -11,10 +21,28 @@ const CustomArrows = ({ nextSlide, prevSlide, overrideArrowStyle = {}, infinite,
1121

1222
return (
1323
<div style={ arrowDivStyle } className='custom-arrows-div'>
14-
<button className='carousel-custom-arrow' disabled={ !hasNextTop } onClick={ hasNextTop ? prevSlide : nextSlide } style={{ ...overrideArrowStyle, ...{ opacity: !hasNextTop ? 0.5 : 1 }, ...{ cursor: !hasNextTop ? 'not-allowed' : 'pointer' } }}>
24+
<button
25+
className='carousel-custom-arrow'
26+
disabled={ !hasNextTop }
27+
onClick={ hasNextTop ? prevSlide : nextSlide }
28+
style={{
29+
...overrideArrowStyle,
30+
opacity: !hasNextTop ? 0.5 : 1,
31+
cursor: !hasNextTop ? 'not-allowed' : 'pointer'
32+
}}
33+
>
1534
{topArrowImage}
1635
</button>
17-
<button className='carousel-custom-arrow' disabled={ !hasNextBottom } onClick={ hasNextBottom ? nextSlide : prevSlide } style={{ ...overrideArrowStyle, ...{ opacity: !hasNextBottom ? 0.5 : 1 }, ...{ cursor: !hasNextBottom ? 'not-allowed' : 'pointer' } }}>
36+
<button
37+
className='carousel-custom-arrow'
38+
disabled={ !hasNextBottom }
39+
onClick={ hasNextBottom ? nextSlide : prevSlide }
40+
style={{
41+
...overrideArrowStyle,
42+
opacity: !hasNextBottom ? 0.5 : 1,
43+
cursor: !hasNextBottom ? 'not-allowed' : 'pointer'
44+
}}
45+
>
1846
{bottomArrowImage}
1947
</button>
2048
</div>

src/stories/index.stories.jsx

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export const InfiniteWithOnly2Slides = {
161161
slideHeight: '300px'
162162
},
163163
render: (args) => (
164-
<Carousel {...args}>
164+
<Carousel { ...args }>
165165
<img src='http://picsum.photos/325/300' alt='A sample' />
166166
<img src='http://picsum.photos/350/300' alt='A sample' />
167167
</Carousel>
@@ -176,7 +176,7 @@ export const InfiniteWithOnly1Slide = {
176176
dots: false
177177
},
178178
render: (args) => (
179-
<Carousel {...args}>
179+
<Carousel { ...args }>
180180
<img src='http://picsum.photos/325/300' alt='A sample' />
181181
</Carousel>
182182
)
@@ -191,7 +191,7 @@ export const AutoplayWithBackgroundImages = {
191191
autoplay: true
192192
},
193193
render: (args) => (
194-
<Carousel {...args}>
194+
<Carousel { ...args }>
195195
<div style={{
196196
backgroundImage: 'url(http://picsum.photos/600/300)',
197197
backgroundSize: 'cover',
@@ -231,7 +231,7 @@ export const BackgroundImagesWithFade = {
231231
arrows: true
232232
},
233233
render: (args) => (
234-
<Carousel {...args}>
234+
<Carousel { ...args }>
235235
<div style={{
236236
backgroundImage: 'url(http://picsum.photos/600/300)',
237237
backgroundSize: 'cover',
@@ -292,35 +292,37 @@ export const CustomDotsComponent = {
292292
}
293293
};
294294

295-
export const AddImages = {
296-
render: () => {
297-
const [images, setImages] = useState([IMAGES[0]]);
295+
const AddImagesComponent = () => {
296+
const [images, setImages] = useState([IMAGES[0]]);
298297

299-
const addImage = () => {
300-
if (images.length < IMAGES.length) {
301-
setImages(images.concat(IMAGES[images.length]));
302-
}
303-
};
298+
const addImage = () => {
299+
if (images.length < IMAGES.length) {
300+
setImages(images.concat(IMAGES[images.length]));
301+
}
302+
};
304303

305-
return (
306-
<Fragment>
307-
<Carousel
308-
width='450px'
309-
cellPadding={ 5 }
310-
infinite={ true }
311-
dots={ false }
312-
arrows={ false }
313-
autoplay={ false }
314-
controls={ [{ component: CustomDots, props: { title: 'My Slides' }, position: 'top' }] }
315-
>
316-
{
317-
images.map((image, index) => <img key={ index } src={ image } alt='A sample' />)
318-
}
319-
</Carousel>
320-
<button onClick={ addImage }>Add Image</button>
321-
</Fragment>
322-
);
323-
}
304+
return (
305+
<Fragment>
306+
<Carousel
307+
width='450px'
308+
cellPadding={ 5 }
309+
infinite={ true }
310+
dots={ false }
311+
arrows={ false }
312+
autoplay={ false }
313+
controls={ [{ component: CustomDots, props: { title: 'My Slides' }, position: 'top' }] }
314+
>
315+
{
316+
images.map((image, index) => <img key={ index } src={ image } alt='A sample' />)
317+
}
318+
</Carousel>
319+
<button onClick={ addImage }>Add Image</button>
320+
</Fragment>
321+
);
322+
};
323+
324+
export const AddImages = {
325+
render: AddImagesComponent
324326
};
325327

326328
export const LeftAlignedSlides = {
@@ -350,7 +352,7 @@ export const Rtl = {
350352
},
351353
render: (args) => (
352354
<div dir='rtl'>
353-
<Carousel {...args} />
355+
<Carousel { ...args } />
354356
</div>
355357
)
356358
};

0 commit comments

Comments
 (0)