@simplybusiness/mobius 4.0.0-beta.11 → 4.0.0-beta.13

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 (84) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/components/Button/Button.d.ts +1 -1
  3. package/dist/cjs/components/Button/Button.js +1 -1
  4. package/dist/cjs/components/Button/Button.js.map +1 -1
  5. package/dist/cjs/components/Button/Button.stories.js +12 -12
  6. package/dist/cjs/components/Button/Button.stories.js.map +1 -1
  7. package/dist/cjs/components/Drawer/Drawer.js +22 -36
  8. package/dist/cjs/components/Drawer/Drawer.js.map +1 -1
  9. package/dist/cjs/components/Flex/Flex.stories.js +8 -13
  10. package/dist/cjs/components/Flex/Flex.stories.js.map +1 -1
  11. package/dist/cjs/components/Grid/Grid.stories.js +11 -16
  12. package/dist/cjs/components/Grid/Grid.stories.js.map +1 -1
  13. package/dist/cjs/components/Icon/Icon.js +1 -2
  14. package/dist/cjs/components/Icon/Icon.js.map +1 -1
  15. package/dist/cjs/components/Icon/Icon.stories.js +1 -1
  16. package/dist/cjs/components/Icon/types.d.ts +1 -1
  17. package/dist/cjs/components/LinkButton/LinkButton.stories.js +1 -1
  18. package/dist/cjs/components/LinkButton/LinkButton.stories.js.map +1 -1
  19. package/dist/cjs/components/Modal/Modal.js +24 -41
  20. package/dist/cjs/components/Modal/Modal.js.map +1 -1
  21. package/dist/cjs/components/Modal/Modal.stories.d.ts +2 -0
  22. package/dist/cjs/components/Modal/Modal.stories.js +18 -1
  23. package/dist/cjs/components/Modal/Modal.stories.js.map +1 -1
  24. package/dist/cjs/components/Modal/Modal.test.js +29 -6
  25. package/dist/cjs/components/Modal/Modal.test.js.map +1 -1
  26. package/dist/cjs/components/Radio/Radio.stories.js +1 -1
  27. package/dist/cjs/components/Segment/Segment.stories.js +11 -13
  28. package/dist/cjs/components/Segment/Segment.stories.js.map +1 -1
  29. package/dist/cjs/components/Segment/SegmentGroup.d.ts +1 -1
  30. package/dist/cjs/components/Segment/SegmentGroup.js.map +1 -1
  31. package/dist/cjs/components/Text/Text.d.ts +2 -2
  32. package/dist/cjs/components/Text/Text.js +1 -1
  33. package/dist/cjs/components/Text/Text.js.map +1 -1
  34. package/dist/cjs/components/Text/Text.stories.js +2 -2
  35. package/dist/cjs/components/Text/Text.stories.js.map +1 -1
  36. package/dist/cjs/components/Text/Text.test.js +2 -2
  37. package/dist/cjs/components/index.d.ts +1 -0
  38. package/dist/cjs/components/index.js +1 -0
  39. package/dist/cjs/components/index.js.map +1 -1
  40. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  41. package/dist/esm/components/Button/Button.js +1 -1
  42. package/dist/esm/components/Button/Button.js.map +1 -1
  43. package/dist/esm/components/Drawer/Drawer.js +22 -36
  44. package/dist/esm/components/Drawer/Drawer.js.map +1 -1
  45. package/dist/esm/components/Icon/Icon.js +1 -2
  46. package/dist/esm/components/Icon/Icon.js.map +1 -1
  47. package/dist/esm/components/Modal/Modal.js +24 -41
  48. package/dist/esm/components/Modal/Modal.js.map +1 -1
  49. package/dist/esm/components/Segment/SegmentGroup.js.map +1 -1
  50. package/dist/esm/components/Text/Text.js +1 -1
  51. package/dist/esm/components/Text/Text.js.map +1 -1
  52. package/dist/esm/components/index.js +1 -0
  53. package/dist/esm/components/index.js.map +1 -1
  54. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  55. package/dist/mobius.d.ts +46 -5
  56. package/package.json +2 -2
  57. package/src/components/Button/Button.mdx +7 -7
  58. package/src/components/Button/Button.stories.tsx +12 -12
  59. package/src/components/Button/Button.story.styles.css +1 -1
  60. package/src/components/Button/Button.tsx +2 -2
  61. package/src/components/Checkbox/Checkbox.mdx +4 -1
  62. package/src/components/Drawer/Drawer.tsx +34 -46
  63. package/src/components/Flex/Flex.mdx +18 -23
  64. package/src/components/Flex/Flex.stories.tsx +8 -13
  65. package/src/components/Grid/Grid.mdx +13 -18
  66. package/src/components/Grid/Grid.stories.tsx +11 -16
  67. package/src/components/Icon/Icon.stories.tsx +1 -1
  68. package/src/components/Icon/Icon.tsx +1 -1
  69. package/src/components/Icon/types.ts +1 -17
  70. package/src/components/LinkButton/LinkButton.stories.tsx +1 -1
  71. package/src/components/Modal/Modal.mdx +51 -0
  72. package/src/components/Modal/Modal.stories.tsx +53 -0
  73. package/src/components/Modal/Modal.test.tsx +49 -6
  74. package/src/components/Modal/Modal.tsx +35 -50
  75. package/src/components/Progress/Progress.mdx +3 -3
  76. package/src/components/Radio/Radio.mdx +5 -2
  77. package/src/components/Radio/Radio.stories.tsx +1 -1
  78. package/src/components/Segment/Segment.mdx +22 -24
  79. package/src/components/Segment/Segment.stories.tsx +22 -24
  80. package/src/components/Segment/SegmentGroup.tsx +1 -9
  81. package/src/components/Text/Text.stories.tsx +3 -5
  82. package/src/components/Text/Text.test.tsx +2 -2
  83. package/src/components/Text/Text.tsx +3 -13
  84. package/src/components/index.tsx +1 -0
