1
1
import React , { Fragment , useState } from 'react' ;
2
+ import PropTypes from 'prop-types' ;
2
3
import Carousel from '../index' ;
3
4
4
5
require ( '../carousel.less' ) ;
@@ -19,7 +20,7 @@ const IMAGES = [
19
20
'http://picsum.photos/325/300'
20
21
] ;
21
22
22
- const imgElements = IMAGES . map ( ( image , index ) => < img src = { image } key = { index } /> ) ;
23
+ const imgElements = IMAGES . map ( ( image , index ) => < img src = { image } key = { index } alt = 'A sample' /> ) ;
23
24
24
25
const CustomDots = ( { numSlides, selectedIndex, goToSlide, title } ) => {
25
26
const dots = [ ] ;
@@ -52,6 +53,13 @@ const CustomDots = ({ numSlides, selectedIndex, goToSlide, title }) => {
52
53
) ;
53
54
} ;
54
55
56
+ CustomDots . propTypes = {
57
+ numSlides : PropTypes . number . isRequired ,
58
+ selectedIndex : PropTypes . number ,
59
+ goToSlide : PropTypes . func . isRequired ,
60
+ title : PropTypes . node
61
+ } ;
62
+
55
63
export const infiniteWithCellPadding = ( ) =>
56
64
< Carousel width = '450px' cellPadding = { 5 } >
57
65
{ imgElements }
@@ -75,8 +83,8 @@ export const fadeTransition = () =>
75
83
76
84
export const infiniteWithOnly2Slides = ( ) =>
77
85
< Carousel width = '450px' arrows = { false } slideHeight = '300px' >
78
- < img src = 'http://picsum.photos/325/300' />
79
- < img src = 'http://picsum.photos/350/300' />
86
+ < img src = 'http://picsum.photos/325/300' alt = 'A sample' />
87
+ < img src = 'http://picsum.photos/350/300' alt = 'A sample' />
80
88
</ Carousel > ;
81
89
82
90
export const infiniteWithOnly1Slide = ( ) =>
@@ -86,7 +94,7 @@ export const infiniteWithOnly1Slide = () =>
86
94
arrows = { false }
87
95
dots = { false }
88
96
>
89
- < img src = 'http://picsum.photos/325/300' />
97
+ < img src = 'http://picsum.photos/325/300' alt = 'A sample' />
90
98
</ Carousel > ;
91
99
92
100
export const autoplayWithBackgroundImages = ( ) =>
@@ -97,10 +105,30 @@ export const autoplayWithBackgroundImages = () =>
97
105
arrows = { false }
98
106
autoplay = { true }
99
107
>
100
- < div style = { { backgroundImage : 'url(http://picsum.photos/600/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
101
- < div style = { { backgroundImage : 'url(http://picsum.photos/650/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
102
- < div style = { { backgroundImage : 'url(http://picsum.photos/675/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
103
- < div style = { { backgroundImage : 'url(http://picsum.photos/700/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
108
+ < div style = { {
109
+ backgroundImage : 'url(http://picsum.photos/600/300)' ,
110
+ backgroundSize : 'cover' ,
111
+ height : '100%' ,
112
+ width : '100%'
113
+ } } />
114
+ < div style = { {
115
+ backgroundImage : 'url(http://picsum.photos/650/300)' ,
116
+ backgroundSize : 'cover' ,
117
+ height : '100%' ,
118
+ width : '100%'
119
+ } } />
120
+ < div style = { {
121
+ backgroundImage : 'url(http://picsum.photos/675/300)' ,
122
+ backgroundSize : 'cover' ,
123
+ height : '100%' ,
124
+ width : '100%'
125
+ } } />
126
+ < div style = { {
127
+ backgroundImage : 'url(http://picsum.photos/700/300)' ,
128
+ backgroundSize : 'cover' ,
129
+ height : '100%' ,
130
+ width : '100%'
131
+ } } />
104
132
</ Carousel > ;
105
133
106
134
export const backgroundImagesWithFade = ( ) =>
@@ -113,13 +141,48 @@ export const backgroundImagesWithFade = () =>
113
141
autoplay = { true }
114
142
arrows = { true }
115
143
>
116
- < div style = { { backgroundImage : 'url(http://picsum.photos/600/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
117
- < div style = { { backgroundImage : 'url(http://picsum.photos/650/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
118
- < div style = { { backgroundImage : 'url(http://picsum.photos/675/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
119
- < div style = { { backgroundImage : 'url(http://picsum.photos/700/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
120
- < div style = { { backgroundImage : 'url(http://picsum.photos/750/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
121
- < div style = { { backgroundImage : 'url(http://picsum.photos/725/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
122
- < div style = { { backgroundImage : 'url(http://picsum.photos/625/300)' , backgroundSize : 'cover' , height : '100%' , width : '100%' } } />
144
+ < div style = { {
145
+ backgroundImage : 'url(http://picsum.photos/600/300)' ,
146
+ backgroundSize : 'cover' ,
147
+ height : '100%' ,
148
+ width : '100%'
149
+ } } />
150
+ < div style = { {
151
+ backgroundImage : 'url(http://picsum.photos/650/300)' ,
152
+ backgroundSize : 'cover' ,
153
+ height : '100%' ,
154
+ width : '100%'
155
+ } } />
156
+ < div style = { {
157
+ backgroundImage : 'url(http://picsum.photos/675/300)' ,
158
+ backgroundSize : 'cover' ,
159
+ height : '100%' ,
160
+ width : '100%'
161
+ } } />
162
+ < div style = { {
163
+ backgroundImage : 'url(http://picsum.photos/700/300)' ,
164
+ backgroundSize : 'cover' ,
165
+ height : '100%' ,
166
+ width : '100%'
167
+ } } />
168
+ < div style = { {
169
+ backgroundImage : 'url(http://picsum.photos/750/300)' ,
170
+ backgroundSize : 'cover' ,
171
+ height : '100%' ,
172
+ width : '100%'
173
+ } } />
174
+ < div style = { {
175
+ backgroundImage : 'url(http://picsum.photos/725/300)' ,
176
+ backgroundSize : 'cover' ,
177
+ height : '100%' ,
178
+ width : '100%'
179
+ } } />
180
+ < div style = { {
181
+ backgroundImage : 'url(http://picsum.photos/625/300)' ,
182
+ backgroundSize : 'cover' ,
183
+ height : '100%' ,
184
+ width : '100%'
185
+ } } />
123
186
</ Carousel > ;
124
187
125
188
export const customDotsComponent = ( ) =>
@@ -157,7 +220,7 @@ export const addImages = () => {
157
220
controls = { [ { component : CustomDots , props : { title : 'My Slides' } , position : 'top' } ] }
158
221
>
159
222
{
160
- images . map ( ( image , index ) => < img key = { index } src = { image } /> )
223
+ images . map ( ( image , index ) => < img key = { index } src = { image } alt = 'A sample' /> )
161
224
}
162
225
</ Carousel >
163
226
< button onClick = { addImage } > Add Image</ button >
0 commit comments