@navikt/ds-react 0.14.10-next.0 → 0.14.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 (72) hide show
  1. package/cjs/button/Button.js +22 -3
  2. package/cjs/form/Fieldset/Fieldset.js +3 -3
  3. package/cjs/form/Select.js +2 -2
  4. package/cjs/form/Switch.js +1 -1
  5. package/cjs/form/TextField.js +5 -3
  6. package/cjs/form/Textarea.js +3 -3
  7. package/cjs/form/checkbox/Checkbox.js +1 -1
  8. package/cjs/form/search-field/SearchField.js +21 -42
  9. package/cjs/form/search-field/SearchFieldButton.js +50 -0
  10. package/cjs/form/search-field/SearchFieldClearButton.js +50 -0
  11. package/cjs/form/search-field/SearchFieldInput.js +49 -0
  12. package/cjs/modal/Modal.js +4 -4
  13. package/cjs/util/index.js +1 -15
  14. package/esm/button/Button.d.ts +5 -0
  15. package/esm/button/Button.js +24 -5
  16. package/esm/button/Button.js.map +1 -1
  17. package/esm/form/Fieldset/Fieldset.js +3 -3
  18. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  19. package/esm/form/Select.js +2 -2
  20. package/esm/form/Select.js.map +1 -1
  21. package/esm/form/Switch.js +1 -1
  22. package/esm/form/Switch.js.map +1 -1
  23. package/esm/form/TextField.js +5 -3
  24. package/esm/form/TextField.js.map +1 -1
  25. package/esm/form/Textarea.js +3 -3
  26. package/esm/form/Textarea.js.map +1 -1
  27. package/esm/form/checkbox/Checkbox.js +1 -1
  28. package/esm/form/checkbox/Checkbox.js.map +1 -1
  29. package/esm/form/search-field/SearchField.d.ts +25 -25
  30. package/esm/form/search-field/SearchField.js +22 -44
  31. package/esm/form/search-field/SearchField.js.map +1 -1
  32. package/esm/form/search-field/SearchFieldButton.d.ts +17 -0
  33. package/esm/form/search-field/SearchFieldButton.js +27 -0
  34. package/esm/form/search-field/SearchFieldButton.js.map +1 -0
  35. package/esm/form/search-field/SearchFieldClearButton.d.ts +17 -0
  36. package/esm/form/search-field/SearchFieldClearButton.js +27 -0
  37. package/esm/form/search-field/SearchFieldClearButton.js.map +1 -0
  38. package/esm/form/search-field/SearchFieldInput.d.ts +6 -0
  39. package/esm/form/search-field/SearchFieldInput.js +26 -0
  40. package/esm/form/search-field/SearchFieldInput.js.map +1 -0
  41. package/esm/modal/Modal.d.ts +5 -0
  42. package/esm/modal/Modal.js +4 -4
  43. package/esm/modal/Modal.js.map +1 -1
  44. package/esm/util/index.d.ts +0 -5
  45. package/esm/util/index.js +0 -13
  46. package/esm/util/index.js.map +1 -1
  47. package/package.json +3 -3
  48. package/src/button/Button.tsx +55 -18
  49. package/src/button/stories/button.stories.mdx +17 -11
  50. package/src/button/stories/button.stories.tsx +41 -3
  51. package/src/form/Fieldset/Fieldset.tsx +3 -3
  52. package/src/form/Select.tsx +2 -2
  53. package/src/form/Switch.tsx +1 -1
  54. package/src/form/TextField.tsx +5 -3
  55. package/src/form/Textarea.tsx +3 -3
  56. package/src/form/checkbox/Checkbox.tsx +1 -1
  57. package/src/form/search-field/SearchField.tsx +69 -124
  58. package/src/form/search-field/SearchFieldButton.tsx +47 -0
  59. package/src/form/search-field/SearchFieldClearButton.tsx +49 -0
  60. package/src/form/search-field/SearchFieldInput.tsx +42 -0
  61. package/src/form/search-field/stories/search-field-example.tsx +25 -0
  62. package/src/form/search-field/stories/search-field.stories.mdx +89 -158
  63. package/src/form/search-field/stories/search-field.stories.tsx +154 -62
  64. package/src/loader/stories/loader.stories.mdx +0 -22
  65. package/src/modal/Modal.tsx +19 -12
  66. package/src/modal/stories/modal.stories.tsx +16 -0
  67. package/src/util/index.ts +0 -33
  68. package/cjs/form/search-field/useSearchField.js +0 -31
  69. package/esm/form/search-field/useSearchField.d.ts +0 -10
  70. package/esm/form/search-field/useSearchField.js +0 -25
  71. package/esm/form/search-field/useSearchField.js.map +0 -1
  72. package/src/form/search-field/useSearchField.ts +0 -31