@@ -115,6 +115,57 @@ const WithAnimationDemo = () => {
115
115
  };
116
116
  ```
117
117
 
118
+ ### Nested Modals
119
+
120
+ <Story of={ModalStories.WithNested} />
121
+
122
+ ```jsx
123
+ const ChildModal = () => {
124
+ const [showModal, setShowModal] = useState<boolean>(false);
125
+ const show = () => setShowModal(true);
126
+ const hide = () => setShowModal(false);
127
+
128
+ return (
129
+ <>
130
+ <Button onClick={show}>Show child modal</Button>
131
+ <Modal isOpen={showModal} onClose={hide} animation="slideUp">
132
+ <Modal.Header>Howdy</Modal.Header>
133
+ <Modal.Content>
134
+ <Text>
135
+ Closing or cancelling (with Escape key) should leave the parent
136
+ modal open.
137
+ </Text>
138
+ </Modal.Content>
139
+ </Modal>
140
+ </>
141
+ );
142
+ };
143
+
144
+ const Nested = ({ animation, closeLabel }: ModalProps) => {
145
+ const [open, setOpen] = useState(false);
146
+
147
+ return (
148
+ <>
149
+ <Button onClick={() => setOpen(true)}>Show Nested Modal</Button>
150
+ <Modal
151
+ isOpen={open}
152
+ onClose={() => setOpen(false)}
153
+ animation={animation}
154
+ closeLabel={closeLabel}
155
+ >
156
+ <Modal.Header>The Latin Modal</Modal.Header>
157
+ <Modal.Content>
158
+ <Text>
159
+ Closing or cancelling the next modal should leave me open.
160
+ </Text>
161
+ <ChildModal />
162
+ </Modal.Content>
163
+ </Modal>
164
+ </>
165
+ );
166
+ };
167
+ ```
168
+
118
169
  ## Closing a Modal from within a child `<iframe>`
119
170
 
120
171
  ### Step 1: Create embeddable `<iframe>`
@@ -168,6 +168,51 @@ const WithLongContentDemo = (props: ModalProps) => {
168
168
  );
169
169
  };
170
170
 
171
+ const ChildModal = () => {
172
+ const [showModal, setShowModal] = useState<boolean>(false);
173
+ const show = () => setShowModal(true);
174
+ const hide = () => setShowModal(false);
175
+
176
+ return (
177
+ <>
178
+ <Button onClick={show}>Show child modal</Button>
179
+ <Modal isOpen={showModal} onClose={hide} animation="slideUp">
180
+ <Modal.Header>Howdy</Modal.Header>
181
+ <Modal.Content>
182
+ <Text>
183
+ Closing or cancelling (with Escape key) should leave the parent
184
+ modal open.
185
+ </Text>
186
+ </Modal.Content>
187
+ </Modal>
188
+ </>
189
+ );
190
+ };
191
+
192
+ const WithNestedDemo = ({ animation, closeLabel }: ModalProps) => {
193
+ const [open, setOpen] = useState(false);
194
+
195
+ return (
196
+ <>
197
+ <Button onClick={() => setOpen(true)}>Show Nested Modal</Button>
198
+ <Modal
199
+ isOpen={open}
200
+ onClose={() => setOpen(false)}
201
+ animation={animation}
202
+ closeLabel={closeLabel}
203
+ >
204
+ <Modal.Header>The Latin Modal</Modal.Header>
205
+ <Modal.Content>
206
+ <Text>
207
+ Closing or cancelling the next modal should leave me open.
208
+ </Text>
209
+ <ChildModal />
210
+ </Modal.Content>
211
+ </Modal>
212
+ </>
213
+ );
214
+ };
215
+
171
216
  export default {
172
217
  title: "Components/Modal",
173
218
  component: Modal,
@@ -230,3 +275,11 @@ export const WithLongContent: Meta<typeof WithLongContentDemo> = {
230
275
  closeLabel: "Close",
231
276
  },
232
277
  };
278
+
279
+ export const WithNested: Meta<typeof WithNestedDemo> = {
280
+ render: (args: ModalProps) => <WithNestedDemo {...args} />,
281
+ args: {
282
+ isOpen: false,
283
+ closeLabel: "Close",
284
+ },
285
+ };
@@ -100,16 +100,59 @@ describe("Modal", () => {
100
100
  });
101
101
 
102
102
  // TODO: Cannot test until HTML Dialog is supported in JSDom
103
- xdescribe("pressing close button", () => {
104
- it.only("should close the modal", async () => {
103
+ xdescribe("closing and cancelling", () => {
104
+ beforeAll(() => {
105
+ HTMLDialogElement.prototype.show = jest.fn(function mock(
106
+ this: HTMLDialogElement,
107
+ ) {
108
+ this.open = true;
109
+ });
110
+
111
+ HTMLDialogElement.prototype.showModal = jest.fn(function mock(
112
+ this: HTMLDialogElement,
113
+ ) {
114
+ this.open = true;
115
+ });
116
+
117
+ HTMLDialogElement.prototype.close = jest.fn(function mock(
118
+ this: HTMLDialogElement,
119
+ ) {
120
+ this.open = false;
121
+ });
122
+ });
123
+
124
+ it.only("pressing close button should close the modal", async () => {
105
125
  const content = <Modal.Content>Sample content</Modal.Content>;
106
126
  let modalOpen = true;
107
127
  const onClose = () => {
108
128
  modalOpen = false;
109
129
  };
130
+ const user = userEvent.setup();
131
+
132
+ render(
133
+ <Modal isOpen={modalOpen} onClose={onClose} closeLabel="Close Me">
134
+ <Modal.Header />
135
+ {content}
136
+ </Modal>,
137
+ );
138
+
139
+ const modal = screen.getByRole("dialog", { hidden: true });
140
+ expect(modal).toBeInTheDocument();
141
+ expect((modal as HTMLDialogElement).open).toBe(true);
142
+ screen.debug();
143
+
144
+ const closeButton = screen.getByRole("button");
145
+
146
+ await user.click(closeButton); // This errors because
147
+ expect((modal as HTMLDialogElement).open).toBe(false);
148
+ });
149
+
150
+ it("should cancel the modal", async () => {
151
+ const content = <Modal.Content>Sample content</Modal.Content>;
152
+ const onClose = jest.fn();
110
153
 
111
154
  render(
112
- <Modal isOpen={modalOpen} onClose={onClose}>
155
+ <Modal isOpen onClose={onClose}>
113
156
  <Modal.Header />
114
157
  {content}
115
158
  </Modal>,
@@ -117,9 +160,9 @@ describe("Modal", () => {
117
160
 
118
161
  const modalContent = screen.getByText("Sample content");
119
162
  expect(modalContent).toBeInTheDocument();
120
- const closeButton = screen.getByLabelText("Close");
121
- await userEvent.click(closeButton); // This errors
122
- expect(modalOpen).toBe(false);
163
+ await userEvent.keyboard("{escape}");
164
+
165
+ expect(onClose).toHaveBeenCalled();
123
166
  });
124
167
  });
125
168
 
@@ -6,6 +6,7 @@
6
6
  import classNames from "classnames/dedupe";
7
7
  import {
8
8
  Children,
9
+ ReactEventHandler,
9
10
  ReactNode,
10
11
  cloneElement,
11
12
  isValidElement,
@@ -13,7 +14,6 @@ import {
13
14
  useEffect,
14
15
  useRef,
15
16
  } from "react";
16
- import { useOnClickOutside } from "../../hooks";
17
17
  import { useBodyScrollLock } from "../../hooks/useBodyScrollLock";
18
18
  import { supportsDialog } from "../../utils/polyfill-tests";
19
19
 
@@ -79,9 +79,8 @@ const Modal = ({
79
79
  }
80
80
  }
81
81
 
82
- // End deprecation warnings
83
- const ref = useRef<HTMLDialogElement>(null);
84
- const dialog = ref.current as HTMLDialogElement;
82
+ const modalRef = useRef<HTMLDialogElement>(null);
83
+ const dialog = modalRef.current as HTMLDialogElement;
85
84
  const noPreference = window?.matchMedia(
86
85
  "(prefers-reduced-motion: no-preference)",
87
86
  );
@@ -89,48 +88,34 @@ const Modal = ({
89
88
  useBodyScrollLock({ enabled: isOpen });
90
89
 
91
90
  // Add close handler, to enable closing animations
92
- const handleClose = useCallback(() => {
93
- const doClose = () => {
94
- dialog.close();
95
- if (onClose) {
96
- onClose();
97
- }
98
- };
99
-
100
- if (animation) {
101
- dialog.classList.add("close");
102
- dialog.addEventListener(
103
- "animationend",
104
- () => {
105
- dialog.classList.remove("close");
91
+ const handleClose: ReactEventHandler<HTMLDialogElement> = useCallback(
92
+ event => {
93
+ if (event) {
94
+ event.preventDefault();
95
+ event.stopPropagation();
96
+
97
+ const doClose = () => {
98
+ dialog.close();
99
+ onClose?.();
100
+ };
101
+
102
+ if (animation) {
103
+ dialog.classList.add("close");
104
+ dialog.addEventListener(
105
+ "animationend",
106
+ () => {
107
+ dialog.classList.remove("close");
108
+ doClose();
109
+ },
110
+ { once: true },
111
+ );
112
+ } else {
106
113
  doClose();
107
- },
108
- { once: true },
109
- );
110
- } else {
111
- doClose();
112
- }
113
- }, [onClose, animation, dialog]);
114
-
115
- // Close modal if backdrop is clicked
116
- dialog?.addEventListener("click", event => {
117
- const rect = dialog.getBoundingClientRect();
118
- const isInDialog =
119
- rect.top <= event.clientY &&
120
- event.clientY <= rect.top + rect.height &&
121
- rect.left <= event.clientX &&
122
- event.clientX <= rect.left + rect.width;
123
- if (!isInDialog) {
124
- handleClose();
125
- }
126
- });
127
-
128
- // Close modal if Escape button is pressed
129
- useOnClickOutside(ref, () => {
130
- if (ref.current && isOpen) {
131
- handleClose();
132
- }
133
- });
114
+ }
115
+ }
116
+ },
117
+ [animation, dialog, onClose],
118
+ );
134
119
 
135
120
  const modalClasses = classNames(
136
121
  "mobius",
@@ -151,13 +136,13 @@ const Modal = ({
151
136
  if (!supportsDialog() && typeof window !== "undefined") {
152
137
  // eslint-disable-next-line import/no-extraneous-dependencies
153
138
  const { default: dialogPolyfill } = await import("dialog-polyfill");
154
- dialogPolyfill.registerDialog(ref.current as HTMLDialogElement);
139
+ dialogPolyfill.registerDialog(modalRef.current as HTMLDialogElement);
155
140
  }
156
141
 
157
142
  if (isOpen) {
158
- ref.current?.showModal();
159
- } else if (ref.current?.open) {
160
- ref.current?.close();
143
+ modalRef.current?.showModal();
144
+ } else if (modalRef.current?.open) {
145
+ modalRef.current?.close();
161
146
  }
162
147
  }
163
148
 
@@ -165,7 +150,7 @@ const Modal = ({
165
150
  }, [isOpen]);
166
151
 
167
152
  return (
168
- <dialog ref={ref} onCancel={onClose} className={modalClasses}>
153
+ <dialog ref={modalRef} onCancel={handleClose} className={modalClasses}>
169
154
  {Children.map(children, child => {
170
155
  if (isValidElement(child)) {
171
156
  return cloneElement(child, {
@@ -51,8 +51,8 @@ The following HTML is rendered for a Progress:
51
51
 
52
52
  ```html
