-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy path2-Events.stories.js
99 lines (91 loc) · 2.46 KB
/
2-Events.stories.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React from 'react';
import { useState } from 'react';
import SelectSearch from '../src';
import '../style.css';
export default {
title: 'Events',
};
export const OnChange = () => {
const [size, setSize] = useState('s');
const style = {
fontFamily: '"Nunito Sans", sans-serif',
marginTop: '24px',
};
if (size === 's') {
style.fontSize = '16px';
} else if (size === 'm') {
style.fontSize = '32px';
}
if (size === 'l') {
style.fontSize = '64px';
}
return (
<>
<SelectSearch
value={size}
onChange={setSize}
placeholder="Select font size"
options={[
{ value: 's', name: 'Small' },
{ value: 'm', name: 'Medium' },
{ value: 'l', name: 'Large' },
]}
/>
<h1 style={style}>Aa</h1>
</>
);
};
export const ControlledValue = () => {
const [size, setSize] = useState(null);
const style = {
fontFamily: '"Nunito Sans", sans-serif',
marginTop: '16px',
};
const button = {
marginTop: '16px',
display: 'inline-flex',
position: 'relative',
alignItems: 'center',
height: '40px',
padding: '0 16px',
borderRadius: '3px',
border: 'none',
background: 'rgb(49, 173, 122)',
color: '#fff',
fontSize: '16px',
cursor: 'pointer',
outline: 'none',
};
const buttonTwo = {
...button,
background: 'transparent',
border: '2px solid #888',
color: '#888',
marginLeft: '8px',
};
return (
<>
<SelectSearch
onChange={setSize}
value={size}
placeholder="Select size"
options={[
{ value: 'small', name: 'Small' },
{ value: 'medium', name: 'Medium' },
{ value: 'large', name: 'Large' },
]}
/>
<p style={style}>You have selected: {size}</p>
<button type="button" style={button} onClick={() => setSize(null)}>
Click to reset
</button>
<button
type="button"
style={buttonTwo}
onClick={() => setSize('medium')}
>
Set medium
</button>
</>
);
};