@@ -1,8 +1,9 @@
1
1
  import { Meta, Canvas } from "@storybook/addon-docs";
2
2
  import { SearchField } from "../index";
3
3
 
4
- import { Table } from "@navikt/ds-react";
5
- import { Header } from "@navikt/ds-react-internal";
4
+ import { Example } from "./search-field-example.tsx";
5
+
6
+ import { Search } from "@navikt/ds-icons";
6
7
 
7
8
  <Meta title="ds-react/form/search-field/intro" />
8
9
 
@@ -15,47 +16,24 @@ Komponenten er ikke testet eller gått gjennom et design-review, så anbefalses
15
16
  ## Bruk
16
17
 
17
18
  ```jsx
18
- <SearchField
19
- label="Mollit eiusmod"
20
- description="Ea cupidatat eu sunt commodo"
21
- />
22
- ```
23
-
24
- <Canvas>
25
- <div style={{ width: 300 }}>
26
- <SearchField
27
- label="Mollit eiusmod"
28
- description="Ea cupidatat eu sunt commodo"
29
- />
30
- </div>
31
- </Canvas>
32
-
33
- ## Inverted
34
-
35
- ```jsx
36
- <SearchField
37
- label="Mollit eiusmod"
38
- description="Ea cupidatat eu sunt commodo"
39
- hideLabel
40
- inverted
41
- />
19
+ <SearchField label="Mollit eiusmod" description="Ea cupidatat eu sunt commodo">
20
+ <SearchField.Input />
21
+ <SearchField.Button>
22
+ <Search /> Søk
23
+ </SearchField.Button>
24
+ </SearchField>
42
25
  ```
43
26
 
44
27
  <Canvas>
45
- <div
46
- style={{
47
- width: 300,
48
- padding: "1rem",
49
- background: "var(--navds-global-color-gray-900)",
50
- }}
28
+ <SearchField
29
+ label="Mollit eiusmod"
30
+ description="Ea cupidatat eu sunt commodo"
51
31
  >
52
- <SearchField
53
- inverted
54
- hideLabel
55
- label="Mollit eiusmod"
56
- description="Ea cupidatat eu sunt commodo"
57
- />
58
- </div>
32
+ <SearchField.Input />
33
+ <SearchField.Button>
34
+ <Search /> Søk
35
+ </SearchField.Button>
36
+ </SearchField>
59
37
  </Canvas>
60
38
 
61
39
  ## hideLabel
@@ -68,41 +46,25 @@ Vi har satt `label` som required siden man vil bruke den i sammenheng med denne
68
46
  label="Mollit eiusmod"
69
47
  description="Ea cupidatat eu sunt commodo"
70
48
  hideLabel
