@navikt/ds-react 6.5.0 → 6.6.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 (153) hide show
  1. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +2 -4
  2. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  3. package/cjs/form/combobox/Input/Input.js +6 -1
  4. package/cjs/form/combobox/Input/Input.js.map +1 -1
  5. package/cjs/form/form-summary/FormSummary.d.ts +82 -0
  6. package/cjs/form/form-summary/FormSummary.js +81 -0
  7. package/cjs/form/form-summary/FormSummary.js.map +1 -0
  8. package/cjs/form/form-summary/FormSummaryAnswer.d.ts +11 -0
  9. package/cjs/form/form-summary/FormSummaryAnswer.js +25 -0
  10. package/cjs/form/form-summary/FormSummaryAnswer.js.map +1 -0
  11. package/cjs/form/form-summary/FormSummaryAnswers.d.ts +9 -0
  12. package/cjs/form/form-summary/FormSummaryAnswers.js +48 -0
  13. package/cjs/form/form-summary/FormSummaryAnswers.js.map +1 -0
  14. package/cjs/form/form-summary/FormSummaryEditLink.d.ts +17 -0
  15. package/cjs/form/form-summary/FormSummaryEditLink.js +49 -0
  16. package/cjs/form/form-summary/FormSummaryEditLink.js.map +1 -0
  17. package/cjs/form/form-summary/FormSummaryHeader.d.ts +9 -0
  18. package/cjs/form/form-summary/FormSummaryHeader.js +48 -0
  19. package/cjs/form/form-summary/FormSummaryHeader.js.map +1 -0
  20. package/cjs/form/form-summary/FormSummaryHeading.d.ts +14 -0
  21. package/cjs/form/form-summary/FormSummaryHeading.js +31 -0
  22. package/cjs/form/form-summary/FormSummaryHeading.js.map +1 -0
  23. package/cjs/form/form-summary/FormSummaryLabel.d.ts +6 -0
  24. package/cjs/form/form-summary/FormSummaryLabel.js +45 -0
  25. package/cjs/form/form-summary/FormSummaryLabel.js.map +1 -0
  26. package/cjs/form/form-summary/FormSummaryValue.d.ts +6 -0
  27. package/cjs/form/form-summary/FormSummaryValue.js +49 -0
  28. package/cjs/form/form-summary/FormSummaryValue.js.map +1 -0
  29. package/cjs/form/form-summary/index.d.ts +8 -0
  30. package/cjs/form/form-summary/index.js +24 -0
  31. package/cjs/form/form-summary/index.js.map +1 -0
  32. package/cjs/index.d.ts +3 -2
  33. package/cjs/index.js +5 -3
  34. package/cjs/index.js.map +1 -1
  35. package/cjs/util/hooks/descendants/descendant.js +10 -1
  36. package/cjs/util/hooks/descendants/descendant.js.map +1 -1
  37. package/cjs/util/hooks/descendants/useDescendant.js +0 -5
  38. package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
  39. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +2 -4
  40. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  41. package/esm/form/combobox/Input/Input.js +6 -1
  42. package/esm/form/combobox/Input/Input.js.map +1 -1
  43. package/esm/form/form-summary/FormSummary.d.ts +82 -0
  44. package/esm/form/form-summary/FormSummary.js +52 -0
  45. package/esm/form/form-summary/FormSummary.js.map +1 -0
  46. package/esm/form/form-summary/FormSummaryAnswer.d.ts +11 -0
  47. package/esm/form/form-summary/FormSummaryAnswer.js +19 -0
  48. package/esm/form/form-summary/FormSummaryAnswer.js.map +1 -0
  49. package/esm/form/form-summary/FormSummaryAnswers.d.ts +9 -0
  50. package/esm/form/form-summary/FormSummaryAnswers.js +19 -0
  51. package/esm/form/form-summary/FormSummaryAnswers.js.map +1 -0
  52. package/esm/form/form-summary/FormSummaryEditLink.d.ts +17 -0
  53. package/esm/form/form-summary/FormSummaryEditLink.js +20 -0
  54. package/esm/form/form-summary/FormSummaryEditLink.js.map +1 -0
  55. package/esm/form/form-summary/FormSummaryHeader.d.ts +9 -0
  56. package/esm/form/form-summary/FormSummaryHeader.js +19 -0
  57. package/esm/form/form-summary/FormSummaryHeader.js.map +1 -0
  58. package/esm/form/form-summary/FormSummaryHeading.d.ts +14 -0
  59. package/esm/form/form-summary/FormSummaryHeading.js +5 -0
  60. package/esm/form/form-summary/FormSummaryHeading.js.map +1 -0
  61. package/esm/form/form-summary/FormSummaryLabel.d.ts +6 -0
  62. package/esm/form/form-summary/FormSummaryLabel.js +19 -0
  63. package/esm/form/form-summary/FormSummaryLabel.js.map +1 -0
  64. package/esm/form/form-summary/FormSummaryValue.d.ts +6 -0
  65. package/esm/form/form-summary/FormSummaryValue.js +20 -0
  66. package/esm/form/form-summary/FormSummaryValue.js.map +1 -0
  67. package/esm/form/form-summary/index.d.ts +8 -0
  68. package/esm/form/form-summary/index.js +10 -0
  69. package/esm/form/form-summary/index.js.map +1 -0
  70. package/esm/index.d.ts +3 -2
  71. package/esm/index.js +2 -1
  72. package/esm/index.js.map +1 -1
  73. package/esm/util/hooks/descendants/descendant.js +10 -1
  74. package/esm/util/hooks/descendants/descendant.js.map +1 -1
  75. package/esm/util/hooks/descendants/useDescendant.js +0 -5
  76. package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
  77. package/package.json +15 -4
  78. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +9 -1
  79. package/src/form/combobox/Input/Input.tsx +5 -0
  80. package/src/form/form-summary/FormSummary.tsx +106 -0
  81. package/src/form/form-summary/FormSummaryAnswer.tsx +27 -0
  82. package/src/form/form-summary/FormSummaryAnswers.tsx +25 -0
  83. package/src/form/form-summary/FormSummaryEditLink.tsx +35 -0
  84. package/src/form/form-summary/FormSummaryHeader.tsx +25 -0
  85. package/src/form/form-summary/FormSummaryHeading.tsx +23 -0
  86. package/src/form/form-summary/FormSummaryLabel.tsx +17 -0
  87. package/src/form/form-summary/FormSummaryValue.tsx +24 -0
  88. package/src/form/form-summary/index.ts +30 -0
  89. package/src/index.ts +16 -15
  90. package/src/util/hooks/descendants/descendant.ts +15 -1
  91. package/src/util/hooks/descendants/useDescendant.tsx +0 -5
  92. package/src/accordion/accordion.stories.tsx +0 -286
  93. package/src/alert/alert.stories.tsx +0 -306
  94. package/src/button/button.stories.tsx +0 -185
  95. package/src/chat/chat.stories.tsx +0 -341
  96. package/src/chips/chips.stories.tsx +0 -260
  97. package/src/copybutton/copy-button.stories.tsx +0 -261
  98. package/src/date/datepicker/datepicker.stories.tsx +0 -614
  99. package/src/date/monthpicker/monthpicker.stories.tsx +0 -221
  100. package/src/dropdown/dropdown.stories.tsx +0 -124
  101. package/src/expansion-card/expansion-card.stories.tsx +0 -282
  102. package/src/form/checkbox/checkbox.stories.tsx +0 -281
  103. package/src/form/combobox/combobox.stories.tsx +0 -626
  104. package/src/form/confirmation-panel/confirmation-panel.stories.tsx +0 -128
  105. package/src/form/error-summary/error-summary.stories.tsx +0 -81
  106. package/src/form/fieldset/fieldset.stories.tsx +0 -157
  107. package/src/form/file-upload/file-upload-dropzone.stories.tsx +0 -123
  108. package/src/form/file-upload/file-upload-item.stories.tsx +0 -148
  109. package/src/form/file-upload/file-upload.stories.tsx +0 -248
  110. package/src/form/radio/radio.stories.tsx +0 -230
  111. package/src/form/search/search.stories.tsx +0 -238
  112. package/src/form/select/select.stories.tsx +0 -172
  113. package/src/form/switch/switch.stories.tsx +0 -171
  114. package/src/form/textarea/textarea.stories.tsx +0 -254
  115. package/src/form/textfield/text-field.stories.tsx +0 -143
  116. package/src/guide-panel/guidepanel.stories.tsx +0 -90
  117. package/src/help-text/help-text.stories.tsx +0 -91
  118. package/src/internal-header/header.stories.tsx +0 -229
  119. package/src/layout/bleed/Bleed.stories.tsx +0 -395
  120. package/src/layout/box/Box.stories.tsx +0 -380
  121. package/src/layout/grid/h-grid.stories.tsx +0 -122
  122. package/src/layout/page/Page.stories.tsx +0 -271
  123. package/src/layout/responsive/hide.stories.tsx +0 -80
  124. package/src/layout/responsive/show.stories.tsx +0 -80
  125. package/src/layout/sidemal-test/navno-sidemal.stories.tsx +0 -69
  126. package/src/layout/stack/stack.stories.tsx +0 -183
  127. package/src/link/stories/link.stories.tsx +0 -304
  128. package/src/link-panel/link-panel.stories.tsx +0 -59
  129. package/src/list/list.stories.tsx +0 -280
  130. package/src/loader/loader.stories.tsx +0 -82
  131. package/src/modal/modal.stories.tsx +0 -391
  132. package/src/pagination/pagination.stories.tsx +0 -110
  133. package/src/popover/popover.stories.tsx +0 -113
  134. package/src/portal/Portal.stories.tsx +0 -102
  135. package/src/read-more/readmore.stories.tsx +0 -91
  136. package/src/skeleton/skeleton.stories.tsx +0 -130
  137. package/src/stepper/stepper.stories.tsx +0 -200
  138. package/src/table/stories/table-1.stories.tsx +0 -292
  139. package/src/table/stories/table-2-expandable.stories.tsx +0 -298
  140. package/src/table/stories/table-3-async.stories.tsx +0 -179
  141. package/src/table/stories/tests/table.stories.tsx +0 -102
  142. package/src/tabs/Tabs.stories.tsx +0 -311
  143. package/src/tag/tag.stories.tsx +0 -126
  144. package/src/timeline/timeline.stories.tsx +0 -445
  145. package/src/toggle-group/ToggleGroup.stories.tsx +0 -198
  146. package/src/tooltip/tooltip.stories.tsx +0 -101
  147. package/src/typography/stories/bodylong.stories.tsx +0 -209
  148. package/src/typography/stories/bodyshort.stories.tsx +0 -208
  149. package/src/typography/stories/detail.stories.tsx +0 -115
  150. package/src/typography/stories/error-message.stories.tsx +0 -122
  151. package/src/typography/stories/heading.stories.tsx +0 -169
  152. package/src/typography/stories/label.stories.tsx +0 -131
  153. package/src/util/hooks/descendants/descendant.stories.tsx +0 -147