53
53
  <div
54
- id="react-aria123"
55
- aria-labelledby="react-aria456"
54
+ id="123"
55
+ aria-labelledby="456"
56
56
  aria-valuenow="2"
57
57
  aria-valuemin="0"
58
58
  aria-valuemax="10"
@@ -60,7 +60,7 @@ The following HTML is rendered for a Progress:
60
60
  role="progressbar"
61
61
  class="mobius mobius/Progress --is-primary"
62
62
  >
63
- <label class="mobius mobius/Label mobius/ProgressLabel" id="react-aria456"
63
+ <label class="mobius mobius/Label mobius/ProgressLabel" id="456"
64
64
  >Primary</label
65
65
  >
66
66
  <div class="mobius/ProgressTrack">
@@ -79,7 +79,7 @@ For example, `<RadioGroup defaultValue="blue">`
79
79
  width: "100%",
80
80
  flexDirection: "row",
81
81
  justifyContent: "space-between",
82
- marginBottom: "var(--size-20)",
82
+ marginBottom: "var(--size-xs)",
83
83
  }}
84
84
  >
85
85
  <div>To pay today</div>
@@ -128,7 +128,10 @@ The `onChange` prop can be used to listen to changes of the selected radio butto
128
128
 
129
129
  ## Radio Props