71
- />
72
- ```
73
-
74
- <Canvas>
75
- <div style={{ width: 300 }}>
76
- <SearchField
77
- label="Mollit eiusmod"
78
- description="Ea cupidatat eu sunt commodo"
79
- hideLabel
80
- />
81
- </div>
82
- </Canvas>
83
-
84
- ## Uten "clear"-button
85
-
86
- Fjerner "lukke"-knapp som dukker opp når feltet ikke er tomt.
87
-
88
- ```jsx
89
- <SearchField
90
- label="Mollit eiusmod"
91
- description="Ea cupidatat eu sunt commodo"
92
- hideLabel
93
- clearButton={false}
94
- />
49
+ >
50
+ <SearchField.Input />
51
+ <SearchField.Button>
52
+ <Search /> Søk
53
+ </SearchField.Button>
54
+ </SearchField>
95
55
  ```
96
56
 
97
57
  <Canvas>
98
- <div style={{ width: 300 }}>
99
- <SearchField
100
- label="Mollit eiusmod"
101
- description="Ea cupidatat eu sunt commodo"
102
- hideLabel
103
- clearButton={false}
104
- />
105
- </div>
58
+ <SearchField
59
+ label="Mollit eiusmod"
60
+ description="Ea cupidatat eu sunt commodo"
61
+ hideLabel
62
+ >
63
+ <SearchField.Input />
64
+ <SearchField.Button>
65
+ <Search /> Søk
66
+ </SearchField.Button>
67
+ </SearchField>
106
68
  </Canvas>
107
69
 
108
70
  ## Sizing
@@ -113,113 +75,82 @@ Fjerner "lukke"-knapp som dukker opp når feltet ikke er tomt.
113
75
  description="Ea cupidatat eu sunt commodo"
114
76
  hideLabel
115
77
  size="small"
116
- />
78
+ >
79
+ <SearchField.Input />
80
+ <SearchField.Button>
81
+ <Search /> Søk
82
+ </SearchField.Button>
83
+ </SearchField>
117
84
  ```
118
85
 
119
86
  <Canvas>
120
- <div style={{ width: 300 }}>
121
- <SearchField
122
- label="Mollit eiusmod"
123
- description="Ea cupidatat eu sunt commodo"
124
- hideLabel
125
- size="small"
126
- />
127
- </div>
87
+ <SearchField
88
+ label="Mollit eiusmod"
89
+ description="Ea cupidatat eu sunt commodo"
90
+ hideLabel
91
+ size="small"
92
+ >
93
+ <SearchField.Input />
94
+ <SearchField.Button>
95
+ <Search /> Søk
96
+ </SearchField.Button>
97
+ </SearchField>
128
98
  </Canvas>
129
99
 
130
- ## Disabled
100
+ ## Errors
131
101
 
132
102
  ```jsx
133
103
  <SearchField
134
- disabled
135
104
  label="Mollit eiusmod"
136
105
  description="Ea cupidatat eu sunt commodo"
137
106
  hideLabel
138
-
139
- />
140
- <SearchField
141
- disabled
142
- label="Mollit eiusmod"
143
- description="Ea cupidatat eu sunt commodo"
144
- hideLabel
145
- size="small"
146
- />
107
+ error="Error message"
108
+ >
109
+ <SearchField.Input />
110
+ <SearchField.Button>
111
+ <Search /> Søk
112
+ </SearchField.Button>
113
+ </SearchField>
147
114
  ```
148
115
 
149
116
  <Canvas>
150
- <div style={{ width: 300 }}>
151
- <SearchField
152
- disabled
153
- label="Mollit eiusmod"
154
- description="Ea cupidatat eu sunt commodo"
155
- hideLabel
156
- />
157
- </div>
158
117
  <SearchField
159
- disabled
160
118
  label="Mollit eiusmod"
161
119
  description="Ea cupidatat eu sunt commodo"
162
120
  hideLabel
163
- size="small"
164
- />
121
+ error="Error message"
122
+ >
123
+ <SearchField.Input />
124
+ <SearchField.Button>
125
+ <Search /> Søk
126
+ </SearchField.Button>
127
+ </SearchField>
165
128
  </Canvas>
166
129
 
167
- ## Table
130
+ ## ClearButton
168
131
 
