@popsure/dirty-swan 0.33.2 → 0.33.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +32 -25
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/modal/bottomModal/index.d.ts +1 -2
- package/dist/cjs/lib/components/modal/bottomOrRegularModal/index.d.ts +1 -2
- package/dist/cjs/lib/components/modal/index.d.ts +3 -3
- package/dist/cjs/lib/components/modal/index.stories.d.ts +62 -0
- package/dist/cjs/lib/components/modal/regularModal/index.d.ts +1 -2
- package/dist/cjs/lib/util/images/index.d.ts +5 -0
- package/dist/esm/components/input/checkbox/index.js +11 -10
- package/dist/esm/components/input/checkbox/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +1 -1
- package/dist/esm/components/modal/bottomModal/index.js +3 -3
- package/dist/esm/components/modal/bottomModal/index.js.map +1 -1
- package/dist/esm/components/modal/bottomOrRegularModal/index.js +5 -5
- package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +1 -1
- package/dist/esm/components/modal/index.stories.js +118 -0
- package/dist/esm/components/modal/index.stories.js.map +1 -0
- package/dist/esm/components/modal/regularModal/index.js +3 -3
- package/dist/esm/components/modal/regularModal/index.js.map +1 -1
- package/dist/esm/index-e81a1766.js +19 -0
- package/dist/esm/index-e81a1766.js.map +1 -0
- package/dist/esm/index.js +4 -4
- package/dist/esm/lib/components/modal/bottomModal/index.d.ts +1 -2
- package/dist/esm/lib/components/modal/bottomOrRegularModal/index.d.ts +1 -2
- package/dist/esm/lib/components/modal/index.d.ts +3 -3
- package/dist/esm/lib/components/modal/index.stories.d.ts +62 -0
- package/dist/esm/lib/components/modal/regularModal/index.d.ts +1 -2
- package/dist/esm/lib/util/images/index.d.ts +5 -0
- package/dist/esm/util/images/index.stories.js +7 -4
- package/dist/esm/util/images/index.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/input/checkbox/index.tsx +2 -2
- package/src/lib/components/input/checkbox/styles.module.scss +8 -0
- package/src/lib/components/modal/bottomModal/index.tsx +1 -1
- package/src/lib/components/modal/bottomOrRegularModal/index.tsx +2 -2
- package/src/lib/components/modal/index.stories.tsx +254 -0
- package/src/lib/components/modal/index.ts +3 -3
- package/src/lib/components/modal/regularModal/index.tsx +1 -1
- package/src/lib/util/images/index.stories.tsx +20 -12
- package/src/lib/util/images/index.ts +16 -9
- package/dist/esm/index-db2e797f.js +0 -13
- package/dist/esm/index-db2e797f.js.map +0 -1
- package/src/lib/components/modal/index.stories.mdx +0 -313
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Meta } from '@storybook/addon-docs/blocks';
|
|
4
|
-
|
|
5
|
-
import { BottomModal, RegularModal, BottomOrRegularModal } from '.';
|
|
6
|
-
|
|
7
|
-
<Meta title="JSX/Modals" />
|
|
8
|
-
|
|
9
|
-
# Modals
|
|
10
|
-
|
|
11
|
-
Modals are dialog overlays that prevent the user from interacting with the rest of the website until an action is taken or the dialog is dismissed. Modals are purposefully disruptive and should be used thoughtfully and sparingly.
|
|
12
|
-
|
|
13
|
-
<Preview>
|
|
14
|
-
<iframe
|
|
15
|
-
width="100%"
|
|
16
|
-
height="450"
|
|
17
|
-
src="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FMKs4cbojdVOBKUxv7okb93%2FDirty-Swan-Design-System%3Fnode-id%3D283%253A1"
|
|
18
|
-
allowFullScreen
|
|
19
|
-
></iframe>
|
|
20
|
-
</Preview>
|
|
21
|
-
|
|
22
|
-
| attribute | unit | description | default value | required |
|
|
23
|
-
| ----------- | --------------------- | -------------------------------------------------------------------------------------- | ------------- | -------- |
|
|
24
|
-
| title | string | The title that needs to be displayed on the modal | n/a | true |
|
|
25
|
-
| isOpen | boolean | When set to `true`, the modal is displayed. When set to `false` the modal gets removed | n/a | true |
|
|
26
|
-
| onClose | `function () => void` | Callback when the user close the modal | n/a | true |
|
|
27
|
-
| children | React.jsx | The content that gets displayed on the modal | n/a | true |
|
|
28
|
-
| className | string | Any additional className | n/a | false |
|
|
29
|
-
| dismissible | boolean | When set to `false` prevents the user from closing the modal | true | false |
|
|
30
|
-
|
|
31
|
-
export const RegularModalStory = () => {
|
|
32
|
-
const [display, setDisplay] = useState(false);
|
|
33
|
-
const toggleOpen = () => setDisplay(!display);
|
|
34
|
-
return (
|
|
35
|
-
<>
|
|
36
|
-
<button
|
|
37
|
-
className="p-btn--primary wmn2"
|
|
38
|
-
onClick={toggleOpen}
|
|
39
|
-
>
|
|
40
|
-
Regular modal
|
|
41
|
-
</button>
|
|
42
|
-
<RegularModal
|
|
43
|
-
title="Regular modal title"
|
|
44
|
-
isOpen={display}
|
|
45
|
-
onClose={toggleOpen}
|
|
46
|
-
>
|
|
47
|
-
<div style={{ padding: '0 24px 24px 24px' }}>
|
|
48
|
-
<p className="p-p">
|
|
49
|
-
This is a regular modal that is mostly meant to be used on desktop.
|
|
50
|
-
Need to use it on mobile? Check my friend BottomModal instead! Not
|
|
51
|
-
sure? Just use BottomOrRegularModal <br /> Do you like this modal?
|
|
52
|
-
Tell us by answering this short survey!
|
|
53
|
-
</p>
|
|
54
|
-
<div className="p-label-container wmx4">
|
|
55
|
-
<input id="bordered-1" className="p-radio" type="radio" />
|
|
56
|
-
<label htmlFor="bordered-1" className="p-label p-label--bordered">
|
|
57
|
-
Yes
|
|
58
|
-
</label>
|
|
59
|
-
<input id="bordered-2" className="p-radio" type="radio" />
|
|
60
|
-
<label
|
|
61
|
-
htmlFor="bordered-2"
|
|
62
|
-
className="p-label p-label--bordered mt16"
|
|
63
|
-
>
|
|
64
|
-
No
|
|
65
|
-
</label>
|
|
66
|
-
</div>
|
|
67
|
-
<button
|
|
68
|
-
className="p-btn--primary mt24 wmn3"
|
|
69
|
-
onClick={() => setDisplay(false)}
|
|
70
|
-
>
|
|
71
|
-
Continue
|
|
72
|
-
</button>
|
|
73
|
-
</div>
|
|
74
|
-
</RegularModal>
|
|
75
|
-
</>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const BottomModalStory = () => {
|
|
80
|
-
const [display, setDisplay] = useState(false);
|
|
81
|
-
return (
|
|
82
|
-
<>
|
|
83
|
-
<button
|
|
84
|
-
className="p-btn--primary wmn2 d-block"
|
|
85
|
-
onClick={() => {
|
|
86
|
-
setDisplay(!display);
|
|
87
|
-
}}
|
|
88
|
-
>
|
|
89
|
-
Bottom modal
|
|
90
|
-
</button>
|
|
91
|
-
<BottomModal
|
|
92
|
-
title="Bottom modal title"
|
|
93
|
-
isOpen={display}
|
|
94
|
-
onClose={() => {
|
|
95
|
-
setDisplay(false);
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
98
|
-
<div style={{ padding: '0 16px 16px 16px' }}>
|
|
99
|
-
<p className="p-p">
|
|
100
|
-
This is a bottom modal that is mostly meant to be used on mobile, do
|
|
101
|
-
you like this modal? Tell us by answering this short survey!
|
|
102
|
-
</p>
|
|
103
|
-
<div className="p-label-container wmx4">
|
|
104
|
-
<input id="bordered-1" className="p-radio" type="radio" />
|
|
105
|
-
<label htmlFor="bordered-1" className="p-label p-label--bordered">
|
|
106
|
-
Yes
|
|
107
|
-
</label>
|
|
108
|
-
<input id="bordered-2" className="p-radio" type="radio" />
|
|
109
|
-
<label
|
|
110
|
-
htmlFor="bordered-2"
|
|
111
|
-
className="p-label p-label--bordered mt16"
|
|
112
|
-
>
|
|
113
|
-
No
|
|
114
|
-
</label>
|
|
115
|
-
</div>
|
|
116
|
-
<button
|
|
117
|
-
className="p-btn--primary mt24 wmn3"
|
|
118
|
-
onClick={() => setDisplay(false)}
|
|
119
|
-
>
|
|
120
|
-
Continue
|
|
121
|
-
</button>
|
|
122
|
-
</div>
|
|
123
|
-
</BottomModal>
|
|
124
|
-
</>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const NonDismissibleModal = () => {
|
|
129
|
-
const [display, setDisplay] = useState(false);
|
|
130
|
-
return (
|
|
131
|
-
<>
|
|
132
|
-
<button
|
|
133
|
-
className="p-btn--primary wmn2"
|
|
134
|
-
onClick={() => {
|
|
135
|
-
setDisplay(!display);
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
Open modal
|
|
139
|
-
</button>
|
|
140
|
-
<RegularModal
|
|
141
|
-
title="Non-dismissible modal title"
|
|
142
|
-
isOpen={display}
|
|
143
|
-
onClose={() => {
|
|
144
|
-
setDisplay(false);
|
|
145
|
-
}}
|
|
146
|
-
dismissible={false}
|
|
147
|
-
>
|
|
148
|
-
<div style={{ padding: '0 24px 24px 24px' }}>
|
|
149
|
-
<p className="p-p">
|
|
150
|
-
This modal requires clear user interaction to dismiss it. The close
|
|
151
|
-
button is hidden, and it cannot be closed using the keyboard nor
|
|
152
|
-
clicking outside.
|
|
153
|
-
</p>
|
|
154
|
-
<button
|
|
155
|
-
className="p-btn--primary bg-red-500 mt24 wmn3"
|
|
156
|
-
onClick={() => setDisplay(false)}
|
|
157
|
-
>
|
|
158
|
-
Reject
|
|
159
|
-
</button>
|
|
160
|
-
<button
|
|
161
|
-
className="p-btn--primary mt24 wmn3 ml16"
|
|
162
|
-
onClick={() => setDisplay(false)}
|
|
163
|
-
>
|
|
164
|
-
Accept
|
|
165
|
-
</button>
|
|
166
|
-
</div>
|
|
167
|
-
</RegularModal>
|
|
168
|
-
</>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
## Regular modal
|
|
173
|
-
|
|
174
|
-
Regular modals are primary meant to be used on Desktop or Tablet environment. The modal will appear in the middle of the screen and the user will be able to dismiss them using the top left "X" icon.
|
|
175
|
-
|
|
176
|
-
If you want to use it for Mobile only, you should check [Bottom modal](##Bottom-modal) instead.
|
|
177
|
-
|
|
178
|
-
Want to use either Regular Modal or Bottom Modal based on the screen width? You can use [Bottom or Regular modal](##Bottom-or-Regular-modal).
|
|
179
|
-
|
|
180
|
-
<RegularModalStory />
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
import React, { useState } from 'react';
|
|
184
|
-
import { BottomModal } from '@popsure/dirty-swan';
|
|
185
|
-
|
|
186
|
-
export default () => {
|
|
187
|
-
const [display, setDisplay] = useState(false);
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<>
|
|
191
|
-
<button
|
|
192
|
-
className="p-btn--primary wmn2 d-block"
|
|
193
|
-
onClick={() => {
|
|
194
|
-
setDisplay(!display);
|
|
195
|
-
}}
|
|
196
|
-
>
|
|
197
|
-
Bottom modal
|
|
198
|
-
</button>
|
|
199
|
-
<BottomModal
|
|
200
|
-
title="Bottom modal title"
|
|
201
|
-
isOpen={display}
|
|
202
|
-
onClose={() => {
|
|
203
|
-
setDisplay(false);
|
|
204
|
-
}}
|
|
205
|
-
>
|
|
206
|
-
<div style={{ padding: '0 16px 16px 16px' }}>
|
|
207
|
-
<p className="p-p">
|
|
208
|
-
This is a bottom modal that is mostly meant to be used on mobile, do
|
|
209
|
-
you like this modal? Tell us by answering this short survey!
|
|
210
|
-
</p>
|
|
211
|
-
<div className="p-label-container wmx4">
|
|
212
|
-
<input id="bordered-1" className="p-radio" type="radio" />
|
|
213
|
-
<label htmlFor="bordered-1" className="p-label p-label--bordered">
|
|
214
|
-
Yes
|
|
215
|
-
</label>
|
|
216
|
-
<input id="bordered-2" className="p-radio" type="radio" />
|
|
217
|
-
<label
|
|
218
|
-
htmlFor="bordered-2"
|
|
219
|
-
className="p-label p-label--bordered mt16"
|
|
220
|
-
>
|
|
221
|
-
No
|
|
222
|
-
</label>
|
|
223
|
-
</div>
|
|
224
|
-
<button
|
|
225
|
-
className="p-btn--primary mt24 wmn3"
|
|
226
|
-
onClick={() => setDisplay(false)}
|
|
227
|
-
>
|
|
228
|
-
Continue
|
|
229
|
-
</button>
|
|
230
|
-
</div>
|
|
231
|
-
</BottomModal>
|
|
232
|
-
</>
|
|
233
|
-
);
|
|
234
|
-
};
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## Bottom modal
|
|
238
|
-
|
|
239
|
-
Regular modals are primary meant to be used on Mobile environment. The modal will appear from the bottom of the screen and the user will be able to dismiss them using the top left "X" icon.
|
|
240
|
-
|
|
241
|
-
If you want to use it for Desktop only, you should check [Regular modal](##Regular-modal) instead.
|
|
242
|
-
|
|
243
|
-
Want to use either Regular Modal or Bottom Modal based on the screen width? You can use [Bottom or Regular modal](##Bottom-or-Regular-modal).
|
|
244
|
-
|
|
245
|
-
<BottomModalStory />
|
|
246
|
-
|
|
247
|
-
```typescript
|
|
248
|
-
import React, { useState } from 'react';
|
|
249
|
-
import { BottomModal } from '@popsure/dirty-swan';
|
|
250
|
-
|
|
251
|
-
export default () => {
|
|
252
|
-
const [display, setDisplay] = useState(false);
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
<>
|
|
256
|
-
<button
|
|
257
|
-
className="p-btn--primary wmn2 d-block"
|
|
258
|
-
onClick={() => {
|
|
259
|
-
setDisplay(!display);
|
|
260
|
-
}}
|
|
261
|
-
>
|
|
262
|
-
Bottom modal
|
|
263
|
-
</button>
|
|
264
|
-
<BottomModal
|
|
265
|
-
title="Bottom modal title"
|
|
266
|
-
isOpen={display}
|
|
267
|
-
onClose={() => {
|
|
268
|
-
setDisplay(false);
|
|
269
|
-
}}
|
|
270
|
-
>
|
|
271
|
-
<div style={{ padding: '0 16px 16px 16px' }}>
|
|
272
|
-
<p className="p-p">
|
|
273
|
-
This is a bottom modal that is mostly meant to be used on mobile, do
|
|
274
|
-
you like this modal? Tell us by answering this short survey!
|
|
275
|
-
</p>
|
|
276
|
-
<div className="p-label-container wmx4">
|
|
277
|
-
<input id="bordered-1" className="p-radio" type="radio" />
|
|
278
|
-
<label htmlFor="bordered-1" className="p-label p-label--bordered">
|
|
279
|
-
Yes
|
|
280
|
-
</label>
|
|
281
|
-
<input id="bordered-2" className="p-radio" type="radio" />
|
|
282
|
-
<label
|
|
283
|
-
htmlFor="bordered-2"
|
|
284
|
-
className="p-label p-label--bordered mt16"
|
|
285
|
-
>
|
|
286
|
-
No
|
|
287
|
-
</label>
|
|
288
|
-
</div>
|
|
289
|
-
<button
|
|
290
|
-
className="p-btn--primary mt24 wmn3"
|
|
291
|
-
onClick={() => setDisplay(false)}
|
|
292
|
-
>
|
|
293
|
-
Continue
|
|
294
|
-
</button>
|
|
295
|
-
</div>
|
|
296
|
-
</BottomModal>
|
|
297
|
-
</>
|
|
298
|
-
);
|
|
299
|
-
};
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
## Bottom or Regular modal
|
|
303
|
-
|
|
304
|
-
Bottom or Regular modal will automatically choose what’s best to display based on the users screen width.
|
|
305
|
-
|
|
306
|
-
## Non-dismissible modal
|
|
307
|
-
|
|
308
|
-
Setting the `dismissible` prop to false will hide the close button and prevent the user from closing it using the escape key or clicking outside.
|
|
309
|
-
This prop can be useful if we want the user to explicitly interact with the modal options.
|
|
310
|
-
|
|
311
|
-
**Warning:** a modal with the `dismissible` prop can only be closed by changing the `isOpen` prop to `false`.
|
|
312
|
-
|
|
313
|
-
<NonDismissibleModal />
|