@arbor-education/design-system.components 0.2.3 → 0.2.5

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 (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/card/Card.d.ts +4 -4
  3. package/dist/components/card/Card.d.ts.map +1 -1
  4. package/dist/components/card/Card.js +3 -3
  5. package/dist/components/card/Card.js.map +1 -1
  6. package/dist/components/card/Card.test.js +2 -2
  7. package/dist/components/card/Card.test.js.map +1 -1
  8. package/dist/components/pill/Pill.d.ts +3 -3
  9. package/dist/components/pill/Pill.d.ts.map +1 -1
  10. package/dist/components/pill/Pill.js +18 -3
  11. package/dist/components/pill/Pill.js.map +1 -1
  12. package/dist/components/pill/Pill.stories.d.ts +11 -1
  13. package/dist/components/pill/Pill.stories.d.ts.map +1 -1
  14. package/dist/components/pill/Pill.stories.js +11 -1
  15. package/dist/components/pill/Pill.stories.js.map +1 -1
  16. package/dist/components/pill/Pill.test.d.ts.map +1 -1
  17. package/dist/components/pill/Pill.test.js +47 -11
  18. package/dist/components/pill/Pill.test.js.map +1 -1
  19. package/dist/components/table/Table.stories.d.ts +2 -0
  20. package/dist/components/table/Table.stories.d.ts.map +1 -1
  21. package/dist/components/table/Table.stories.js +112 -1
  22. package/dist/components/table/Table.stories.js.map +1 -1
  23. package/dist/components/tag/Tag.d.ts +8 -0
  24. package/dist/components/tag/Tag.d.ts.map +1 -0
  25. package/dist/components/tag/Tag.js +6 -0
  26. package/dist/components/tag/Tag.js.map +1 -0
  27. package/dist/components/tag/Tag.stories.d.ts +8 -0
  28. package/dist/components/tag/Tag.stories.d.ts.map +1 -0
  29. package/dist/components/tag/Tag.stories.js +10 -0
  30. package/dist/components/tag/Tag.stories.js.map +1 -0
  31. package/dist/components/tag/Tag.test.d.ts +2 -0
  32. package/dist/components/tag/Tag.test.d.ts.map +1 -0
  33. package/dist/components/tag/Tag.test.js +20 -0
  34. package/dist/components/tag/Tag.test.js.map +1 -0
  35. package/dist/index.css +60 -8
  36. package/dist/index.css.map +1 -1
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -0
  40. package/dist/index.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/components/card/Card.test.tsx +3 -3
  43. package/src/components/card/Card.tsx +6 -6
  44. package/src/components/pill/Pill.stories.tsx +10 -0
  45. package/src/components/pill/Pill.test.tsx +50 -11
  46. package/src/components/pill/Pill.tsx +35 -11
  47. package/src/components/pill/pill.scss +32 -24
  48. package/src/components/table/Table.stories.tsx +165 -0
  49. package/src/components/tag/Tag.stories.tsx +14 -0
  50. package/src/components/tag/Tag.test.tsx +21 -0
  51. package/src/components/tag/Tag.tsx +24 -0
  52. package/src/components/tag/tag.scss +51 -0
  53. package/src/index.scss +1 -0
  54. package/src/index.ts +1 -0
@@ -10,6 +10,9 @@ import { RowCountInfo } from './pagination/RowCountInfo';
10
10
  import { PaginationPanel } from './pagination/PaginationPanel';
11
11
  import { HideColumnsDropdown } from './HideColumnsDropdown';
12
12
  import { TableSettingsDropdown } from './pagination/TableSettingsDropdown';
13
+ import { ModalManager } from 'Components/modal/modalManager/ModalManager';
14
+ import { Modal } from 'Components/modal/Modal';
15
+ import { ModalUtils } from 'Utils/ModalUtils';
13
16
 
14
17
  type TableProps = ComponentProps<typeof Table>;
15
18
 
@@ -353,4 +356,166 @@ export const WithButtonCellRenderer: Story = {
353
356
  },
354
357
  };
355
358
 