169
- <Canvas>
170
- <Table>
171
- <Table.Body>
172
- <Table.Row>
173
- <Table.HeaderCell scope="col">
174
- <SearchField
175
- label="Mollit eiusmod"
176
- description="Ea cupidatat eu sunt commodo"
177
- hideLabel
178
- />
179
- </Table.HeaderCell>
180
- </Table.Row>
181
- <Table.Row>
182
- <Table.HeaderCell scope="col">Name</Table.HeaderCell>
183
- <Table.HeaderCell scope="col">Age</Table.HeaderCell>
184
- <Table.HeaderCell scope="col">Country</Table.HeaderCell>
185
- <Table.HeaderCell scope="col">Points</Table.HeaderCell>
186
- </Table.Row>
187
- <Table.Row>
188
- <Table.HeaderCell scope="row">
189
- Donald SmithDonald Smith
190
- </Table.HeaderCell>
191
- <Table.DataCell>32</Table.DataCell>
192
- <Table.DataCell>USA</Table.DataCell>
193
- <Table.DataCell>38</Table.DataCell>
194
- </Table.Row>
195
- <Table.Row>
196
- <Table.HeaderCell scope="row">Preben Aalborg</Table.HeaderCell>
197
- <Table.DataCell>44</Table.DataCell>
198
- <Table.DataCell>Denmark</Table.DataCell>
199
- <Table.DataCell>11</Table.DataCell>
200
- </Table.Row>
201
- <Table.Row>
202
- <Table.HeaderCell scope="row">Rudolph Bachenmeier</Table.HeaderCell>
203
- <Table.DataCell>32</Table.DataCell>
204
- <Table.DataCell>Germany</Table.DataCell>
205
- <Table.DataCell>70</Table.DataCell>
206
- </Table.Row>
207
- </Table.Body>
208
- </Table>
209
- </Canvas>
132
+ Man kan bruke `SearchField.Clear` for å håndtere clearing av value i `<input />`. For å bruke denne
133
+ kreves det da at `SearchField.Input` er controlled slik at man styrer state selv slik som eksemplet under.
134
+ Hvis man bare ønsker at den bare skal vises når bruker har begynt å skrive, anbefaler vi bare å rendre
135
+ den når inputvalue ikke er empty.
210
136
 
211
- ## Header
212
-
213
- <Header>
214
- <Header.Title href="#">NAV Sykepenger</Header.Title>
215
- <div style={{ margin: "auto 1rem auto auto" }}>
216
- <SearchField
217
- label="Mollit eiusmod"
218
- description="Ea cupidatat eu sunt commodo"
219
- hideLabel
220
- size="small"
221
- inverted
222
- />
137
+ ```jsx
138
+ <SearchField label="Mollit eiusmod" description="Ea cupidatat eu sunt commodo">
139
+ <SearchField.Input value={value} onChange={(e) => setValue(e.target.value)} />
140
+ {!!value && (
141
+ <SearchField.Clear onClick={() => setValue("")}>
142
+ <Close /> Tøm
143
+ </SearchField.Clear>
144
+ )}
145
+ <SearchField.Button>
146
+ <Search /> Søk
147
+ </SearchField.Button>
148
+ </SearchField>
149
+ ```
150
+
151
+ <Canvas>
152
+ <div>
153
+ <Example />
154
+ <Example size="small" />
223
155
  </div>
224
- <Header.User name="Ola Normann" />
225
- </Header>
156
+ </Canvas>
@@ -1,77 +1,174 @@
1
- import { Meta } from "@storybook/react/types-6-0";
2
1
  import React, { useState } from "react";
3
- import { Fieldset } from "../..";
2
+ import { Meta } from "@storybook/react/types-6-0";
3
+ import { Close, Search } from "@navikt/ds-icons";
4
4
  import { SearchField } from "../index";
5
+ import { Fieldset } from "../..";
5
6
  export default {
6
7
  title: "ds-react/form/search-field",
7
8
  component: SearchField,
8
9
  } as Meta;
9
10
 
