Repository navigation
Expand file tree
/
Copy pathReactivityExample.tsx
More file actions
64 lines (57 loc) · 1.63 KB
/
Copy pathReactivityExample.tsx
File metadata and controls
64 lines (57 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, { useState } from 'react';
import { Splide, SplideSlide } from '@splidejs/react-splide';
import { generateSlides } from '../utils';
export const ReactivityExample: React.VoidFunctionComponent = () => {
const [ gap, setGap ] = useState( 0 );
const [ perPage, setPerPage ] = useState( 2 );
const [ height, setHeight ] = useState( 10 );
return (
<div className="wrapper">
<h2 id="reactivity-example-heading">Reactivity Example</h2>
<div style={ { marginBottom: '1rem' } }>
<label>
<span>gap:</span>
<input
type="number"
min="0"
max="20"
defaultValue="0"
onChange={ e => setGap( +e.target.value || 0 ) }
/>
px
</label>
<label>
<span>perPage:</span>
<input
type="number"
min="1"
max="5"
defaultValue="2"
onChange={ e => setPerPage( +e.target.value || 2 ) }
/>
</label>
<label>
<span>height:</span>
<input
type="number"
min="5"
max="30"
defaultValue="10"
onChange={ e => setHeight( +e.target.value || 10 ) }
/>
rem
</label>
</div>
<Splide
options={ { perPage, height: `${ height }rem`, gap } }
aria-labelledby="reactivity-example-heading"
>
{ generateSlides().map( slide => (
<SplideSlide key={ slide.src }>
<img src={ slide.src } alt={ slide.alt }/>
</SplideSlide>
) ) }
</Splide>
</div>
);
};