@utrecht/form-field-css 1.0.0 → 1.2.0

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.
@@ -0,0 +1,404 @@
1
+ {/* @license CC0-1.0 */}
2
+
3
+ import { Canvas, Meta, Story } from "@storybook/blocks";
4
+ import { arabicDecorator, argTypes, defaultArgs, exampleArgs, FormFieldTextbox } from "../story-template";
5
+
6
+ export const PlaceholderRTLWarning = () =>
7
+ `Let op: dit is helaas nog niet gelukt om de placeholder automatisch rechts uit te lijnen, wanneer de tekst van de
8
+ placeholder right-to-left is. Op dit moment gebruiken we de volgende class name: utrecht-textbox--placeholder-rtl`;
9
+
10
+ <Meta
11
+ id="css-form-field--textbox"
12
+ title="CSS Component/Form field/with textbox (right-to-left)"
13
+ component={FormFieldTextbox}
14
+ argTypes={argTypes}
15
+ args={defaultArgs}
16
+ parameters={{
17
+ status: {
18
+ type: "WORK IN PROGRESS",
19
+ },
20
+ }}
21
+ />
22
+
23
+ # Textbox in right-to-left script
24
+
25
+ Let op: de labels in dit voorbeeld zijn gemaakt met Google Translate.
26
+
27
+ ## Full name
28
+
29
+ ### Full name (empty)
30
+
31
+ In een _right-to-left_ schrift zoals Arabisch moet de tekst van het label, placeholder en van de invoer meestal rechts uitgelijnd zijn.
32
+
33
+ Sommige invoer is links-naar-rechts, daarom zijn er enkele uitzonderingen:
34
+
35
+ - e-mailadressen
36
+ - website URLs
37
+ - telefoonnummers
38
+ - zoek naar code (kleurocodes, programmeertalen)
39
+
40
+ Gebruik een passend formaat van de textbox, zodat het het rechts uitgelijnde label niet een onnodig grote afstand heeft tot de links uitgelijnde invoer.
41
+
42
+ <Canvas>
43
+ <Story
44
+ name="Full name (empty)"
45
+ args={{
46
+ ...exampleArgs,
47
+ label: "الاسم الكامل",
48
+ autoComplete: "name",
49
+ type: "text",
50
+ dir: "auto",
51
+ id: "5e95c937-e454-4605-a220-a59dd226aebf",
52
+ }}
53
+ decorators={[arabicDecorator]}
54
+ >
55
+ {FormFieldTextbox.bind({})}
56
+ </Story>
57
+ </Canvas>
58
+
59
+ ## Full name
60
+
61
+ ### Full name (right-to-left placeholder)
62
+
63
+ A right-to-left placeholder should be right aligned.
64
+
65
+ {PlaceholderRTLWarning()}
66
+
67
+ <Canvas>
68
+ <Story
69
+ name="Full name (right-to-left placeholder)"
70
+ args={{
71
+ ...exampleArgs,
72
+ label: "الاسم الكامل",
73
+ placeholder: "الاسم الكامل",
74
+ autoComplete: "name",
75
+ type: "text",
76
+ dir: "auto",
77
+ placeholderDir: "rtl",
78
+ id: "a79112b4-26b6-4393-96bd-c514aaac0781",
79
+ }}
80
+ decorators={[arabicDecorator]}
81
+ parameters={{
82
+ status: {
83
+ type: "WORK IN PROGRESS",
84
+ },
85
+ chromatic: { disableSnapshot: true },
86
+ }}
87
+ >
88
+ {FormFieldTextbox.bind({})}
89
+ </Story>
90
+ </Canvas>
91
+
92
+ ### Full name (left-to-right placeholder)
93
+
94
+ A left-to-right placeholder should be left aligned.
95
+
96
+ <Canvas>
97
+ <Story
98
+ name="Full name (left-to-right placeholder)"
99
+ args={{
100
+ ...exampleArgs,
101
+ label: "الاسم الكامل",
102
+ placeholder: "Jane Doe",
103
+ autoComplete: "name",
104
+ type: "text",
105
+ dir: "auto",
106
+ id: "5dfbb67d-699c-47c2-9ec7-ce18d7efe71c",
107
+ }}
108
+ decorators={[arabicDecorator]}
109
+ >
110
+ {FormFieldTextbox.bind({})}
111
+ </Story>
112
+ </Canvas>
113
+
114
+ ### Full name (value)
115
+
116
+ <Canvas>
117
+ <Story
118
+ name="Full name"
119
+ args={{
120
+ ...exampleArgs,
121
+ label: "الاسم الكامل",
122
+ autoComplete: "name",
123
+ type: "text",
124
+ value: "Jan Janssen",
125
+ dir: "auto",
126
+ id: "e341cf11-0666-4ae5-abed-8fe1e2af3bd9",
127
+ }}
128
+ decorators={[arabicDecorator]}
129
+ >
130
+ {FormFieldTextbox.bind({})}
131
+ </Story>
132
+ </Canvas>
133
+
134
+ ## E-mail address
135
+
136
+ ### E-mail address (empty)
137
+
138
+ <Canvas>
139
+ <Story
140
+ name="E-mail address (empty)"
141
+ args={{
142
+ ...exampleArgs,
143
+ label: "بريد إلكتروني",
144
+ type: "email",
145
+ autoComplete: "email",
146
+ dir: "ltr",
147
+ id: "b3b9491b-c32a-4eee-b742-46c14324a417",
148
+ }}
149
+ decorators={[arabicDecorator]}
150
+ >
151
+ {FormFieldTextbox.bind({})}
152
+ </Story>
153
+ </Canvas>
154
+
155
+ ### E-mail address (right-to-left placeholder)
156
+
157
+ Voor een e-mailadres, die _left-to-right_ moet zijn, moet een _right-to-left_ placeholder tekst rechts uitgelijnd zijn.
158
+
159
+ {PlaceholderRTLWarning()}
160
+
161
+ <Canvas>
162
+ <Story
163
+ name="E-mail address (placeholder)"
164
+ args={{
165
+ ...exampleArgs,
166
+ label: "بريد إلكتروني",
167
+ placeholder: "بريد إلكتروني",
168
+ type: "email",
169
+ autoComplete: "email",
170
+ dir: "ltr",
171
+ placeholderDir: "rtl",
172
+ id: "1cede51f-042c-4839-b7a7-e29d8702a16e",
173
+ }}
174
+ decorators={[arabicDecorator]}
175
+ parameters={{
176
+ status: {
177
+ type: "WORK IN PROGRESS",
178
+ },
179
+ chromatic: { disableSnapshot: true },
180
+ }}
181
+ >
182
+ {FormFieldTextbox.bind({})}
183
+ </Story>
184
+ </Canvas>
185
+
186
+ ### E-mail address (left-to-right placeholder)
187
+
188
+ <Canvas>
189
+ <Story
190
+ name="E-mail address (left-to-right placeholder)"
191
+ args={{
192
+ ...exampleArgs,
193
+ label: "بريد إلكتروني",
194
+ placeholder: "info@example.com",
195
+ type: "email",
196
+ autoComplete: "email",
197
+ dir: "ltr",
198
+ id: "5cbdd2ff-6fae-49bf-977d-a5e762618506",
199
+ }}
200
+ decorators={[arabicDecorator]}
201
+ >
202
+ {FormFieldTextbox.bind({})}
203
+ </Story>
204
+ </Canvas>
205
+
206
+ ### E-mail address (value)
207
+
208
+ <Canvas>
209
+ <Story
210
+ name="E-mail address"
211
+ args={{
212
+ ...exampleArgs,
213
+ label: "بريد إلكتروني",
214
+ type: "email",
215
+ autoComplete: "email",
216
+ value: "info@example.com",
217
+ dir: "ltr",
218
+ id: "fece1712-c6ca-4972-b735-0fb5fa705ce7",
219
+ }}
220
+ decorators={[arabicDecorator]}
221
+ >
222
+ {FormFieldTextbox.bind({})}
223
+ </Story>
224
+ </Canvas>
225
+
226
+ ## Website
227
+
228
+ ### Website URL (empty)
229
+
230
+ <Canvas>
231
+ <Story
232
+ name="Website URL (empty)"
233
+ args={{
234
+ ...exampleArgs,
235
+ label: "موقع إلكتروني",
236
+ type: "url",
237
+ autoComplete: "url",
238
+ dir: "ltr",
239
+ id: "b3b9491b-c32a-4eee-b742-46c14324a417",
240
+ }}
241
+ decorators={[arabicDecorator]}
242
+ >
243
+ {FormFieldTextbox.bind({})}
244
+ </Story>
245
+ </Canvas>
246
+
247
+ ### Website URL (right-to-left placeholder)
248
+
249
+ {PlaceholderRTLWarning()}
250
+
251
+ <Canvas>
252
+ <Story
253
+ name="Website URL (placeholder)"
254
+ args={{
255
+ ...exampleArgs,
256
+ label: "موقع إلكتروني",
257
+ placeholder: "موقع إلكتروني",
258
+ type: "url",
259
+ autoComplete: "email",
260
+ dir: "ltr",
261
+ placeholderDir: "rtl",
262
+ id: "1cede51f-042c-4839-b7a7-e29d8702a16e",
263
+ }}
264
+ decorators={[arabicDecorator]}
265
+ parameters={{
266
+ status: {
267
+ type: "WORK IN PROGRESS",
268
+ },
269
+ chromatic: { disableSnapshot: true },
270
+ }}
271
+ >
272
+ {FormFieldTextbox.bind({})}
273
+ </Story>
274
+ </Canvas>
275
+
276
+ ### Website URL (left-to-right placeholder)
277
+
278
+ <Canvas>
279
+ <Story
280
+ name="Website URL (left-to-right placeholder)"
281
+ args={{
282
+ ...exampleArgs,
283
+ label: "موقع إلكتروني",
284
+ placeholder: "https://example.com/",
285
+ type: "url",
286
+ autoComplete: "email",
287
+ dir: "ltr",
288
+ id: "5cbdd2ff-6fae-49bf-977d-a5e762618506",
289
+ }}
290
+ decorators={[arabicDecorator]}
291
+ >
292
+ {FormFieldTextbox.bind({})}
293
+ </Story>
294
+ </Canvas>
295
+
296
+ ### Website URL (value)
297
+
298
+ <Canvas>
299
+ <Story
300
+ name="Website URL"
301
+ args={{
302
+ ...exampleArgs,
303
+ label: "موقع إلكتروني",
304
+ type: "url",
305
+ autoComplete: "email",
306
+ value: "https://example.com/",
307
+ dir: "ltr",
308
+ id: "fece1712-c6ca-4972-b735-0fb5fa705ce7",
309
+ }}
310
+ decorators={[arabicDecorator]}
311
+ >
312
+ {FormFieldTextbox.bind({})}
313
+ </Story>
314
+ </Canvas>
315
+
316
+ ## Mobile phone number
317
+
318
+ ### Mobile phone number (empty)
319
+
320
+ <Canvas>
321
+ <Story
322
+ name="Mobile phone number (empty)"
323
+ args={{
324
+ ...exampleArgs,
325
+ label: "رقم الهاتف المحمول",
326
+ type: "tel",
327
+ autoComplete: "mobile tel",
328
+ dir: "ltr",
329
+ id: "8f455e89-85be-4911-ad05-b666a8cc2ff7",
330
+ }}
331
+ decorators={[arabicDecorator]}
332
+ >
333
+ {FormFieldTextbox.bind({})}
334
+ </Story>
335
+ </Canvas>
336
+
337
+ ### Mobile phone number (right-to-left placeholder)
338
+
339
+ {PlaceholderRTLWarning()}
340
+
341
+ <Canvas>
342
+ <Story
343
+ name="Mobile phone number (right-to-left placeholder)"
344
+ args={{
345
+ ...exampleArgs,
346
+ label: "رقم الهاتف المحمول",
347
+ placeholder: "رقم الهاتف المحمول",
348
+ type: "tel",
349
+ autoComplete: "mobile tel",
350
+ dir: "ltr",
351
+ id: "73c41136-aecf-421d-9f06-16caf39b09e7",
352
+ placeholderDir: "rtl",
353
+ }}
354
+ decorators={[arabicDecorator]}
355
+ parameters={{
356
+ status: {
357
+ type: "WORK IN PROGRESS",
358
+ },
359
+ chromatic: { disableSnapshot: true },
360
+ }}
361
+ >
362
+ {FormFieldTextbox.bind({})}
363
+ </Story>
364
+ </Canvas>
365
+
366
+ ### Mobile phone number (left-to-right placeholder)
367
+
368
+ <Canvas>
369
+ <Story
370
+ name="Mobile phone number (left-to-right placeholder)"
371
+ args={{
372
+ ...exampleArgs,
373
+ label: "رقم الهاتف المحمول",
374
+ placeholder: "+1 555 1234",
375
+ type: "tel",
376
+ autoComplete: "mobile tel",
377
+ dir: "ltr",
378
+ id: "785ba9e3-6bab-4155-9ae6-6d0af71f7479",
379
+ }}
380
+ decorators={[arabicDecorator]}
381
+ >
382
+ {FormFieldTextbox.bind({})}
383
+ </Story>
384
+ </Canvas>
385
+
386
+ ### Mobile phone number (value)
387
+
388
+ <Canvas>
389
+ <Story
390
+ name="Mobile phone number"
391
+ args={{
392
+ ...exampleArgs,
393
+ label: "رقم الهاتف المحمول",
394
+ type: "tel",
395
+ autoComplete: "mobile tel",
396
+ value: "+31 6 1234 5678",
397
+ dir: "ltr",
398
+ id: "c155f4b2-9d08-4690-8639-a4059929dba9",
399
+ }}
400
+ decorators={[arabicDecorator]}
401
+ >
402
+ {FormFieldTextbox.bind({})}
403
+ </Story>
404
+ </Canvas>
@@ -0,0 +1,128 @@
1
+ {/* @license CC0-1.0 */}
2
+
3
+ import { Canvas, Meta, Story } from "@storybook/blocks";
4
+ import { Textarea } from "../../../textarea/src/story-template";
5
+ import { argTypes, defaultArgs, exampleArgs, FormFieldTextbox } from "../story-template";
6
+
7
+ <Meta
8
+ id="css-form-field--textbox"
9
+ title="CSS Component/Form field/with textbox"
10
+ component={FormFieldTextbox}
11
+ argTypes={argTypes}
12
+ args={defaultArgs}
13
+ parameters={{
14
+ status: {
15
+ type: "WORK IN PROGRESS",
16
+ },
17
+ }}
18
+ />
19
+
20
+ ## label
21
+
22
+ <Canvas>
23
+ <Story
24
+ name="label"
25
+ args={{
26
+ ...exampleArgs,
27
+ id: "172cd71b-8854-41ee-bcdc-9c8ac856c5d1",
28
+ }}
29
+ >
30
+ {FormFieldTextbox.bind({})}
31
+ </Story>
32
+ </Canvas>
33
+
34
+ ## Heading as label
35
+
36
+ <Canvas>
37
+ <Story
38
+ name="Heading as label"
39
+ args={{
40
+ ...exampleArgs,
41
+ id: "5657eb52-c943-4106-85dd-9a3926a9155a",
42
+ headingLevel: 1,
43
+ }}
44
+ >
45
+ {FormFieldTextbox.bind({})}
46
+ </Story>
47
+ </Canvas>
48
+
49
+ # Form field with description
50
+
51
+ <Canvas>
52
+ <Story
53
+ name="description"
54
+ args={{
55
+ ...exampleArgs,
56
+ id: "c2d1cc9c-4ec4-4806-8fc7-caa66fc4986a",
57
+ description: "Do not use any emoji characters.",
58
+ }}
59
+ >
60
+ {FormFieldTextbox.bind({})}
61
+ </Story>
62
+ </Canvas>
63
+
64
+ # invalid
65
+
66
+ <Canvas>
67
+ <Story
68
+ name="invalid"
69
+ args={{
70
+ ...exampleArgs,
71
+ value: "I ❤️ NY",
72
+ id: "5da58629-c3d5-4fad-bb7c-eca1f8df972e",
73
+ description: "Do not use any emoji characters.",
74
+ invalid: true,
75
+ invalidDescription: "Remove the emoji characters from the subject.",
76
+ }}
77
+ >
78
+ {FormFieldTextbox.bind({})}
79
+ </Story>
80
+ </Canvas>
81
+
82
+ ## Rich text description
83
+
84
+ <Canvas>
85
+ <Story
86
+ name="Rich text description"
87
+ args={{
88
+ ...exampleArgs,
89
+ id: "fb436ace-88ff-4a38-b7ca-b03bbf43a7c0",
90
+ description: (
91
+ <>
92
+ <p className="utrecht-paragraph">Your new password needs to meet these requirements:</p>
93
+ <ul className="utrecht-unordered-list">
94
+ <li>At least 1 character</li>
95
+ <li>No more than 2 characters</li>
96
+ <li>Use at least one uppercase letter and one lowercase letter.</li>
97
+ </ul>
98
+ </>
99
+ ),
100
+ invalidDescription: (
101
+ <>
102
+ <p className="utrecht-paragraph">Your new password does not meet these requirements:</p>
103
+ <ul className="utrecht-unordered-list">
104
+ <li>Your password is too long.</li>
105
+ <li>Use at least one uppercase letter.</li>
106
+ </ul>
107
+ </>
108
+ ),
109
+ }}
110
+ >
111
+ {FormFieldTextbox.bind({})}
112
+ </Story>
113
+ </Canvas>
114
+
115
+ ## Textarea
116
+
117
+ <Canvas>
118
+ <Story
119
+ name="Textarea"
120
+ args={{
121
+ ...exampleArgs,
122
+ id: "93051d49-ac02-4a15-b5a2-b424eccb35d6",
123
+ component: Textarea,
124
+ }}
125
+ >
126
+ {FormFieldTextbox.bind({})}
127
+ </Story>
128
+ </Canvas>