130
130
 
131
- <ArgTypes of={{ ...RadioGroup, ...Radio }} />
131
+ <ArgTypes
132
+ of={{ ...RadioGroup, ...Radio }}
133
+ exclude={["name", "groupDisabled", "selected", "setSelected"]}
134
+ />
132
135
 
133
136
  ## Component HTML Structure and Class names
134
137
 
@@ -148,7 +148,7 @@ export const ComplexLabel: Meta<typeof RadioGroup> = {
148
148
  width: "100%",
149
149
  flexDirection: "row",
150
150
  justifyContent: "space-between",
151
- marginBottom: "var(--size-20)",
151
+ marginBottom: "var(--size-xs)",
152
152
  }}
153
153
  >
154
154
  <div>To pay today</div>
@@ -17,14 +17,12 @@ import * as SegmentStories from "./Segment.stories";
17
17
 
18
18
  export const sizeOptions = [
19
19
  "",
20
- "size-10",
21
- "size-20",
22
- "size-30",
23
- "size-40",
24
- "size-50",
25
- "size-60",
26
- "size-70",
27
- "size-80",
20
+ "size-xs",
21
+ "size-s",
22
+ "size-m",
23
+ "size-l",
24
+ "size-xl",
25
+ "size-xxl",
28
26
  ];
