@indico-data/design-system 2.7.0 → 2.9.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.
Files changed (39) hide show
  1. package/lib/index.css +195 -19
  2. package/lib/index.d.ts +14 -2
  3. package/lib/index.esm.css +195 -19
  4. package/lib/index.esm.js +7 -2
  5. package/lib/index.esm.js.map +1 -1
  6. package/lib/index.js +7 -1
  7. package/lib/index.js.map +1 -1
  8. package/lib/src/components/forms/textarea/Textarea.d.ts +22 -0
  9. package/lib/src/components/forms/textarea/Textarea.stories.d.ts +11 -0
  10. package/lib/src/components/forms/textarea/__tests__/Textarea.test.d.ts +1 -0
  11. package/lib/src/components/forms/textarea/index.d.ts +1 -0
  12. package/lib/src/components/forms/toggle/Toggle.d.ts +12 -0
  13. package/lib/src/components/forms/toggle/Toggle.stories.d.ts +6 -0
  14. package/lib/src/components/forms/toggle/__tests__/Toggle.test.d.ts +1 -0
  15. package/lib/src/components/forms/toggle/index.d.ts +1 -0
  16. package/lib/src/components/index.d.ts +1 -0
  17. package/lib/src/index.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/src/components/forms/checkbox/Checkbox.mdx +6 -1
  20. package/src/components/forms/checkbox/Checkbox.stories.tsx +10 -4
  21. package/src/components/forms/checkbox/Checkbox.tsx +1 -1
  22. package/src/components/forms/checkbox/styles/Checkbox.scss +16 -16
  23. package/src/components/forms/input/Input.stories.tsx +70 -64
  24. package/src/components/forms/input/styles/Input.scss +10 -3
  25. package/src/components/forms/textarea/Textarea.mdx +19 -0
  26. package/src/components/forms/textarea/Textarea.stories.tsx +363 -0
  27. package/src/components/forms/textarea/Textarea.tsx +85 -0
  28. package/src/components/forms/textarea/__tests__/Textarea.test.tsx +103 -0
  29. package/src/components/forms/textarea/index.ts +1 -0
  30. package/src/components/forms/textarea/styles/Textarea.scss +102 -0
  31. package/src/components/forms/toggle/Toggle.mdx +15 -0
  32. package/src/components/forms/toggle/Toggle.stories.tsx +126 -0
  33. package/src/components/forms/toggle/Toggle.tsx +51 -0
  34. package/src/components/forms/toggle/__tests__/Toggle.test.tsx +19 -0
  35. package/src/components/forms/toggle/index.ts +1 -0
  36. package/src/components/forms/toggle/styles/Toggle.scss +72 -0
  37. package/src/components/index.ts +1 -0
  38. package/src/index.ts +1 -0
  39. package/src/styles/index.scss +2 -0
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ export interface TextareaProps {
3
+ ref?: React.LegacyRef<HTMLTextAreaElement>;
4
+ label: string;
5
+ name: string;
6
+ placeholder: string;
7
+ value: string;
8
+ onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
9
+ isRequired?: boolean;
10
+ isDisabled?: boolean;
11
+ errorList?: string[];
12
+ helpText?: string;
13
+ hasHiddenLabel?: boolean;
14
+ rows?: number;
15
+ cols?: number;
16
+ readonly?: boolean;
17
+ wrap?: 'hard' | 'soft';
18
+ form?: string;
19
+ maxLength?: number;
20
+ autofocus?: boolean;
21
+ }
22
+ export declare const Textarea: ({ ref, label, name, placeholder, value, onChange, isRequired, isDisabled, errorList, helpText, hasHiddenLabel, rows, cols, readonly, wrap, form, maxLength, autofocus, ...rest }: TextareaProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Textarea } from './Textarea';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Textarea>;
6
+ export declare const Default: Story;
7
+ export declare const Errors: Story;
8
+ export declare const HiddenLabel: Story;
9
+ export declare const HelpText: Story;
10
+ export declare const Disabled: Story;
11
+ export declare const Readonly: Story;
@@ -0,0 +1 @@
1
+ export { Textarea } from './Textarea';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface ToggleProps {
3
+ ref?: React.LegacyRef<HTMLInputElement>;
4
+ id: string;
5
+ label?: string;
6
+ name: string;
7
+ value?: string;
8
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
9
+ isDisabled?: boolean;
10
+ isChecked?: boolean;
11
+ }
12
+ export declare const Toggle: ({ ref, id, label, name, value, onChange, isDisabled, isChecked, ...rest }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { Toggle } from './Toggle';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Toggle>;
6
+ export declare const Default: Story;
@@ -0,0 +1 @@
1
+ export { Toggle } from './Toggle';
@@ -5,3 +5,4 @@ export { Table } from './table';
5
5
  export { Input } from './forms/input';
6
6
  export { Radio } from './forms/radio';
7
7
  export { Checkbox } from './forms/checkbox';
8
+ export { Toggle } from './forms/toggle';
@@ -10,3 +10,4 @@ export { Table } from './components/table';
10
10
  export { Input } from './components/forms/input';
11
11
  export { Radio as RadioInput } from './components/forms/radio';
12
12
  export { Checkbox } from './components/forms/checkbox';
13
+ export { Toggle as ToggleInput } from './components/forms/toggle';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -8,10 +8,15 @@ This component may be used on it's on or as part of a group. The source code is
8
8
 
9
9
  <Canvas of={Checkbox.Default} source={{
10
10
  code: `
11
+ const [isChecked, setIsChecked] = useState<boolean>(false);
12
+ const handleChange = () => {
13
+ setIsChecked(!isChecked);
14
+ };
15
+
11
16
  <div>
12
17
  <h2 className="mb-2">Checkbox Buttons</h2>
13
18
  <Checkbox
14
- onChange={onChange}
19
+ onChange={handleChange}
15
20
  id={id}
16
21
  label={label}
17
22
  name={name}
@@ -78,7 +78,7 @@ const meta: Meta = {
78
78
  defaultValue: { summary: false },
79
79
  },
80
80
  isChecked: {
81
- control: 'boolean',
81
+ control: false,
82
82
  description: 'Toggles the checked state of the checkbox field when true',
83
83
  table: {
84
84
  category: 'Props',
@@ -111,18 +111,24 @@ export const Default: Story = {
111
111
  isChecked: false,
112
112
  },
113
113
  render: (args) => {
114
+ const [isChecked, setIsChecked] = useState<boolean>(false);
115
+
116
+ const handleChange = () => {
117
+ setIsChecked(!isChecked);
118
+ };
119
+
114
120
  return (
115
121
  <div>
116
- <h2 className="mb-2">Checkbox Buttons</h2>
122
+ <h2 className="mb-2">Checkbox Button</h2>
117
123
  <Checkbox
118
124
  key={args.id}
119
- onChange={args.onChange}
125
+ onChange={handleChange}
120
126
  id={args.id}
121
127
  label={args.label}
122
128
  name={args.name}
123
129
  value={args.value}
124
130
  isDisabled={args.isDisabled}
125
- isChecked={args.isChecked}
131
+ isChecked={isChecked}
126
132
  />
127
133
  </div>
128
134
  );
@@ -28,7 +28,6 @@ export const Checkbox = ({
28
28
  <div className="checkbox-wrapper">
29
29
  <input
30
30
  data-testid={`form-checkbox-input-${name}`}
31
- {...rest}
32
31
  className="checkbox-input"
33
32
  type="checkbox"
34
33
  id={id}
@@ -41,6 +40,7 @@ export const Checkbox = ({
41
40
  tabIndex={0}
42
41
  aria-describedby={id}
43
42
  aria-label={label}
43
+ {...rest}
44
44
  />
45
45
  <label
46
46
  htmlFor={id}
@@ -10,7 +10,7 @@
10
10
 
11
11
  // Dark Theme Specific Variables
12
12
  :root [data-theme='dark'] {
13
- --pf-checkbox-background-color: transparent;
13
+ --pf-checkbox-background-color: var(--pf-primary-color-200);
14
14
  --pf-checkbox-check-color: var(--pf-white-color);
15
15
  --pf-checkbox-border-color: var(--pf-white-color);
16
16
  --pf-checkbox-disabled-color: var(--pf-gray-color-300);
@@ -30,21 +30,21 @@
30
30
  .checkbox-input-label {
31
31
  cursor: pointer;
32
32
  }
33
- [type='checkbox']:checked,
34
- [type='checkbox']:not(:checked) {
33
+ .checkbox-input:checked,
34
+ .checkbox-input:not(:checked) {
35
35
  position: absolute;
36
36
  left: -9999px;
37
37
  }
38
- [type='checkbox']:checked + label,
39
- [type='checkbox']:not(:checked) + label {
38
+ .checkbox-input:checked + label,
39
+ .checkbox-input:not(:checked) + label {
40
40
  position: relative;
41
41
  padding-left: var(--pf-padding-7);
42
42
  cursor: pointer;
43
43
  line-height: 20px;
44
44
  display: inline-block;
45
45
  }
46
- [type='checkbox']:checked + label:before,
47
- [type='checkbox']:not(:checked) + label:before {
46
+ .checkbox-input:checked + label:before,
47
+ .checkbox-input:not(:checked) + label:before {
48
48
  content: '';
49
49
  position: absolute;
50
50
  left: 0;
@@ -55,8 +55,8 @@
55
55
  border-radius: var(--pf-rounded);
56
56
  background: var(--pf-checkbox-background-color);
57
57
  }
58
- [type='checkbox']:checked + label:after,
59
- [type='checkbox']:not(:checked) + label:after {
58
+ .checkbox-input:checked + label:after,
59
+ .checkbox-input:not(:checked) + label:after {
60
60
  content: '';
61
61
  width: 12px;
62
62
  height: 12px;
@@ -68,31 +68,31 @@
68
68
  -webkit-transition: all 0.2s ease;
69
69
  transition: all 0.2s ease;
70
70
  }
71
- [type='checkbox']:not(:checked) + label:after {
71
+ .checkbox-input:not(:checked) + label:after {
72
72
  opacity: 0;
73
73
  -webkit-transform: scale(0);
74
74
  transform: scale(0);
75
75
  }
76
- [type='checkbox']:checked + label:after {
76
+ .checkbox-input:checked + label:after {
77
77
  opacity: 1;
78
78
  -webkit-transform: scale(1);
79
79
  transform: scale(1);
80
80
  }
81
- [type='checkbox']:disabled,
82
- [type='checkbox']:disabled + label {
81
+ .checkbox-input:disabled,
82
+ .checkbox-input:disabled + label {
83
83
  cursor: not-allowed;
84
84
  }
85
85
 
86
- [type='checkbox']:disabled + label {
86
+ .checkbox-input:disabled + label {
87
87
  color: var(--pf-checkbox-disabled-color);
88
88
  opacity: 0.5;
89
89
  }
90
90
 
91
- [type='checkbox']:disabled + label:before {
91
+ .checkbox-input:disabled + label:before {
92
92
  border-color: var(--pf-checkbox-disabled-color);
93
93
  }
94
94
 
95
- [type='checkbox']:disabled + label:after {
95
+ .checkbox-input:disabled + label:after {
96
96
  background: var(--pf-checkbox-disabled-color);
97
97
  }
98
98
  }
@@ -1,6 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { Input, InputProps } from './Input';
3
- import { useState } from 'react';
3
+ import { SetStateAction, useEffect, useState } from 'react';
4
4
  import { iconNames } from 'build/generated/iconTypes';
5
5
 
6
6
  const meta: Meta = {
@@ -174,15 +174,15 @@ export const Default: Story = {
174
174
  },
175
175
  render: (args) => {
176
176
  const [value, setValue] = useState('');
177
- return (
178
- <Input
179
- {...args}
180
- value={value}
181
- onChange={(e) => {
182
- setValue(e.target.value);
183
- }}
184
- />
185
- );
177
+
178
+ useEffect(() => {
179
+ setValue(args.value);
180
+ }, [args.value]);
181
+
182
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
183
+ setValue(e.target.value);
184
+ };
185
+ return <Input {...args} value={value} onChange={handleChange} />;
186
186
  },
187
187
  };
188
188
 
@@ -193,15 +193,16 @@ export const Errors: Story = {
193
193
  },
194
194
  render: (args) => {
195
195
  const [value, setValue] = useState('');
196
- return (
197
- <Input
198
- {...args}
199
- value={value}
200
- onChange={(e) => {
201
- setValue(e.target.value);
202
- }}
203
- />
204
- );
196
+
197
+ useEffect(() => {
198
+ setValue(args.value);
199
+ }, [args.value]);
200
+
201
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
202
+ setValue(e.target.value);
203
+ };
204
+
205
+ return <Input {...args} value={value} onChange={handleChange} />;
205
206
  },
206
207
  };
207
208
 
@@ -212,15 +213,16 @@ export const HiddenLabel: Story = {
212
213
  },
213
214
  render: (args) => {
214
215
  const [value, setValue] = useState('');
215
- return (
216
- <Input
217
- {...args}
218
- value={value}
219
- onChange={(e) => {
220
- setValue(e.target.value);
221
- }}
222
- />
223
- );
216
+
217
+ useEffect(() => {
218
+ setValue(args.value);
219
+ }, [args.value]);
220
+
221
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
222
+ setValue(e.target.value);
223
+ };
224
+
225
+ return <Input {...args} value={value} onChange={handleChange} />;
224
226
  },
225
227
  };
226
228
 
@@ -231,15 +233,16 @@ export const HelpText: Story = {
231
233
  },
232
234
  render: (args) => {
233
235
  const [value, setValue] = useState('');
234
- return (
235
- <Input
236
- {...args}
237
- value={value}
238
- onChange={(e) => {
239
- setValue(e.target.value);
240
- }}
241
- />
242
- );
236
+
237
+ useEffect(() => {
238
+ setValue(args.value);
239
+ }, [args.value]);
240
+
241
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
242
+ setValue(e.target.value);
243
+ };
244
+
245
+ return <Input {...args} value={value} onChange={handleChange} />;
243
246
  },
244
247
  };
245
248
 
@@ -250,15 +253,16 @@ export const Clearable: Story = {
250
253
  },
251
254
  render: (args) => {
252
255
  const [value, setValue] = useState('');
253
- return (
254
- <Input
255
- {...args}
256
- value={value}
257
- onChange={(e) => {
258
- setValue(e.target.value);
259
- }}
260
- />
261
- );
256
+
257
+ useEffect(() => {
258
+ setValue(args.value);
259
+ }, [args.value]);
260
+
261
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
262
+ setValue(e.target.value);
263
+ };
264
+
265
+ return <Input {...args} value={value} onChange={handleChange} />;
262
266
  },
263
267
  };
264
268
 
@@ -269,15 +273,16 @@ export const Icon: Story = {
269
273
  },
270
274
  render: (args) => {
271
275
  const [value, setValue] = useState('');
272
- return (
273
- <Input
274
- {...args}
275
- value={value}
276
- onChange={(e) => {
277
- setValue(e.target.value);
278
- }}
279
- />
280
- );
276
+
277
+ useEffect(() => {
278
+ setValue(args.value);
279
+ }, [args.value]);
280
+
281
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
282
+ setValue(e.target.value);
283
+ };
284
+
285
+ return <Input {...args} value={value} onChange={handleChange} />;
281
286
  },
282
287
  };
283
288
 
@@ -288,14 +293,15 @@ export const Required: Story = {
288
293
  },
289
294
  render: (args) => {
290
295
  const [value, setValue] = useState('');
291
- return (
292
- <Input
293
- {...args}
294
- value={value}
295
- onChange={(e) => {
296
- setValue(e.target.value);
297
- }}
298
- />
299
- );
296
+
297
+ useEffect(() => {
298
+ setValue(args.value);
299
+ }, [args.value]);
300
+
301
+ const handleChange = (e: { target: { value: SetStateAction<string> } }) => {
302
+ setValue(e.target.value);
303
+ };
304
+
305
+ return <Input {...args} value={value} onChange={handleChange} />;
300
306
  },
301
307
  };
@@ -8,6 +8,10 @@
8
8
  --pf-input-text-color: var(--pf-gray-color);
9
9
  --pf-input-placeholder-text-color: var(--pf-gray-color-300);
10
10
  --pf-input-help-text-color: var(--pf-gray-color-400);
11
+ --pf-input-disabled-background-color: var(--pf-gray-color-100);
12
+ --pf-input-border-color: var(--pf-gray-color);
13
+ --pf-input-disabled-color: var(--pf-gray-color-400);
14
+ --pf-input-border-color: var(--pf-gray-color);
11
15
 
12
16
  // input Radius
13
17
  --pf-input-rounded: var(--pf-rounded);
@@ -20,6 +24,9 @@
20
24
  --pf-input-text-color: var(--pf-gray-color-100);
21
25
  --pf-input-placeholder-text-color: var(--pf-gray-color);
22
26
  --pf-input-help-text-color: var(--pf-gray-color-200);
27
+ --pf-input-disabled-background-color: var(--pf-primary-color-200);
28
+ --pf-input-disabled-border-color: var(--pf-gray-color-300);
29
+ --pf-input-disabled-color: var(--pf-gray-color-400);
23
30
  }
24
31
 
25
32
  .input {
@@ -56,9 +63,9 @@
56
63
  }
57
64
 
58
65
  &:disabled {
59
- background-color: var(--pf-gray-color-100);
60
- border-color: var(--pf-gray-color-300);
61
- color: var(--pf-gray-color-400);
66
+ background-color: var(--pf-input-disabled-background-color);
67
+ border-color: var(--pf-input-disabled-border-color);
68
+ color: var(--pf-input-disabled-color);
62
69
  }
63
70
  &--has-icon {
64
71
  padding-left: var(--pf-padding-7);
@@ -0,0 +1,19 @@
1
+ import { Canvas, Meta, Controls } from '@storybook/blocks';
2
+ import * as Textarea from './Textarea.stories';
3
+
4
+ <Meta title="Forms/Textarea" name="Textarea" />
5
+
6
+ # Textarea
7
+
8
+ The Textarea component is the building block of any form. Below you will find the accepted properties for this component. It is encouraged to build forms utilizing [React Hook Form](https://react-hook-form.com/) library in your application. This will facilitate form state management and enforce best practices. (***Our components are compatible with but do not provide the plugin***)
9
+
10
+ <Canvas
11
+ of={Textarea.Default}
12
+ source={{
13
+ code: `
14
+ <Textarea name="first_name" isRequired helpText="This Is Help Text" placeholder="This is a placeholder" value="''" onChange={handleChange} label="Label Name" />
15
+ `,
16
+ }}
17
+ />
18
+
19
+ <Controls of={Textarea.Default} />