359
+ export const WithButtonCellRendererThatOpensAModalWithModalManager: StoryObj<TableProps> = {
360
+ args: {
361
+ rowData: sampleData,
362
+ columnDefs: sampleColumnDefs,
363
+ defaultColDef: defaultColDef,
364
+ domLayout: 'autoHeight',
365
+ },
366
+ render: () => {
367
+ const ModalContent = (name: string) => (
368
+ <>
369
+ <Modal.Header>
370
+ <Modal.Title>
371
+ You've clicked on
372
+ {' '}
373
+ {name}
374
+ </Modal.Title>
375
+ </Modal.Header>
376
+ <Modal.Body>
377
+ <p>Look at you go.</p>
378
+ </Modal.Body>
379
+ </>
380
+ );
381
+
382
+ const sampleData = [
383
+ { id: 1, name: { children: 'Alice Johnson', value: 'Alice Johnson', onClick: () => ModalUtils.addModal({ children: ModalContent('Alice Johnson') }) }, email: 'alice.johnson@example.com', role: 'Developer', status: 'Active' },
384
+ { id: 2, name: { children: 'Bob Smith', variant: 'secondary', value: 'Bob Smith', onClick: () => ModalUtils.addModal({ children: ModalContent('Bob Smith') }) }, email: 'bob.smith@example.com', role: 'Designer', status: 'Active' },
385
+ { id: 3, name: { children: 'Charlie Brown', size: 'S', value: 'Charlie Brown', onClick: () => ModalUtils.addModal({ children: ModalContent('Charlie Brown') }) }, email: 'charlie.brown@example.com', role: 'Manager', status: 'Inactive' },
386
+ { id: 4, name: { children: 'Diana Prince', disabled: true, value: 'Diana Prince', onClick: () => ModalUtils.addModal({ children: ModalContent('Diana Prince') }) }, email: 'diana.prince@example.com', role: 'Developer', status: 'Active' },
387
+ { id: 5, name: { children: 'Ethan Hunt', iconLeftName: 'download', value: 'Ethan Hunt', onClick: () => ModalUtils.addModal({ children: ModalContent('Ethan Hunt') }) }, email: 'ethan.hunt@example.com', role: 'Analyst', status: 'Active' },
388
+ ];
389
+ return (
390
+ <>
391
+ <Table
392
+ rowData={sampleData}
393
+ columnDefs={sampleColumnDefsWithButtonCellRenderer}
394
+ defaultColDef={defaultColDef}
395
+ domLayout="autoHeight"
396
+ />
397
+ <ModalManager />
398
+ </>
399
+
400
+ );
401
+ },
402
+ };
403
+
404
+ export const WithButtonCellRendererThatOpensAModalWithComposableModal: StoryObj<TableProps> = {
405
+ args: {
406
+ rowData: sampleData,
407
+ columnDefs: sampleColumnDefs,
408
+ defaultColDef: defaultColDef,
409
+ domLayout: 'autoHeight',
410
+ },
411
+ render: () => {
412
+ const [activePersonId, setActivePersonId] = useState<number | null>(null);
413
+ const [showModal, setShowModal] = useState(false);
414
+
415
+ const sampleData = [
416
+ {
417
+ id: 1,
418
+ name: {
419
+ children: 'Alice Johnson',
420
+ value: 'Alice Johnson',
421
+ onClick: () => {
422
+ setActivePersonId(1);
423
+ setShowModal(true);
424
+ },
425
+ },
426
+ email: 'alice.johnson@example.com',
427
+ role: 'Developer',
428
+ status: 'Active',
429
+ },
430
+ {
431
+ id: 2,
432
+ name: {
433
+ children: 'Bob Smith',
434
+ variant: 'secondary',
435
+ value: 'Bob Smith',
436
+ onClick: () => {
437
+ setActivePersonId(2);
438
+ setShowModal(true);
439
+ },
440
+ },
441
+ email: 'bob.smith@example.com',
442
+ role: 'Designer',
443
+ status: 'Active',
444
+ },
445
+ {
446
+ id: 3,
447
+ name: {
448
+ children: 'Charlie Brown',
449
+ size: 'S',
450
+ value: 'Charlie Brown',
451
+ onClick: () => {
452
+ setActivePersonId(3);
453
+ setShowModal(true);
454
+ },
455
+ },
456
+ email: 'charlie.brown@example.com',
457
+ role: 'Manager',
458
+ status: 'Inactive',
459
+ },
460
+ {
461
+ id: 4,
462
+ name: {
463
+ children: 'Diana Prince',
464
+ disabled: true,
465
+ value: 'Diana Prince',
466
+ onClick: () => {
467
+ setActivePersonId(4);
468
+ setShowModal(true);
469
+ },
470
+ },
471
+ email: 'diana.prince@example.com',
472
+ role: 'Developer',
473
+ status: 'Active',
474
+ },
475
+ {
476
+ id: 5,
477
+ name: {
478
+ children: 'Ethan Hunt',
479
+ iconLeftName: 'download',
480
+ value: 'Ethan Hunt',
481
+ onClick: () => {
482
+ setActivePersonId(5);
483
+ setShowModal(true);
484
+ },
485
+ },
486
+ email: 'ethan.hunt@example.com',
487
+ role: 'Analyst',
488
+ status: 'Active',
489
+ },
490
+ ];
491
+ return (
492
+ <>
493
+ <Table
494
+ rowData={sampleData}
495
+ columnDefs={sampleColumnDefsWithButtonCellRenderer}
496
+ defaultColDef={defaultColDef}
497
+ domLayout="autoHeight"
498
+ />
499
+ <Modal open={showModal} closeHandler={() => setShowModal(false)}>
500
+ <Modal.Header>
501
+ <Modal.Title>
502
+ You've clicked on
503
+ {' '}
504
+ {sampleData.find(person => person.id === activePersonId)?.name.children}
505
+ </Modal.Title>
506
+ </Modal.Header>
507
+ <Modal.Body>
508
+ <p>Look at you go.</p>
509
+ </Modal.Body>
510
+ <Modal.Footer>
511
+ <Button variant="tertiary" onClick={() => setShowModal(false)}>Close</Button>
512
+ <Button variant="primary" onClick={() => setShowModal(false)}>Primary Action</Button>
513
+ </Modal.Footer>
514
+ </Modal>
515
+ </>
516
+
517
+ );
518
+ },
519
+ };
520
+
356
521
  export default meta;