10
11
  export const All = () => {
11
- const [value, setValue] = useState("");
12
+ const [show, setShow] = useState(false);
12
13
  return (
13
14
  <>
14
15
  <h1>SearchField</h1>
15
- <div>
16
- <SearchField label="Mollit eiusmod" />
17
- <SearchField
18
- label="Mollit eiusmod"
19
- description={<div>Ea cupidatat eu sunt commodo</div>}
20
- />
21
- </div>
16
+ <SearchField
17
+ label="Mollit eiusmod"
18
+ description={<div>Ea cupidatat eu sunt commodo</div>}
19
+ >
20
+ <SearchField.Input />
21
+ <SearchField.Button>
22
+ <Search /> Søk
23
+ </SearchField.Button>
24
+ </SearchField>
25
+ <SearchField
26
+ label="Mollit eiusmod"
27
+ description="Ea cupidatat eu sunt commodo"
28
+ >
29
+ <SearchField.Button>
30
+ <Search /> Søk
31
+ </SearchField.Button>
32
+ <SearchField.Input />
33
+ </SearchField>
34
+
35
+ <h1>SearchField w clearsearch</h1>
36
+ <SearchField
37
+ label="Mollit eiusmod"
38
+ description="Ea cupidatat eu sunt commodo"
39
+ >
40
+ <SearchField.Input />
41
+ <SearchField.Clear>
42
+ <Close />
43
+ </SearchField.Clear>
44
+ <SearchField.Button onClick={() => setShow(!show)}>
45
+ <Search /> Søk
46
+ </SearchField.Button>
47
+ </SearchField>
48
+ <SearchField
49
+ label="Mollit eiusmod"
50
+ description="Ea cupidatat eu sunt commodo"
51
+ >
52
+ <SearchField.Button>
53
+ <Search /> Søk
54
+ </SearchField.Button>
55
+ <SearchField.Clear>
56
+ <Close /> Tøm
57
+ </SearchField.Clear>
58
+ <SearchField.Input />
59
+ </SearchField>
22
60
 
23
61
  <h2>Hidelabel</h2>
24
62
  <SearchField
25
63
  label="Mollit eiusmod"
26
64
  description="Ea cupidatat eu sunt commodo"
27
65
  hideLabel
28
- />
29
-
30
- <h2>Inverted</h2>
31
- <div
32
- style={{
33
- width: 300,
34
- padding: "1rem",
35
- background: "var(--navds-global-color-gray-900)",
36
- }}
37
66
  >
38
- <SearchField
39
- label="Mollit eiusmod"
40
- description="Ea cupidatat eu sunt commodo"
41
- hideLabel
42
- inverted
43
- />
44
- <br />
45
- <SearchField
46
- label="Mollit eiusmod"
47
- description="Ea cupidatat eu sunt commodo"
48
- hideLabel
49
- inverted
50
- value="Søketekst"
51
- />
52
- </div>
67
+ <SearchField.Button>
68
+ <Search /> Søk
69
+ </SearchField.Button>
70
+ <SearchField.Input />
71
+ </SearchField>
53
72
 
54
73
  <h2>SearchField small</h2>
55
74
  <SearchField
56
75
  label="Mollit eiusmod"
57
76
  description="Ea cupidatat eu sunt commodo"
58
77
  size="small"
59
- />
60
- <br />
78
+ >
79
+ <SearchField.Button>
80
+ <Search />
81
+ <span className="navds-sr-only">Søk</span>
82
+ </SearchField.Button>
83
+ <SearchField.Input />
84
+ </SearchField>
85
+
61
86
  <SearchField
62
87
  label="Mollit eiusmod"
63
88
  description="Ea cupidatat eu sunt commodo"
64
89
  size="small"
65
- hideLabel
66
- />
90
+ >
91
+ <SearchField.Input />
92
+ <SearchField.Button>
93
+ <Search />
94
+ <span className="navds-sr-only">Søk</span>
95
+ </SearchField.Button>
96
+ </SearchField>
97
+ <SearchField
98
+ label="Mollit eiusmod"
99
+ description="Ea cupidatat eu sunt commodo"
100
+ size="small"
101
+ >
102
+ <SearchField.Button>
103
+ <Search />
104
+ <span className="navds-sr-only">Søk</span>
105
+ </SearchField.Button>
106
+ <SearchField.Clear>
107
+ <Close /> Tøm
108
+ </SearchField.Clear>
109
+ <SearchField.Input />
110
+ </SearchField>
111
+
112
+ <SearchField
113
+ label="Mollit eiusmod"
114
+ description="Ea cupidatat eu sunt commodo"
115
+ size="small"
116
+ >
117
+ <SearchField.Input />
118
+ <SearchField.Clear>
119
+ <Close /> Tøm
120
+ </SearchField.Clear>
121
+ <SearchField.Button>
122
+ <Search />
123
+ <span className="navds-sr-only">Søk</span>
124
+ </SearchField.Button>
125
+ </SearchField>
126
+
127
+ <h2>SearchField w error</h2>
128
+ <SearchField
129
+ label="Mollit eiusmod"
130
+ description="Ea cupidatat eu sunt commodo"
131
+ error="Errormsg"
132
+ >
133
+ <SearchField.Input />
134
+ <SearchField.Button>
135
+ <Search /> Søk
136
+ </SearchField.Button>
137
+ </SearchField>
138
+ <SearchField
139
+ label="Mollit eiusmod"
140
+ description="Ea cupidatat eu sunt commodo"
141
+ error="Errormsg"
142
+ >
143
+ <SearchField.Button>
144
+ <Search /> Søk
145
+ </SearchField.Button>
146
+ <SearchField.Input />
147
+ </SearchField>
67
148
 
68
149
  <h2>SearchField in Fieldset</h2>
69
150
  <Fieldset legend="Filter" error="Fieldset-error-msg">
70
151
  <SearchField
71
152
  label="Mollit eiusmod"
72
153
  description="Ea cupidatat eu sunt commodo"
154
+ error="Errormsg"
73
155
  hideLabel
74
- />
156
+ >
157
+ <SearchField.Input />
158
+ <SearchField.Button>
159
+ <Search /> Søk
160
+ </SearchField.Button>
161
+ </SearchField>
162
+ <SearchField
163
+ label="Mollit eiusmod"
164
+ description="Ea cupidatat eu sunt commodo"
165
+ hideLabel
166
+ >
167
+ <SearchField.Button>
168
+ <Search /> Søk
169
+ </SearchField.Button>
170
+ <SearchField.Input />
171
+ </SearchField>
75
172
  </Fieldset>
76
173
 
77
174
  <h2>Disabled </h2>
@@ -79,29 +176,24 @@ export const All = () => {
79
176
  disabled
80
177
  label="Mollit eiusmod"
81
178
  description="Ea cupidatat eu sunt commodo"
82
- />
83
- <h2>Controlled state </h2>
84
- <SearchField
85
- value={value}
86
- label="Mollit eiusmod"
87
- description="Ea cupidatat eu sunt commodo"
88
- onChange={(e) => setValue(e)}
89
- onClear={() => setValue("")}
90
- />
91
- <h3>Controlled state no clear</h3>
92
- <SearchField
93
- value={value}
94
- label="Mollit eiusmod"
95
- description="Ea cupidatat eu sunt commodo"
96
- onChange={(e) => setValue(e)}
97
- />
98
- <h2>No clear button</h2>
99
- <SearchField
100
- hideLabel
101
- label="Mollit eiusmod"
102
- description="Ea cupidatat eu sunt commodo"
103
- clearButton={false}
104
- />
179
+ >
180
+ <SearchField.Input />
181
+ <SearchField.Button>
182
+ <Search /> Søk
183
+ </SearchField.Button>
184
+ </SearchField>
185
+ <Fieldset legend="Filter" disabled>
186
+ <SearchField
187
+ label="Mollit eiusmod"
188
+ description="Ea cupidatat eu sunt commodo"
189
+ error="Errormsg"
190
+ >
191
+ <SearchField.Input />
192
+ <SearchField.Button>
193
+ <Search /> Søk
194
+ </SearchField.Button>
195
+ </SearchField>
196
+ </Fieldset>
105
197
  </>
106
198
  );
107
199
  };
@@ -63,25 +63,3 @@ Bakgrunnen kan settes til transparent med `transparent={true}`
63
63
  <Canvas>
64
64
  <Loader size="2xlarge" transparent />
65
65
  </Canvas>
66
-
67
- ## Bruk av loader i knapper
68
-
69
- Husk her å gi brukeren nok informasjon om hvorfor knappen har en Loader. Dette kan gjøres ved å ha god tekst på siden,
70
- i knappen og i `title`-proppen for `Loader`. Unngå også bruk av `Loader` uten noen tekst som hinter til hva som foregår.
71
-
72
- Stylingen er overstyrt for knapper, slik at `transparent` ikke fungerer by-default ved bruk i knapper.
73
- Størrelsen justeres også automatisk, slik at alt man trenger er å sette Loaderen rett inn i knappen.
74
-
75
- ```jsx
76
- <Button>
77
- Laster inn nytt innhold...
78
- <Loader />
79
- </Button>
80
- ```
81
-
82
- <Canvas>
83
- <Button>
84
- Laster inn nytt innhold...
85
- <Loader />
86
- </Button>
87
- </Canvas>
@@ -28,6 +28,11 @@ export interface ModalProps {
28
28
  * User defined classname for modal
29
29
  */
30
30
  className?: string;
31
+ /**
32
+ * Toggles addition of a X-button on modal
33
+ * @default true
34
+ */
35
+ closeButton?: boolean;
31
36
  }
32
37
 
33
38
  interface ModalComponent
@@ -50,6 +55,7 @@ const Modal = forwardRef<ReactModal, ModalProps>(
50
55
  onClose,
51
56
  className,
52
57
  shouldCloseOnOverlayClick = true,
58
+ closeButton = true,
53
59
  ...rest
54
60
  },
55
61
  ref
@@ -77,18 +83,19 @@ const Modal = forwardRef<ReactModal, ModalProps>(
77
83
  onRequestClose={(e) => onModalCloseRequest(e)}
78
84
  >
79
85
  {children}
80
- <Button
81
- className={cl("navds-modal__button", {
82
- "navds-modal__button--shake": shouldCloseOnOverlayClick,
83
- })}
84
- size="small"
85
- variant="secondary"
86
- ref={buttonRef}
87
- aria-label="lukk modalvindu"
88
- onClick={onClose}
89
- >
90
- <Close title="X-ikon for å lukke modal" />
91
- </Button>
86
+ {closeButton && (
87
+ <Button
88
+ className={cl("navds-modal__button", {
89
+ "navds-modal__button--shake": shouldCloseOnOverlayClick,
90
+ })}
91
+ size="small"
92
+ variant="tertiary"
93
+ ref={buttonRef}
94
+ onClick={onClose}
95
+ >
96
+ <Close title="Lukk modalvindu" />
97
+ </Button>
98
+ )}
92
99
  </ReactModal>
93
100
  );
94
101
  }
@@ -11,6 +11,7 @@ Modal.setAppElement("#root");
11
11
  export const All = () => {
12
12
  const [open, setOpen] = useState(true);
13
13
  const [openTwo, setOpenTwo] = useState(false);
14
+ const [openThree, setOpenThree] = useState(false);
14
15
 
15
16
  return (
16
17
  <>
@@ -46,6 +47,21 @@ export const All = () => {
46
47
  </p>
47
48
  </Modal.Content>
48
49
  </Modal>
50
+ <button onClick={() => setOpenThree(true)}>
51
+ Open modal without x-button
52
+ </button>
53
+ <Modal
54
+ open={openThree}
55
+ closeButton={false}
56
+ onClose={() => setOpenThree(false)}
57
+ >
58
+ <Modal.Content>
59
+ <h1>Header</h1>
60
+ <h2>subheader</h2>
61
+ <p>Cupidatat irure ipsum veniam ad in esse.</p>
62
+ <p>Cillum tempor pariatur amet ut laborum Lorem enim enim.</p>
63
+ </Modal.Content>
64
+ </Modal>
49
65
  </>
50
66
  );
51
67
  };