29
27
 
30
28
  <Meta of={SegmentStories} />
@@ -236,7 +234,7 @@ import { Segment, SegmentGroup } from "@simplybusiness/mobius";
236
234
  </SegmentGroup>
237
235
  ```
238
236
 
239
- Add margin around a SegmentGroup with a `margin="size-{10|20|30|40}"` prop:
237
+ Add margin around a SegmentGroup with a `margin="size-{xs|s|m|l|xl|xxl}"` prop:
240
238
 
241
239
  <SegmentStories.MarginAround />
242
240
 
@@ -246,7 +244,7 @@ import { Segment, SegmentGroup } from "@simplybusiness/mobius";
246
244
 
247
245
  <SegmentGroup>
248
246
  <Segment>Top</Segment>
249
- <SegmentGroup margin="size-30">
247
+ <SegmentGroup margin="size-s">
250
248
  <Segment>Nested Top</Segment>
251
249
  <Segment>Nested Middle</Segment>
252
250
  <Segment>Nested Bottom</Segment>
@@ -278,12 +276,12 @@ import { Segment, SegmentGroup, Text, Flex } from "@simplybusiness/mobius";
278
276
  rowGap: "8px",
279
277
  }}
280
278
  >
281
- <Text variant="caption">General liability*</Text>
282
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>$300.00</Text>
283
- <Text variant="caption">Contractor's equipment and small tools</Text>
284
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>$80.00</Text>
285
- <Text variant="caption">Cyber insurance</Text>
286
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>$250.00</Text>
279
+ <Text variant="small">General liability*</Text>
280
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>$300.00</Text>
281
+ <Text variant="small">Contractor's equipment and small tools</Text>
282
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>$80.00</Text>
283
+ <Text variant="small">Cyber insurance</Text>
284
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>$250.00</Text>
287
285
  </div>
288
286
  <Divider />
289
287
  <div
@@ -295,8 +293,8 @@ import { Segment, SegmentGroup, Text, Flex } from "@simplybusiness/mobius";
295
293
  width: "100%",
296
294
  }}
297
295
  >
298
- <Text variant="caption"><strong>To pay today</strong></Text>
299
- <Text variant="caption" style={{ justifySelf: "flex-end" }}><strong>$630.00</strong></Text>
296
+ <Text variant="small"><strong>To pay today</strong></Text>
297
+ <Text variant="small" style={{ justifySelf: "flex-end" }}><strong>$630.00</strong></Text>
300
298
  </div>
301
299
  </Segment>
302
300
  <Segment heading="Monthly Payments">
@@ -309,14 +307,14 @@ import { Segment, SegmentGroup, Text, Flex } from "@simplybusiness/mobius";
309
307
  width: "100%",
310
308
  }}
311
309
  >
312
- <Text variant="caption">
310
+ <Text variant="small">
313
311
  <strong>First monthly payment taken</strong>
314
312
  </Text>
315
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>01/01/2022</Text>
316
- <Text variant="caption">8 monthly payments of</Text>
317
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>$120.00</Text>
318
- <Text variant="caption">Then 2 monthly payments of</Text>
319
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>$90.00</Text>
313
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>01/01/2022</Text>
314
+ <Text variant="small">8 monthly payments of</Text>
315
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>$120.00</Text>
316
+ <Text variant="small">Then 2 monthly payments of</Text>
317
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>$90.00</Text>
320
318
  </div>
321
319
  </Segment>
322
320
  <Segment colour="subtle">
@@ -16,14 +16,12 @@ import { excludeControls } from "../../utils/excludeControls";
16
16
 
17
17
  const sizeOptions = [
18
18
  "",
19
- "size-10",
20
- "size-20",
21
- "size-30",
22
- "size-40",
23
- "size-50",
24
- "size-60",
25
- "size-70",
26
- "size-80",
19
+ "size-xs",
20
+ "size-s",
21
+ "size-m",
22
+ "size-l",
23
+ "size-xl",
24
+ "size-xxl",
27
25
  ];
28
26
 
29
27
  export default {
@@ -117,7 +115,7 @@ export const HorizontalStack: Meta<typeof SegmentGroup> = {
117
115
  ),
118
116
  args: {
119
117
  horizontal: true,
120
- margin: "size-20",
118
+ margin: "size-xs",
121
119
  },
122
120
  argTypes: {
123
121
  margin: {
@@ -232,7 +230,7 @@ export const CompoundLayout = () => (
232
230
  export const MarginAround = () => (
233
231
  <SegmentGroup>
234
232
  <Segment>Top</Segment>
235
- <SegmentGroup margin="size-30">
233
+ <SegmentGroup margin="size-s">
236
234
  <Segment>Nested Top</Segment>
237
235
  <Segment>Nested Middle</Segment>
238
236
  <Segment>Nested Bottom</Segment>
@@ -258,18 +256,18 @@ export const PaymentDetails = () => (
258
256
  rowGap: "8px",
259
257
  }}
260
258
  >
261
- <Text variant="caption">General liability\*</Text>
262
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
259
+ <Text variant="small">General liability\*</Text>
260
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
263
261
  $300.00
264
262
  </Text>
265
- <Text variant="caption">
263
+ <Text variant="small">
266
264
  Contractor&apos;s equipment and small tools
267
265
  </Text>
268
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
266
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
269
267
  $80.00
270
268
  </Text>
271
- <Text variant="caption">Cyber insurance</Text>
272
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
269
+ <Text variant="small">Cyber insurance</Text>
270
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
273
271
  $250.00
274
272
  </Text>
275
273
  </div>
@@ -283,10 +281,10 @@ export const PaymentDetails = () => (
283
281
  width: "100%",
284
282
  }}
285
283
  >
286
- <Text variant="caption">
284
+ <Text variant="small">
287
285
  <strong>To pay today</strong>
288
286
  </Text>
289
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
287
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
290
288
  <strong>$630.00</strong>
291
289
  </Text>
292
290
  </div>
@@ -301,18 +299,18 @@ export const PaymentDetails = () => (
301
299
  width: "100%",
302
300
  }}
303
301
  >
304
- <Text variant="caption">
302
+ <Text variant="small">
305
303
  <strong>First monthly payment taken</strong>
306
304
  </Text>
307
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
305
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
308
306
  01/01/2022
309
307
  </Text>
310
- <Text variant="caption">8 monthly payments of</Text>
311
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
308
+ <Text variant="small">8 monthly payments of</Text>
309
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
312
310
  $120.00
313
311
  </Text>
314
- <Text variant="caption">Then 2 monthly payments of</Text>
315
- <Text variant="caption" style={{ justifySelf: "flex-end" }}>
312
+ <Text variant="small">Then 2 monthly payments of</Text>
313
+ <Text variant="small" style={{ justifySelf: "flex-end" }}>
316
314
  $90.00
317
315
  </Text>
318
316
  </div>
@@ -5,15 +5,7 @@ import { DOMProps } from "../../types/dom";
5
5
  export interface SegmentGroupProps extends DOMProps {
6
6
  className?: string;
7
7
  horizontal?: boolean;
8
- margin?:
9
- | "size-10"
10
- | "size-20"
11
- | "size-30"
12
- | "size-40"
13
- | "size-50"
14
- | "size-60"
15
- | "size-70"
16
- | "size-80";
8
+ margin?: "size-xs" | "size-s" | "size-m" | "size-l" | "size-xl" | "size-xxl";
17
9
  children?: ReactNode;
18
10
  }
19
11
 
@@ -36,9 +36,9 @@ export const Example = () => (
36
36
  <Text elementType="h2">Heading 2</Text>
37
37
  <Text elementType="h3">Heading 3</Text>
38
38
  <Text elementType="h4">Heading 4</Text>
39
- <Text elementType="h5">Heading 5</Text>
40
- <Text elementType="h6">Heading 6</Text>
41
39
  <Text>Paragraph</Text>
40
+ <Text variant="small">Small paragraph</Text>
41
+ <Text variant="legal">Small print</Text>
42
42
  </Box>
43
43
  <Box>
44
44
  <Text elementType="h1">First Heading</Text>
@@ -86,10 +86,8 @@ export const ExampleVariant = () => (
86
86
  <Text variant="h2">variant h2</Text>
87
87
  <Text variant="h3">variant h3</Text>
88
88
  <Text variant="h4">variant h4</Text>
89
- <Text variant="h5">variant h5</Text>
90
- <Text variant="lead">variant lead</Text>
91
89
  <Text variant="body">variant body</Text>
92
- <Text variant="caption">variant caption</Text>
90
+ <Text variant="small">variant small</Text>
93
91
  <Text variant="legal">variant legal</Text>
94
92
  </div>
95
93
  );
@@ -10,8 +10,8 @@ describe("Text", () => {
10
10
 
11
11
  describe("given elementType", () => {
12
12
  it("is not applied as element attribute", () => {
13
- const { container } = render(<Text elementType="h6">Sample text</Text>);
14
- expect(container.firstChild).not.toHaveAttribute("elementtype", "h6");
13
+ const { container } = render(<Text elementType="h4">Sample text</Text>);
14
+ expect(container.firstChild).not.toHaveAttribute("elementtype", "h4");
15
15
  });
16
16
  });
17
17
 
@@ -9,20 +9,10 @@ export type TextVariantType =
9
9
  | "h2"
10
10
  | "h3"
11
11
  | "h4"
12
- | "h5"
13
- | "lead"
14
12
  | "body"
15
- | "caption"
13
+ | "small"
16
14
  | "legal";
17
- export type ElementType =
18
- | "h1"
19
- | "h2"
20
- | "h3"
21
- | "h4"
22
- | "h5"
23
- | "h6"
24
- | "p"
25
- | "span";
15
+ export type ElementType = "h1" | "h2" | "h3" | "h4" | "p" | "span";
26
16
  export interface TextProps extends DOMProps, RefAttributes<TextElementType> {
27
17
  /** HTML element for the text */
28
18
  elementType?: ElementType;
@@ -43,7 +33,7 @@ const getElementType = (
43
33
  elementType: ElementType | undefined,
44
34
  ) => {
45
35
  if (variant) {
46
- return ["h1", "h2", "h3", "h4", "h5"].includes(variant) ? variant : "p";
36
+ return ["h1", "h2", "h3", "h4"].includes(variant) ? variant : "p";
47
37
  }
48
38
  return elementType || "p";
49
39
  };
@@ -6,6 +6,7 @@ export * from "./Button";
6
6
  export * from "./Checkbox";
7
7
  export * from "./Container";
8
8
  export * from "./Divider";
9
+ export * from "./Drawer";
9
10
  export * from "./DropdownMenu";
10
11
  export * from "./ErrorMessage";
11
12
  export * from "./Fieldset";