@@ -1,82 +0,0 @@
1
- import { Meta } from "@storybook/react";
2
- import React from "react";
3
- import Loader, { LoaderProps } from "./Loader";
4
-
5
- export default {
6
- title: "ds-react/Loader",
7
- component: Loader,
8
- argTypes: {
9
- size: {
10
- control: {
11
- type: "radio",
12
- options: [
13
- "3xlarge",
14
- "2xlarge",
15
- "xlarge",
16
- "large",
17
- "medium",
18
- "small",
19
- "xsmall",
20
- ],
21
- },
22
- },
23
- variant: {
24
- control: {
25
- type: "radio",
26
- options: ["neutral", "interaction", "inverted"],
27
- },
28
- },
29
- },
30
- } as Meta;
31
-
32
- export const Default = {
33
- render: (props: LoaderProps) => {
34
- return <Loader {...props} />;
35
- },
36
-
37
- args: {
38
- transparent: false,
39
- },
40
- };
41
-
42
- export const Size = () => (
43
- <div>
44
- <Loader size="3xlarge" />
45
- <Loader size="2xlarge" />
46
- <Loader size="xlarge" />
47
- <Loader size="large" />
48
- <Loader size="medium" />
49
- <Loader size="small" />
50
- <Loader size="xsmall" />
51
- </div>
52
- );
53
-
54
- export const Variant = () => (
55
- <div className="colgap">
56
- <div>
57
- <Loader size="3xlarge" variant="neutral" />
58
- <Loader size="3xlarge" variant="inverted" />
59
- <Loader size="3xlarge" variant="interaction" />
60
- </div>
61
- <div style={{ backgroundColor: "#23262a" }}>
62
- <Loader size="3xlarge" variant="neutral" />
63
- <Loader size="3xlarge" variant="inverted" />
64
- <Loader size="3xlarge" variant="interaction" />
65
- </div>
66
- </div>
67
- );
68
-
69
- export const Transparent = () => (
70
- <div className="colgap">
71
- <div>
72
- <Loader size="3xlarge" transparent variant="neutral" />
73
- <Loader size="3xlarge" transparent variant="inverted" />
74
- <Loader size="3xlarge" transparent variant="interaction" />
75
- </div>
76
- <div style={{ backgroundColor: "#23262a" }}>
77
- <Loader size="3xlarge" transparent variant="neutral" />
78
- <Loader size="3xlarge" transparent variant="inverted" />
79
- <Loader size="3xlarge" transparent variant="interaction" />
80
- </div>
81
- </div>
82
- );
@@ -1,391 +0,0 @@
1
- import { Meta, StoryFn } from "@storybook/react";
2
- import React, { useRef, useState } from "react";
3
- import { FileIcon } from "@navikt/aksel-icons";
4
- import { Button } from "../button";
5
- import { Checkbox, CheckboxGroup } from "../form/checkbox";
6
- import { VStack } from "../layout/stack";
7
- import { Tooltip } from "../tooltip";
8
- import { BodyLong, Heading } from "../typography";
9
- import Modal from "./Modal";
10
-
11
- const meta: Meta<typeof Modal> = {
12
- title: "ds-react/Modal",
13
- component: Modal,
14
- parameters: {
15
- chromatic: { pauseAnimationAtEnd: true },
16
- },
17
- };
18
- export default meta;
19
-
20
- export const WithUseRef: StoryFn = () => {
21
- const ref = useRef<HTMLDialogElement>(null);
22
- const ref2 = useRef<HTMLDialogElement>(null);
23
-
24
- return (
25
- <div>
26
- <Button onClick={() => ref.current?.showModal()}>Open Modal</Button>
27
- <Modal
28
- open={ref.current ? undefined : true /* initially open */}
29
- onClose={() => null}
30
- ref={ref}
31
- header={{
32
- label: "Optional label",
33
- icon: <FileIcon aria-hidden />,
34
- heading: "Title",
35
- size: "small",
36
- }}
37
- closeOnBackdropClick
38
- >
39
- <Modal.Body>
40
- <BodyLong spacing>
41
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
42
- eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
43
- ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
44
- aliquip ex ea commodo consequat. Duis aute irure dolor in
45
- reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
46
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
47
- culpa qui officia deserunt mollit anim id est laborum.
48
- </BodyLong>
49
-
50
- {/* Nested modal */}
51
- <Modal
52
- ref={ref2}
53
- onBeforeClose={() =>
54
- window.confirm("Are you sure you want to close the modal?")
55
- }
56
- closeOnBackdropClick
57
- aria-labelledby="heading123"
58
- >
59
- <Modal.Header>
60
- <Heading size="medium" level="2" id="heading123">
61
- Custom header
62
- </Heading>
63
- </Modal.Header>
64
- <Modal.Body>
65
- Nesting modals is not recommended, but works in most cases.
66
- </Modal.Body>
67
- <Modal.Footer>
68
- <Button onClick={() => ref2.current?.close()}>
69
- Close w/o confirm
70
- </Button>
71
- </Modal.Footer>
72
- </Modal>
73
-
74
- <BodyLong>
75
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
76
- eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
77
- ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
78
- aliquip ex ea commodo consequat. Duis aute irure dolor in
79
- reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
80
- pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
81
- culpa qui officia deserunt mollit anim id est laborum.
82
- </BodyLong>
83
- </Modal.Body>
84
- <Modal.Footer>
85
- <Button>Primary</Button>
86
- <Button variant="secondary" onClick={() => ref2.current?.showModal()}>
87
- Secondary
88
- </Button>
89
- <Button variant="tertiary">Tertiary</Button>
90
- </Modal.Footer>
91
- </Modal>
92
- </div>
93
- );
94
- };
95
- WithUseRef.storyName = "With useRef";
96
-
97
- export const WithUseState: StoryFn = () => {
98
- const [open, setOpen] = useState(true);
99
- const [open2, setOpen2] = useState(false);
100
-
101
- return (
102
- <div style={{ minHeight: "1000px", display: "flex", alignItems: "center" }}>
103
- <div style={{ display: "flex", gap: "1em" }}>
104
- <Button variant="secondary">Button</Button>
105
- <Button onClick={() => setOpen(true)}>Open Modal</Button>
106
- <Button variant="secondary">Button</Button>
107
- </div>
108
- <Modal
109
- header={{ heading: "Simple header" }}
110
- open={open}
111
- onClose={() => setOpen(false)}
112
- width={400}
113
- >
114
- <Modal.Body>
115
- This modal has width set to 400.
116
- {/* Nested modal */}
117
- <Modal
118
- open={open2}
119
- onClose={(e) => {
120
- e.stopPropagation(); // onClose wil propagate to parent modal if not stopped
121
- setOpen2(false);
122
- }}
123
- closeOnBackdropClick
124
- aria-label="Nested modal"
125
- width={800}
126
- >
127
- <Modal.Body>
128
- <BodyLong spacing>
129
- Nesting modals is not recommended, but works in most cases. This
130
- one does not have header or footer, but is bigger than the
131
- parent modal.
132
- </BodyLong>
133
- <BodyLong spacing>Width is set to 800.</BodyLong>
134
- <Button onClick={() => setOpen2(false)}>Close</Button>
135
- </Modal.Body>
136
- </Modal>
137
- </Modal.Body>
138
- <Modal.Footer>
139
- <Button onClick={() => setOpen2(true)}>Primary</Button>
140
- <Button variant="secondary" onClick={() => setOpen(false)}>
141
- Cancel
142
- </Button>
143
- </Modal.Footer>
144
- </Modal>
145
- </div>
146
- );
147
- };
148
- WithUseState.storyName = "With useState";
149
- WithUseState.parameters = { chromatic: { disable: true } };
150
-
151
- export const EmptyHeader: StoryFn = () => (
152
- <Modal open onClose={() => null} aria-label="Modal with empty header">
153
- <Modal.Header />
154
- <Modal.Body>
155
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
156
- tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
157
- veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
158
- commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
159
- velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
160
- cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
161
- est laborum.
162
- </Modal.Body>
163
- </Modal>
164
- );
165
-
166
- export const Small: StoryFn = () => (
167
- <Modal
168
- open
169
- onClose={() => null}
170
- width="small"
171
- header={{ heading: "Simple header" }}
172
- >
173
- <Modal.Body>Lorem ipsum dolor sit amet.</Modal.Body>
174
- </Modal>
175
- );
176
- Small.storyName = "Size = Small";
177
-
178
- export const MediumWithPortal: StoryFn = () => (
179
- <Modal
180
- open
181
- onClose={() => null}
182
- portal
183
- width="medium"
184
- header={{ heading: "Simple header" }}
185
- >
186
- <Modal.Body>Lorem ipsum dolor sit amet.</Modal.Body>
187
- </Modal>
188
- );
189
- MediumWithPortal.storyName = "Size = Medium (with portal)";
190
-
191
- export const Large800: StoryFn = () => (
192
- <Modal
193
- open
194
- onClose={() => null}
195
- width={800}
196
- header={{ heading: "Simple header" }}
197
- >
198
- <Modal.Body>Lorem ipsum dolor sit amet.</Modal.Body>
199
- </Modal>
200
- );
201
- Large800.storyName = "Size = 800px";
202
-
203
- export const WithTooltip: StoryFn = () => {
204
- const ref = useRef<HTMLDialogElement>(null);
205
-
206
- return (
207
- <div>
208
- <Button onClick={() => ref.current?.showModal()}>Open Modal</Button>
209
- <Modal
210
- open={ref.current ? undefined : true /* initially open */}
211
- onClose={() => null}
212
- ref={ref}
213
- aria-label="Tooltip test"
214
- >
215
- <Modal.Body>
216
- <div style={{ marginBottom: "1rem" }}>
217
- <Tooltip content="This_is_the_first_tooltip">
218
- <Button>Test 1</Button>
219
- </Tooltip>
220
- </div>
221
- <Tooltip content="This is the second tooltip">
222
- <Button>Test 2</Button>
223
- </Tooltip>
224
- </Modal.Body>
225
- </Modal>
226
- </div>
227
- );
228
- };
229
- WithTooltip.parameters = { chromatic: { disable: true } }; // The tooltip behaves unpredictably in Chromatic
230
-
231
- export const WithSrOnlyElement: StoryFn = () => (
232
- <Modal
233
- open
234
- onClose={() => null}
235
- width={300}
236
- header={{ heading: "Simple header" }}
237
- >
238
- <Modal.Body>
239
- <VStack gap="16">
240
- <BodyLong>
241
- The modal body needs to have position:relative to make sr-only
242
- elements position themselves correctly when the modal body is
243
- overflowing (i.e. has a scrollbar).
244
- </BodyLong>
245
- <BodyLong>
246
- If the modal body (and other parents of the sr-only element inside the
247
- modal body) does not have position:relative (or equivalent), the
248
- sr-only element is pushed downwards relative to the height of the
249
- overflowing content.
250
- </BodyLong>
251
- <BodyLong>
252
- In the most extreme cases, an additional scrollbar appears bc. the
253
- dialog element (parent of modal body) starts overflowing. (We have
254
- overflow:auto on the dialog element in case you are on a small screen
255
- and header/footer has a lot of content.)
256
- </BodyLong>
257
- <BodyLong>Example: CheckboxGroup with a hidden legend:</BodyLong>
258
- <CheckboxGroup legend="What fruits do you like?" hideLegend>
259
- <Checkbox>Banana</Checkbox>
260
- <Checkbox>Apple</Checkbox>
261
- <Checkbox>Orange</Checkbox>
262
- <Checkbox>Pear</Checkbox>
263
- </CheckboxGroup>
264
- <BodyLong>
265
- Try to remove position:relative from the modal body and see what
266
- happens. (Use DevTools to find the legend element.) You might need to
267
- make the viewport shorter to get the full effect (double scrollbar).
268
- </BodyLong>
269
- <BodyLong>
270
- Note: The large amount of gap has been added on purpose to force
271
- overflow.
272
- </BodyLong>
273
- </VStack>
274
- </Modal.Body>
275
- <Modal.Footer>
276
- <Button variant="secondary">Dummy button</Button>
277
- </Modal.Footer>
278
- </Modal>
279
- );
280
-
281
- export const ChromaticViewportTesting: StoryFn = () => (
282
- <div id="modal-story-wrapper" style={{ width: "100vw", height: "100vh" }}>
283
- <style>{`#storybook-root { padding: 0 !important }`}</style>
284
- <Modal
285
- open
286
- onClose={() => null}
287
- header={{ heading: "Chromatic Viewports Testing", label: "Test" }}
288
- >
289
- <Modal.Body>
290
- <BodyLong spacing>
291
- This story is tailored for testing the breakpoints with Chromatic.
292
- </BodyLong>
293
- <BodyLong spacing>
294
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
295
- eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
296
- minim veniam, quis nostrud exercitation ullamco laboris nisi ut
297
- aliquip ex ea commodo consequat.
298
- </BodyLong>
299
- <BodyLong spacing>
300
- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
301
- dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
302
- proident, sunt in culpa qui officia deserunt mollit anim id est
303
- laborum.
304
- </BodyLong>
305
- <BodyLong>
306
- Sed ut perspiciatis unde omnis iste natus error sit voluptatem
307
- accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae
308
- ab illo inventore veritatis et quasi architecto beatae vitae dicta
309
- sunt explicabo.
310
- </BodyLong>
311
- </Modal.Body>
312
- <Modal.Footer>
313
- <Button>Primary</Button>
314
- <Button variant="secondary">Secondary</Button>
315
- <Button variant="tertiary">Tertiary</Button>
316
- </Modal.Footer>
317
- </Modal>
318
- </div>
319
- );
320
- ChromaticViewportTesting.parameters = {
321
- chromatic: {
322
- modes: {
323
- mobile_portrait: {
324
- viewport: {
325
- width: 400,
326
- height: 850,
327
- },
328
- },
329
- mobile_landscape: {
330
- viewport: {
331
- width: 850,
332
- height: 400,
333
- },
334
- },
335
- },
336
- },
337
- };
338
-
339
- // For testing TS error messages:
340
-
341
- /* const PropTypeTest = () => {
342
- return (
343
- <>
344
- <Modal header={{ heading: "Label" }}>OK</Modal>
345
-
346
- <Modal header={{ heading: "Label" }} aria-label="Label">
347
- OK
348
- </Modal>
349
-
350
- <Modal header={{ heading: "Label" }} aria-labelledby="Label">
351
- OK
352
- </Modal>
353
-
354
- <Modal aria-label="Label">OK</Modal>
355
-
356
- <Modal aria-labelledby="Label">OK</Modal>
357
-
358
- <Modal aria-label="Label" open onClose={() => null}>
359
- OK
360
- </Modal>
361
-
362
- <Modal>Mangler label</Modal>
363
-
364
- <Modal open>Mangler onClose eller label</Modal>
365
-
366
- <Modal open aria-label="Label">
367
- Mangler onClose
368
- </Modal>
369
-
370
- <Modal open onClose={() => null}>
371
- Mangler label
372
- </Modal>
373
-
374
- <Modal header={{ heading: "Label" }} open>
375
- Mangler onClose
376
- </Modal>
377
-
378
- <Modal
379
- header={{ heading: "Label" }}
380
- aria-label="Label"
381
- aria-labelledby="Label"
382
- >
383
- For mange labels
384
- </Modal>
385
-
386
- <Modal aria-label="Label" aria-labelledby="Label">
387
- For mange labels
388
- </Modal>
389
- </>
390
- );
391
- }; */
@@ -1,110 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Link, HashRouter as Router } from "react-router-dom";
3
- import Pagination from "./Pagination";
4
-
5
- export default {
6
- title: "ds-react/Pagination",
7
- component: Pagination,
8
- argTypes: {
9
- size: {
10
- control: {
11
- type: "radio",
12
- options: ["medium", "small", "xsmall"],
13
- },
14
- },
15
- },
16
- };
17
-
18
- export const Default = (props: any) => {
19
- const [page, setPage] = useState(props.page);
20
- return <Pagination {...props} page={page} onPageChange={setPage} />;
21
- };
22
- Default.args = {
23
- page: 2,
24
- count: 8,
25
- siblingCount: 1,
26
- boundaryCount: 1,
27
- prevNextTexts: false,
28
- };
29
-
30
- export const PrevNextText = () => {
31
- const [page, setPage] = useState(1);
32
- const props = {
33
- page: 1,
34
- count: 8,
35
- siblingCount: 1,
36
- boundaryCount: 1,
37
- };
38
- return (
39
- <div className="colgap" style={{ alignItems: "center" }}>
40
- <Pagination {...props} page={page} onPageChange={setPage} prevNextTexts />
41
- <Pagination
42
- {...props}
43
- page={page}
44
- onPageChange={setPage}
45
- prevNextTexts
46
- size="small"
47
- />
48
- <Pagination
49
- {...props}
50
- page={page}
51
- onPageChange={setPage}
52
- prevNextTexts
53
- size="xsmall"
54
- />
55
- </div>
56
- );
57
- };
58
-
59
- export const Small = () => {
60
- const [page, setPage] = useState(1);
61
- const props = {
62
- page: 1,
63
- count: 8,
64
- siblingCount: 1,
65
- boundaryCount: 1,
66
- };
67
- return (
68
- <Pagination {...props} page={page} onPageChange={setPage} size="small" />
69
- );
70
- };
71
-
72
- export const XSmall = () => {
73
- const [page, setPage] = useState(1);
74
- const props = {
75
- page: 1,
76
- count: 8,
77
- siblingCount: 1,
78
- boundaryCount: 1,
79
- };
80
- return (
81
- <Pagination {...props} page={page} onPageChange={setPage} size="xsmall" />
82
- );
83
- };
84
-
85
- export const AsLink = () => {
86
- const [page, setPage] = useState(1);
87
- const props = {
88
- page: 1,
89
- count: 8,
90
- siblingCount: 1,
91
- boundaryCount: 1,
92
- };
93
- return (
94
- <Pagination
95
- {...props}
96
- page={page}
97
- onPageChange={setPage}
98
- renderItem={(item) => (
99
- <Pagination.Item {...item} as={Link} to={`?page=${item.page}`} />
100
- )}
101
- />
102
- );
103
- };
104
- AsLink.decorators = [
105
- (Story) => (
106
- <Router>
107
- <Story />
108
- </Router>
109
- ),
110
- ];
@@ -1,113 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Button } from "../button";
3
- import Popover from "./Popover";
4
-
5
- const placements = [
6
- "top",
7
- "bottom",
8
- "right",
9
- "left",
10
- "top-start",
11
- "top-end",
12
- "bottom-start",
13
- "bottom-end",
14
- "right-start",
15
- "right-end",
16
- "left-start",
17
- "left-end",
18
- ];
19
- export default {
20
- title: "ds-react/Popover",
21
- component: Popover,
22
- parameters: {
23
- chromatic: { disable: true },
24
- },
25
- argTypes: {
26
- open: {
27
- control: { type: "boolean" },
28
- },
29
- arrow: {
30
- control: { type: "boolean" },
31
- },
32
- offset: {
33
- control: { type: "number" },
34
- },
35
- strategy: {
36
- defaultValue: "absolute",
37
- options: ["fixed", "absolute"],
38
- control: { type: "radio" },
39
- },
40
- placement: {
41
- defaultValue: "right",
42
- options: placements,
43
- control: { type: "radio" },
44
- },
45
- },
46
- };
47
-
48
- export const Default = (props: any) => {
49
- const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>();
50
- const [open, setOpen] = useState(false);
51
- return (
52
- <div tabIndex={-1}>
53
- <Button ref={(el) => setAnchorEl(el)} onClick={() => setOpen((x) => !x)}>
54
- Open
55
- </Button>
56
- <Popover
57
- {...props}
58
- open={props.open ?? open}
59
- anchorEl={anchorEl}
60
- onClose={() => setOpen(false)}
61
- >
62
- <Popover.Content>Velit in consequat</Popover.Content>
63
- </Popover>
64
- &nbsp;
65
- <Button variant="secondary">Another button</Button>
66
- </div>
67
- );
68
- };
69
-
70
- const Template = (props) => {
71
- const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
72
-
73
- return (
74
- <>
75
- <Button ref={(el) => setAnchorEl(el)}>X</Button>
76
- <Popover {...props} open anchorEl={anchorEl}>
77
- <Popover.Content>
78
- Velit in consequat Lorem
79
- <br />
80
- {props.placement}
81
- </Popover.Content>
82
- </Popover>
83
- </>
84
- );
85
- };
86
-
87
- export const Placement = () => {
88
- return (
89
- <div className="colgap" style={{ gap: "12rem" }}>
90
- {placements.map((placement) => (
91
- <Template key={placement} placement={placement} />
92
- ))}
93
- </div>
94
- );
95
- };
96
-
97
- export const Arrow = () => {
98
- return (
99
- <div className="colgap" style={{ gap: "12rem" }}>
100
- <Template arrow />
101
- <Template arrow={false} />
102
- </div>
103
- );
104
- };
105
-
106
- export const Offset = () => {
107
- return (
108
- <div className="colgap" style={{ gap: "12rem" }}>
109
- <Template arrow offset={30} />
110
- <Template arrow={false} offset={30} />
111
- </div>
112
- );
113
- };