@@ -0,0 +1,14 @@
1
+ import type { Meta } from '@storybook/react-vite';
2
+ import { Tag } from './Tag';
3
+
4
+ const meta: Meta<typeof Tag> = {
5
+ title: 'Components/Tag',
6
+ component: Tag,
7
+ };
8
+
9
+ export const Default = {
10
+ args: {
11
+ },
12
+ };
13
+
14
+ export default meta;
@@ -0,0 +1,21 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { Tag } from './Tag';
4
+ import '@testing-library/jest-dom/vitest';
5
+
6
+ describe('Tag', () => {
7
+ test('Tag says hello', () => {
8
+ render(<Tag text="Hello I'm a Pill!" />);
9
+ expect(screen.getByText("Hello I'm a Pill!")).toBeInTheDocument();
10
+ });
11
+
12
+ test('Tag has default color green', () => {
13
+ render(<Tag text="Hello I'm a Pill!" />);
14
+ expect(screen.getByText("Hello I'm a Pill!")).toHaveClass('ds-tag--green');
15
+ });
16
+
17
+ test('Tag has custom color', () => {
18
+ render(<Tag text="Hello I'm a Pill!" color="blue" />);
19
+ expect(screen.getByText("Hello I'm a Pill!")).toHaveClass('ds-tag--blue');
20
+ });
21
+ });
@@ -0,0 +1,24 @@
1
+ import classNames from 'classnames';
2
+
3
+ export type TagColor = 'orange'
4
+ | 'blue'
5
+ | 'green'
6
+ | 'purple'
7
+ | 'teal'
8
+ | 'salmon'
9
+ | 'yellow';
10
+
11
+ type TagProps = {
12
+ text: string;
13
+ color?: TagColor;
14
+ };
15
+
16
+ export const Tag = ({ text, color = 'green' }: TagProps) => {
17
+ return (
18
+ <span
19
+ className={classNames('ds-tag', `ds-tag--${color}`)}
20
+ >
21
+ {text}
22
+ </span>
23
+ );
24
+ };
@@ -0,0 +1,51 @@
1
+ .ds-tag {
2
+ display: flex;
3
+ padding: var(--tag-spacing-vertical) var(--tag-spacing-horizontal);
4
+ align-items: center;
5
+ gap: var(--tag-spacing-gap-horizontal);
6
+ border-radius: var(--tag-radius);
7
+ flex-grow: 0;
8
+ width: fit-content;
9
+
10
+ /* typography/body/p1-reg */
11
+ font-family: var(--type-body-p-family, Inter);
12
+ font-size: var(--type-body-p-size);
13
+ font-style: normal;
14
+ font-weight: var(--type-body-p-weight);
15
+ line-height: 150%; /* 19.5px */
16
+
17
+ &--orange {
18
+ color: var(--tag-category-orange-color-text);
19
+ background: var(--tag-category-orange-color-background);
20
+ }
21
+
22
+ &--blue {
23
+ color: var(--tag-category-blue-color-text);
24
+ background: var(--tag-category-blue-color-background);
25
+ }
26
+
27
+ &--green {
28
+ color: var(--tag-category-green-color-text);
29
+ background: var(--tag-category-green-color-background);
30
+ }
31
+
32
+ &--purple {
33
+ color: var(--tag-category-purple-color-text);
34
+ background: var(--tag-category-purple-color-background);
35
+ }
36
+
37
+ &--teal {
38
+ color: var(--tag-category-teal-color-text);
39
+ background: var(--tag-category-teal-color-background);
40
+ }
41
+
42
+ &--salmon {
43
+ color: var(--tag-category-salmon-color-text);
44
+ background: var(--tag-category-salmon-color-background);
45
+ }
46
+
47
+ &--yellow {
48
+ color: var(--tag-category-yellow-color-text);
49
+ background: var(--tag-category-yellow-color-background);
50
+ }
51
+ }
package/src/index.scss CHANGED
@@ -14,6 +14,7 @@
14
14
  @use "components/formField/inputs/checkbox/checkboxInput.scss";
15
15
  @use "components/formField/inputs/selectDropdown/selectDropdown";
16
16
  @use "components/formField/inputs/colourPickerDropdown/colourPickerDropdown.scss";
17
+ @use "components/tag/tag.scss";
17
18
  @use "components/pill/pill.scss";
18
19
  @use "components/section/section.scss";
19
20
  @use "components/tabs/tabs.scss";
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export { Heading } from 'Components/heading/Heading';
3
3
  export { Icon } from 'Components/icon/Icon';
4
4
  export { Card } from 'Components/card/Card';
5
5
  export { Dropdown } from 'Components/dropdown/Dropdown';
6
+ export { Tag } from 'Components/tag/Tag';
6
7
  export { Pill } from 'Components/pill/Pill';
7
8
  export { Section } from 'Components/section/Section';
8
9
  export { Tabs } from 'Components/tabs/Tabs';