@altinn/altinn-components 0.1.0 → 0.2.1

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 (166) hide show
  1. package/.storybook/StoryDecorator.tsx +27 -0
  2. package/.storybook/ThemeProvider.tsx +16 -0
  3. package/.storybook/main.ts +4 -5
  4. package/.storybook/preview.tsx +31 -29
  5. package/.storybook/storyDecorator.module.css +20 -0
  6. package/.storybook/theme.module.css +3 -0
  7. package/CHANGELOG.md +21 -0
  8. package/CONTRIBUTING.MD +59 -0
  9. package/README.md +33 -1
  10. package/lib/components/Attachment/AttachmentLink.stories.ts +21 -0
  11. package/lib/components/Attachment/AttachmentLink.tsx +20 -0
  12. package/lib/components/Attachment/AttachmentList.stories.ts +39 -0
  13. package/lib/components/Attachment/AttachmentList.tsx +26 -0
  14. package/lib/components/Attachment/attachmentLink.module.css +20 -0
  15. package/lib/components/Attachment/attachmentList.module.css +12 -0
  16. package/lib/components/Attachment/index.ts +2 -0
  17. package/lib/components/Avatar/AvatarGroup.tsx +1 -0
  18. package/lib/components/Avatar/avatar.module.css +2 -0
  19. package/lib/components/Badge/Badge.stories.ts +32 -0
  20. package/lib/components/Badge/Badge.tsx +13 -10
  21. package/lib/components/Badge/badge.module.css +18 -27
  22. package/lib/components/Button/Button.stories.ts +6 -0
  23. package/lib/components/Button/Button.tsx +19 -1
  24. package/lib/components/Button/ButtonBase.tsx +1 -1
  25. package/lib/components/Button/button.module.css +0 -19
  26. package/lib/components/Button/buttonBase.module.css +30 -12
  27. package/lib/components/Button/comboButton.module.css +4 -2
  28. package/lib/components/ContextMenu/ContextMenu.tsx +28 -0
  29. package/lib/components/ContextMenu/contextMenu.module.css +35 -0
  30. package/lib/components/ContextMenu/index.ts +1 -0
  31. package/lib/components/Dialog/Dialog.stories.ts +320 -0
  32. package/lib/components/Dialog/Dialog.tsx +101 -0
  33. package/lib/components/Dialog/DialogActions.stories.ts +60 -0
  34. package/lib/components/Dialog/DialogActions.tsx +80 -0
  35. package/lib/components/Dialog/DialogActivityLog.tsx +18 -0
  36. package/lib/components/Dialog/DialogArticleBase.tsx +10 -0
  37. package/lib/components/Dialog/DialogAttachments.stories.ts +40 -0
  38. package/lib/components/Dialog/DialogAttachments.tsx +25 -0
  39. package/lib/components/Dialog/DialogBase.tsx +10 -0
  40. package/lib/components/Dialog/DialogBodyBase.tsx +17 -0
  41. package/lib/components/Dialog/DialogBorder.tsx +19 -0
  42. package/lib/components/Dialog/DialogContent.stories.ts +26 -0
  43. package/lib/components/Dialog/DialogContent.tsx +24 -0
  44. package/lib/components/Dialog/DialogFooter.tsx +14 -0
  45. package/lib/components/Dialog/DialogHeader.stories.ts +26 -0
  46. package/lib/components/Dialog/DialogHeader.tsx +23 -0
  47. package/lib/components/Dialog/DialogHeaderBase.tsx +10 -0
  48. package/lib/components/Dialog/DialogHeadings.stories.ts +35 -0
  49. package/lib/components/Dialog/DialogHeadings.tsx +77 -0
  50. package/lib/components/Dialog/DialogHistory.stories.ts +67 -0
  51. package/lib/components/Dialog/DialogHistory.tsx +19 -0
  52. package/lib/components/Dialog/DialogList.stories.ts +61 -0
  53. package/lib/components/Dialog/DialogList.tsx +20 -0
  54. package/lib/components/Dialog/DialogListItem.stories.tsx +238 -0
  55. package/lib/components/Dialog/DialogListItem.tsx +114 -0
  56. package/lib/components/Dialog/DialogListItemBase.tsx +50 -0
  57. package/lib/components/Dialog/DialogMetadata.stories.ts +77 -0
  58. package/lib/components/Dialog/DialogMetadata.tsx +56 -0
  59. package/lib/components/Dialog/DialogNav.stories.ts +90 -0
  60. package/lib/components/Dialog/DialogNav.tsx +60 -0
  61. package/lib/components/Dialog/DialogSectionBase.tsx +20 -0
  62. package/lib/components/Dialog/DialogSeenBy.stories.tsx +58 -0
  63. package/lib/components/Dialog/DialogSeenBy.tsx +36 -0
  64. package/lib/components/Dialog/DialogSelect.tsx +23 -0
  65. package/lib/components/Dialog/DialogStatus.stories.ts +57 -0
  66. package/lib/components/Dialog/DialogStatus.tsx +61 -0
  67. package/lib/components/Dialog/DialogTitle.stories.ts +33 -0
  68. package/lib/components/Dialog/DialogTitle.tsx +31 -0
  69. package/lib/components/Dialog/DialogTouchedBy.stories.tsx +27 -0
  70. package/lib/components/Dialog/DialogTouchedBy.tsx +19 -0
  71. package/lib/components/Dialog/dialog.module.css +21 -0
  72. package/lib/components/Dialog/dialogAction.module.css +26 -0
  73. package/lib/components/Dialog/dialogArticleBase.module.css +5 -0
  74. package/lib/components/Dialog/dialogBodyBase.module.css +13 -0
  75. package/lib/components/Dialog/dialogBorder.module.css +42 -0
  76. package/lib/components/Dialog/dialogHeaderBase.module.css +6 -0
  77. package/lib/components/Dialog/dialogHeadings.module.css +24 -0
  78. package/lib/components/Dialog/dialogHistory.module.css +12 -0
  79. package/lib/components/Dialog/dialogListItem.module.css +81 -0
  80. package/lib/components/Dialog/dialogListItemBase.module.css +28 -0
  81. package/lib/components/Dialog/dialogSectionBase.module.css +11 -0
  82. package/lib/components/Dialog/dialogSelect.module.css +34 -0
  83. package/lib/components/Dialog/dialogTitle.module.css +47 -0
  84. package/lib/components/Dialog/index.ts +24 -0
  85. package/lib/components/Header/GlobalMenu.tsx +1 -1
  86. package/lib/components/Header/Header.tsx +3 -3
  87. package/lib/components/Header/HeaderSearch.tsx +1 -1
  88. package/lib/components/History/HistoryBorder.tsx +17 -0
  89. package/lib/components/History/HistoryItem.stories.ts +47 -0
  90. package/lib/components/History/HistoryItem.tsx +64 -0
  91. package/lib/components/History/HistoryList.stories.ts +58 -0
  92. package/lib/components/History/HistoryList.tsx +26 -0
  93. package/lib/components/History/historyBorder.module.css +8 -0
  94. package/lib/components/History/historyItem.module.css +19 -0
  95. package/lib/components/History/historyList.module.css +12 -0
  96. package/lib/components/History/index.ts +2 -0
  97. package/lib/components/Icon/CheckboxCheckedIcon.tsx +28 -0
  98. package/lib/components/Icon/CheckboxIcon.stories.ts +7 -0
  99. package/lib/components/Icon/CheckboxIcon.tsx +6 -18
  100. package/lib/components/Icon/CheckboxUncheckedIcon.tsx +38 -0
  101. package/lib/components/Icon/ProgressIcon.stories.ts +43 -0
  102. package/lib/components/Icon/ProgressIcon.tsx +44 -0
  103. package/lib/components/Icon/RadioCheckedIcon.tsx +29 -0
  104. package/lib/components/Icon/RadioIcon.stories.ts +7 -0
  105. package/lib/components/Icon/RadioIcon.tsx +7 -19
  106. package/lib/components/Icon/RadioUncheckedIcon.tsx +30 -0
  107. package/lib/components/Icon/checkboxIcon.module.css +2 -0
  108. package/lib/components/Icon/index.ts +1 -0
  109. package/lib/components/Icon/progressIcon.module.css +29 -0
  110. package/lib/components/Layout/Layout.stories.ts +0 -3
  111. package/lib/components/List/List.tsx +20 -0
  112. package/lib/components/List/ListBase.tsx +19 -0
  113. package/lib/components/List/ListItem.stories.tsx +208 -0
  114. package/lib/components/List/ListItem.tsx +70 -0
  115. package/lib/components/List/ListItemBase.tsx +62 -0
  116. package/lib/components/List/ListItemLabel.tsx +29 -0
  117. package/lib/components/List/ListItemMedia.tsx +59 -0
  118. package/lib/components/List/index.ts +6 -0
  119. package/lib/components/List/listBase.module.css +16 -0
  120. package/lib/components/List/listItemBase.module.css +86 -0
  121. package/lib/components/List/listItemLabel.module.css +55 -0
  122. package/lib/components/List/listItemMedia.module.css +41 -0
  123. package/lib/components/Menu/Menu.stories.ts +46 -27
  124. package/lib/components/Menu/Menu.tsx +3 -3
  125. package/lib/components/Menu/MenuItem.stories.ts +12 -5
  126. package/lib/components/Menu/MenuItem.tsx +4 -3
  127. package/lib/components/Menu/MenuItemBase.tsx +7 -7
  128. package/lib/components/Menu/MenuItemLabel.tsx +4 -4
  129. package/lib/components/Menu/MenuItemMedia.tsx +2 -2
  130. package/lib/components/Menu/MenuOption.stories.ts +4 -2
  131. package/lib/components/Menu/MenuOption.tsx +4 -4
  132. package/lib/components/Menu/menuItemBase.module.css +72 -0
  133. package/lib/components/Menu/menuItemLabel.module.css +22 -0
  134. package/lib/components/Menu/menuItemMedia.module.css +36 -0
  135. package/lib/components/Menu/menuOption.module.css +6 -8
  136. package/lib/components/Menu/useClickOutside.ts +1 -0
  137. package/lib/components/Menu/useEscapeKey.ts +1 -0
  138. package/lib/components/Meta/MetaBase.tsx +15 -0
  139. package/lib/components/Meta/MetaItem.stories.ts +25 -0
  140. package/lib/components/Meta/MetaItem.tsx +31 -0
  141. package/lib/components/Meta/MetaItemBase.tsx +46 -0
  142. package/lib/components/Meta/MetaItemLabel.tsx +20 -0
  143. package/lib/components/Meta/MetaItemMedia.tsx +22 -0
  144. package/lib/components/Meta/MetaList.stories.ts +29 -0
  145. package/lib/components/Meta/MetaList.tsx +43 -0
  146. package/lib/components/Meta/MetaProgress.stories.ts +29 -0
  147. package/lib/components/Meta/MetaProgress.tsx +26 -0
  148. package/lib/components/Meta/MetaTimestamp.stories.ts +33 -0
  149. package/lib/components/Meta/MetaTimestamp.tsx +29 -0
  150. package/lib/components/Meta/index.ts +8 -0
  151. package/lib/components/Meta/meta.module.css +6 -0
  152. package/lib/components/Meta/metaItem.module.css +107 -0
  153. package/lib/components/Meta/metaList.module.css +15 -0
  154. package/lib/components/Toolbar/ToolbarAdd.tsx +1 -1
  155. package/lib/components/Typography/Typography.tsx +21 -0
  156. package/lib/components/Typography/index.ts +1 -0
  157. package/lib/components/Typography/typography.module.css +56 -0
  158. package/lib/components/index.ts +14 -0
  159. package/lib/css/global.css +2 -0
  160. package/lib/css/shadows.css +7 -0
  161. package/lib/css/theme-article.css +15 -0
  162. package/lib/css/theme.css +5 -7
  163. package/package.json +4 -2
  164. package/renovate.json +1 -3
  165. package/.storybook/preview.css +0 -18
  166. /package/lib/components/Toolbar/{index.js → index.ts} +0 -0
@@ -0,0 +1,55 @@
1
+ /* label */
2
+
3
+ .label {
4
+ display: flex;
5
+ justify-content: center;
6
+ }
7
+
8
+ .label[data-size="xs"] {
9
+ align-items: center;
10
+ column-gap: 0.25em;
11
+ font-size: 0.875rem;
12
+ }
13
+
14
+ .label[data-size="sm"] {
15
+ align-items: center;
16
+ column-gap: 0.25rem;
17
+ }
18
+
19
+ .label[data-size="md"] {
20
+ flex-direction: column;
21
+ }
22
+
23
+ .label[data-size="lg"] {
24
+ flex-direction: column;
25
+ }
26
+
27
+ .label[data-size="xl"] {
28
+ flex-direction: column;
29
+ }
30
+
31
+ /* title + descr */
32
+
33
+ .title {
34
+ font-weight: 600;
35
+ margin: 0;
36
+ }
37
+
38
+ .title[data-size="lg"] {
39
+ font-size: 1.125rem;
40
+ }
41
+
42
+ .title[data-size="xl"] {
43
+ font-size: 1.25rem;
44
+ }
45
+
46
+ .description {
47
+ color: var(--theme-text-subtle);
48
+ margin: 0;
49
+ }
50
+
51
+ .description[data-size="md"],
52
+ .description[data-size="lg"],
53
+ .description[data-size="xl"] {
54
+ font-size: 0.875em;
55
+ }
@@ -0,0 +1,41 @@
1
+ /* media */
2
+
3
+ .media {
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ min-width: 1em;
8
+ height: 1em;
9
+ }
10
+
11
+ .media {
12
+ font-size: 1.5rem;
13
+ }
14
+
15
+ .media[data-size="xs"] {
16
+ font-size: 1.25rem;
17
+ }
18
+
19
+ .media[data-size="md"] {
20
+ font-size: 1.875rem;
21
+ }
22
+
23
+ .media[data-size="md"] .icon {
24
+ font-size: 1.5rem;
25
+ }
26
+
27
+ .media[data-size="lg"] {
28
+ font-size: 2.25rem;
29
+ }
30
+
31
+ .media[data-size="lg"] .icon {
32
+ font-size: 1.75rem;
33
+ }
34
+
35
+ .media[data-size="xl"] {
36
+ font-size: 2.75rem;
37
+ }
38
+
39
+ .media[data-size="xl"] .icon {
40
+ font-size: 2rem;
41
+ }
@@ -14,7 +14,6 @@ type Story = StoryObj<typeof meta>;
14
14
 
15
15
  export const GlobalMenu: Story = {
16
16
  args: {
17
- theme: 'global',
18
17
  groups: {
19
18
  settings: {
20
19
  defaultItemColor: 'default',
@@ -38,6 +37,10 @@ export const GlobalMenu: Story = {
38
37
  size: 'lg',
39
38
  icon: 'inbox',
40
39
  title: 'Innboks',
40
+ badge: {
41
+ color: 'alert',
42
+ label: '4',
43
+ },
41
44
  },
42
45
  {
43
46
  id: 'access',
@@ -45,6 +48,10 @@ export const GlobalMenu: Story = {
45
48
  size: 'lg',
46
49
  icon: 'bookmark',
47
50
  title: 'Tilganger',
51
+ badge: {
52
+ color: 'alert',
53
+ label: '2',
54
+ },
48
55
  },
49
56
  {
50
57
  id: 'access',
@@ -65,7 +72,6 @@ export const GlobalMenu: Story = {
65
72
 
66
73
  export const CollapsibleGlobalMenu: Story = {
67
74
  args: {
68
- theme: 'global',
69
75
  groups: {
70
76
  settings: {
71
77
  defaultItemColor: 'default',
@@ -89,7 +95,6 @@ export const CollapsibleGlobalMenu: Story = {
89
95
  size: 'lg',
90
96
  icon: 'inbox',
91
97
  title: 'Innboks',
92
- badge: '4',
93
98
  collapsible: true,
94
99
  items: [
95
100
  {
@@ -104,14 +109,12 @@ export const CollapsibleGlobalMenu: Story = {
104
109
  icon: 'file-checkmark',
105
110
  selected: true,
106
111
  title: 'Sendt',
107
- badge: 2,
108
112
  },
109
113
  {
110
114
  id: 'bookmarks',
111
115
  group: '3',
112
116
  icon: 'bookmark',
113
117
  title: 'Lagrede søk',
114
- badge: 11,
115
118
  },
116
119
  {
117
120
  id: 'arkiv',
@@ -154,7 +157,7 @@ export const CollapsibleGlobalMenu: Story = {
154
157
  export const ExpandedGlobalMenu: Story = {
155
158
  args: {
156
159
  ...CollapsibleGlobalMenu.args,
157
- items: [...(CollapsibleGlobalMenu?.args?.items ?? [])].map((item) => {
160
+ items: [...CollapsibleGlobalMenu.args.items].map((item) => {
158
161
  if (item.collapsible) {
159
162
  return {
160
163
  ...item,
@@ -169,7 +172,6 @@ export const ExpandedGlobalMenu: Story = {
169
172
 
170
173
  export const DrilldownMenu: Story = {
171
174
  args: {
172
- theme: 'global',
173
175
  color: 'subtle',
174
176
  groups: {
175
177
  'level-1': {
@@ -196,18 +198,18 @@ export const DrilldownMenu: Story = {
196
198
  expanded: true,
197
199
  items: [
198
200
  {
201
+ id: 'c1',
199
202
  group: 'level-3',
200
- name: 'c1',
201
203
  title: 'Kategori 1',
202
204
  },
203
205
  {
204
206
  group: 'level-3',
205
- name: 'c2',
207
+ id: 'c2',
206
208
  title: 'Kategori 2',
207
209
  },
208
210
  {
209
211
  group: 'level-3',
210
- name: 'c3',
212
+ id: 'c3',
211
213
  title: 'Kategori 3',
212
214
  },
213
215
  ],
@@ -220,9 +222,7 @@ export const DrilldownMenu: Story = {
220
222
 
221
223
  export const InboxMenu: Story = {
222
224
  args: {
223
- theme: 'global',
224
225
  groups: {},
225
-
226
226
  items: [
227
227
  {
228
228
  id: 'innboks',
@@ -231,13 +231,16 @@ export const InboxMenu: Story = {
231
231
  icon: 'inbox',
232
232
  title: 'Innboks',
233
233
  color: 'strong',
234
- badge: 4,
234
+ badge: { color: 'alert', label: '4' },
235
235
  },
236
236
  {
237
237
  id: 'utkast',
238
238
  group: '2',
239
239
  icon: 'doc-pencil',
240
240
  title: 'Utkast',
241
+ badge: {
242
+ label: '3',
243
+ },
241
244
  },
242
245
  {
243
246
  id: 'sendt',
@@ -245,20 +248,27 @@ export const InboxMenu: Story = {
245
248
  icon: 'file-checkmark',
246
249
  selected: true,
247
250
  title: 'Sendt',
248
- badge: 2,
251
+ badge: {
252
+ label: '2',
253
+ },
249
254
  },
250
255
  {
251
256
  id: 'lagret',
252
257
  group: '3',
253
258
  icon: 'bookmark',
254
259
  title: 'Lagrede søk',
255
- badge: 11,
260
+ badge: {
261
+ label: '5',
262
+ },
256
263
  },
257
264
  {
258
265
  id: 'arkivert',
259
266
  group: '4',
260
267
  icon: 'archive',
261
268
  title: 'Arkivert',
269
+ badge: {
270
+ label: '100+',
271
+ },
262
272
  },
263
273
  {
264
274
  id: 'papirkurv',
@@ -266,16 +276,18 @@ export const InboxMenu: Story = {
266
276
  disabled: true,
267
277
  icon: 'trash',
268
278
  title: 'Papirkurv',
279
+ badge: {
280
+ label: '45',
281
+ },
269
282
  },
270
283
  ],
271
284
 
272
- color: 'subtle',
285
+ defaultItemColor: 'subtle',
273
286
  },
274
287
  };
275
288
 
276
289
  export const InboxMenuWithShortcuts = {
277
290
  args: {
278
- theme: 'global',
279
291
  groups: {
280
292
  ...InboxMenu.args?.groups,
281
293
  shortcuts: {
@@ -284,7 +296,7 @@ export const InboxMenuWithShortcuts = {
284
296
  },
285
297
  },
286
298
  items: [
287
- ...(InboxMenu.args?.items ?? []),
299
+ ...(InboxMenu?.args?.items ?? []),
288
300
  {
289
301
  id: 'users',
290
302
  group: 'shortcuts',
@@ -303,7 +315,6 @@ export const InboxMenuWithShortcuts = {
303
315
 
304
316
  export const PersonMenu: Story = {
305
317
  args: {
306
- theme: 'global',
307
318
  groups: {},
308
319
  items: [
309
320
  {
@@ -352,7 +363,6 @@ export const PersonMenu: Story = {
352
363
 
353
364
  export const CompanyMenu: Story = {
354
365
  args: {
355
- theme: 'global',
356
366
  groups: {},
357
367
  items: [
358
368
  {
@@ -395,12 +405,12 @@ export const CompanyMenu: Story = {
395
405
 
396
406
  export const AccountMenu: Story = {
397
407
  args: {
398
- theme: 'global',
399
408
  groups: {
400
409
  a1: {
401
410
  title: 'Deg selv, favoritter og grupper',
402
411
  },
403
412
  b1: {
413
+ id: 'companies',
404
414
  title: 'Andre kontoer',
405
415
  },
406
416
  },
@@ -413,7 +423,9 @@ export const AccountMenu: Story = {
413
423
  name: 'Dolly Duck',
414
424
  },
415
425
  title: 'Dolly Duck',
416
- badge: '15',
426
+ badge: {
427
+ label: '15',
428
+ },
417
429
  },
418
430
  {
419
431
  id: '2',
@@ -423,7 +435,9 @@ export const AccountMenu: Story = {
423
435
  name: 'Bergen Bar',
424
436
  },
425
437
  title: 'Bergen Bar',
426
- badge: 21,
438
+ badge: {
439
+ label: '21',
440
+ },
427
441
  },
428
442
  {
429
443
  id: '3',
@@ -433,7 +447,9 @@ export const AccountMenu: Story = {
433
447
  name: 'Sportsklubben Brann',
434
448
  },
435
449
  title: 'Sportsklubben Brann',
436
- badge: '4',
450
+ badge: {
451
+ label: '4',
452
+ },
437
453
  },
438
454
  {
439
455
  id: '4',
@@ -450,6 +466,9 @@ export const AccountMenu: Story = {
450
466
  ],
451
467
  },
452
468
  title: 'Alle virksomheter',
469
+ badge: {
470
+ label: '45',
471
+ },
453
472
  },
454
473
  {
455
474
  id: '5',
@@ -468,6 +487,9 @@ export const AccountMenu: Story = {
468
487
  name: 'Haralds gym',
469
488
  },
470
489
  title: 'Haralds gym',
490
+ badge: {
491
+ label: '2',
492
+ },
471
493
  },
472
494
  {
473
495
  id: '7',
@@ -487,9 +509,6 @@ export const AccountMenuWithSearch: Story = {
487
509
  ...AccountMenu.args,
488
510
  search: {
489
511
  placeholder: 'Søk i kontoer',
490
- name: 'search',
491
- value: '',
492
- onChange: () => {},
493
512
  },
494
513
  },
495
514
  };
@@ -8,7 +8,7 @@ import type { MenuItemColor, MenuItemSize } from './MenuItemBase';
8
8
  import { MenuItem, type MenuItemProps } from './MenuItem';
9
9
  import styles from './menu.module.css';
10
10
 
11
- export type MenuTheme = 'global' | 'neutral' | 'company' | 'person';
11
+ export type MenuTheme = 'inherit' | 'global' | 'neutral' | 'company' | 'person';
12
12
 
13
13
  interface MenuItemsGroupProps {
14
14
  title?: string;
@@ -20,11 +20,11 @@ interface MenuItemsGroupProps {
20
20
  export type MenuGroups = Record<string, MenuItemsGroupProps>;
21
21
 
22
22
  export interface MenuProps {
23
+ items: MenuItemProps[];
23
24
  theme?: MenuTheme;
24
25
  defaultItemColor?: MenuItemColor;
25
26
  defaultItemSize?: MenuItemSize;
26
27
  groups?: MenuGroups;
27
- items?: MenuItemProps[];
28
28
  search?: MenuSearchProps;
29
29
  }
30
30
 
@@ -107,7 +107,7 @@ export const MenuItems = ({
107
107
  };
108
108
 
109
109
  export const Menu = ({
110
- theme,
110
+ theme = 'inherit',
111
111
  defaultItemColor = 'subtle',
112
112
  defaultItemSize = 'sm',
113
113
  groups,
@@ -6,7 +6,9 @@ const meta = {
6
6
  component: MenuItem,
7
7
  tags: ['autodocs'],
8
8
  parameters: {},
9
- args: {},
9
+ args: {
10
+ id: 'inbox',
11
+ },
10
12
  } satisfies Meta<typeof MenuItem>;
11
13
 
12
14
  export default meta;
@@ -23,7 +25,9 @@ export const DefaultBadge: Story = {
23
25
  args: {
24
26
  icon: 'inbox',
25
27
  title: 'Innboks',
26
- badge: 4,
28
+ badge: {
29
+ label: '4',
30
+ },
27
31
  },
28
32
  };
29
33
 
@@ -36,13 +40,16 @@ export const Large: Story = {
36
40
  },
37
41
  };
38
42
 
39
- export const LargeBadge: Story = {
43
+ export const AlertBadge: Story = {
40
44
  args: {
41
45
  size: 'lg',
42
46
  icon: 'inbox',
43
47
  title: 'Innboks',
44
- badge: 4,
45
48
  color: 'strong',
49
+ badge: {
50
+ color: 'alert',
51
+ label: '4',
52
+ },
46
53
  },
47
54
  };
48
55
 
@@ -81,8 +88,8 @@ export const PersonGroup: Story = {
81
88
  export const Company: Story = {
82
89
  args: {
83
90
  avatar: {
84
- name: 'Sportsklubben Brann',
85
91
  type: 'company',
92
+ name: 'Sportsklubben Brann',
86
93
  },
87
94
  title: 'Sportsklubben Brann',
88
95
  },
@@ -1,5 +1,6 @@
1
- import type { ElementType, ReactNode } from 'react';
1
+ import type { ElementType, MouseEventHandler, ReactNode } from 'react';
2
2
  import type { AvatarGroupProps, AvatarProps } from '../Avatar';
3
+ import type { BadgeProps } from '../Badge';
3
4
  import type { IconName } from '../Icon';
4
5
  import { MenuItemBase, type MenuItemColor, type MenuItemSize } from './MenuItemBase';
5
6
  import { MenuItemLabel } from './MenuItemLabel';
@@ -11,7 +12,7 @@ export interface MenuItemProps {
11
12
  as?: ElementType;
12
13
  color?: MenuItemColor;
13
14
  href?: string;
14
- onClick?: () => void;
15
+ onClick?: MouseEventHandler;
15
16
  hidden?: boolean;
16
17
  collapsible?: boolean;
17
18
  expanded?: boolean;
@@ -22,7 +23,7 @@ export interface MenuItemProps {
22
23
  title?: string;
23
24
  description?: string;
24
25
  label?: string;
25
- badge?: string;
26
+ badge?: BadgeProps;
26
27
  icon?: IconName;
27
28
  avatar?: AvatarProps;
28
29
  avatarGroup?: AvatarGroupProps;
@@ -1,8 +1,8 @@
1
1
  import cx from 'classnames';
2
2
  import type { ElementType, ReactNode } from 'react';
3
- import { Badge } from '../Badge';
3
+ import { Badge, type BadgeProps } from '../Badge';
4
4
  import { Icon, type IconName } from '../Icon';
5
- import styles from './menuItem.module.css';
5
+ import styles from './menuItemBase.module.css';
6
6
 
7
7
  export type MenuItemColor = 'default' | 'subtle' | 'strong' | 'company' | 'person';
8
8
  export type MenuItemSize = 'sm' | 'md' | 'lg';
@@ -13,7 +13,7 @@ export interface MenuItemBaseProps {
13
13
  children?: ReactNode;
14
14
  size?: MenuItemSize;
15
15
  linkIcon?: IconName;
16
- badge?: string | number | undefined;
16
+ badge?: BadgeProps;
17
17
  collapsible?: boolean;
18
18
  expanded?: boolean;
19
19
  selected?: boolean;
@@ -47,15 +47,15 @@ export const MenuItemBase = ({
47
47
  aria-expanded={expanded}
48
48
  aria-disabled={disabled}
49
49
  aria-selected={selected}
50
- className={cx(styles?.item, className)}
50
+ className={cx(styles.item, className)}
51
51
  {...rest}
52
52
  >
53
53
  <div className={styles.content}>
54
54
  {children}
55
- {badge && <Badge>{badge}</Badge>}
55
+ {badge && <Badge {...badge} />}
56
56
  </div>
57
- <div className={styles?.action}>
58
- {applicableIcon && <Icon name={applicableIcon} className={styles?.actionIcon} />}
57
+ <div className={styles.action}>
58
+ {applicableIcon && <Icon name={applicableIcon} className={styles.actionIcon} />}
59
59
  </div>
60
60
  </Component>
61
61
  );
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { MenuItemSize } from './MenuItemBase';
3
- import styles from './menuItem.module.css';
3
+ import styles from './menuItemLabel.module.css';
4
4
 
5
5
  export interface MenuItemLabelProps {
6
6
  size?: MenuItemSize;
@@ -12,15 +12,15 @@ export interface MenuItemLabelProps {
12
12
 
13
13
  export const MenuItemLabel = ({ size = 'sm', label, title, description, children }: MenuItemLabelProps) => {
14
14
  return (
15
- <span className={styles?.label} data-size={size}>
15
+ <span className={styles.label} data-size={size}>
16
16
  {children ? (
17
17
  children
18
18
  ) : (
19
19
  <>
20
- <strong className={styles?.title} data-size={size}>
20
+ <strong className={styles.title} data-size={size}>
21
21
  {title || label}
22
22
  </strong>
23
- <span className={styles?.description} data-size={size}>
23
+ <span className={styles.description} data-size={size}>
24
24
  {description}
25
25
  </span>
26
26
  </>
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
2
2
  import { Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize } from '../Avatar';
3
3
  import { Icon, type IconName } from '../Icon';
4
4
  import type { MenuItemColor, MenuItemSize } from './MenuItemBase';
5
- import styles from './menuItem.module.css';
5
+ import styles from './menuItemMedia.module.css';
6
6
 
7
7
  interface MenuItemMediaProps {
8
8
  color?: MenuItemColor;
@@ -33,7 +33,7 @@ export const MenuItemMedia = ({ size = 'sm', color, icon, avatar, avatarGroup, c
33
33
 
34
34
  return (
35
35
  <div className={styles.media} data-size={size} data-color={!icon ? null : color}>
36
- {icon ? <Icon name={icon} variant={color === 'strong' ? 'solid' : 'outline'} className={styles?.icon} /> : ''}
36
+ {icon && <Icon name={icon} variant={color === 'strong' ? 'solid' : 'outline'} className={styles.icon} />}
37
37
  {avatar && <Avatar {...avatar} size={sizeMap?.avatar[size] as AvatarSize} />}
38
38
  {avatarGroup && <AvatarGroup {...avatarGroup} size={sizeMap?.avatarGroup[size] as AvatarSize} />}
39
39
  {children}
@@ -1,5 +1,4 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
-
3
2
  import { MenuOption } from './MenuOption';
4
3
 
5
4
  const meta = {
@@ -7,7 +6,10 @@ const meta = {
7
6
  component: MenuOption,
8
7
  tags: ['autodocs'],
9
8
  parameters: {},
10
- args: {},
9
+ args: {
10
+ value: '',
11
+ label: 'Label',
12
+ },
11
13
  } satisfies Meta<typeof MenuOption>;
12
14
 
13
15
  export default meta;
@@ -33,10 +33,10 @@ export const MenuOption = ({
33
33
  onChange,
34
34
  }: MenuOptionProps) => {
35
35
  return (
36
- <MenuItemBase className={styles?.label} disabled={disabled} selected={checked} size={size} as="label">
37
- <input className={styles?.input} name={name} value={value} type={type} checked={checked} onChange={onChange} />
38
- {type === 'checkbox' && <CheckboxIcon checked={checked} className={styles.icon} />}
39
- {type === 'radio' && <RadioIcon checked={checked} className={styles.icon} />}
36
+ <MenuItemBase className={styles.label} disabled={disabled} selected={checked} size={size} as="label">
37
+ <input className={styles.input} name={name} value={value} type={type} checked={checked} onChange={onChange} />
38
+ {type === 'checkbox' && <CheckboxIcon checked={checked} hover={true} className={styles.icon} />}
39
+ {type === 'radio' && <RadioIcon checked={checked} hover={true} className={styles.icon} />}
40
40
  <MenuItemLabel title={title} description={description} size={size}>
41
41
  {label}
42
42
  </MenuItemLabel>
@@ -0,0 +1,72 @@
1
+ .item {
2
+ background-color: transparent;
3
+ display: flex;
4
+ align-items: center;
5
+ column-gap: 4px;
6
+ border: 0;
7
+ user-select: none;
8
+ cursor: pointer;
9
+ margin: 0.5rem 0;
10
+ }
11
+
12
+ .item[aria-disabled="true"] {
13
+ opacity: 0.5;
14
+ pointer-events: none;
15
+ }
16
+
17
+ /* size */
18
+
19
+ .item[data-size="sm"] {
20
+ min-height: 44px;
21
+ }
22
+
23
+ /* content */
24
+
25
+ .content {
26
+ display: flex;
27
+ width: 100%;
28
+ align-items: center;
29
+ column-gap: 6px;
30
+ padding: 6px;
31
+ }
32
+
33
+ .action {
34
+ display: flex;
35
+ justify-content: center;
36
+ align-items: center;
37
+ padding: 10px;
38
+ }
39
+
40
+ .actionIcon {
41
+ font-size: 1.5rem;
42
+ }
43
+
44
+ /* colors */
45
+
46
+ .item:hover {
47
+ background-color: var(--theme-background-default);
48
+ }
49
+
50
+ .item[aria-selected="true"] {
51
+ background-color: var(--theme-background-default);
52
+ }
53
+
54
+ /* company */
55
+
56
+ .item[data-color="company"]:hover {
57
+ background-color: var(--company-background-subtle);
58
+ }
59
+
60
+ .item[data-color="company"][aria-selected="true"] {
61
+ background-color: var(--company-surface-default);
62
+ }
63
+
64
+ /* person */
65
+
66
+ .item[data-color="person"]:hover {
67
+ background-color: var(--person-background-subtle);
68
+ }
69
+
70
+ .item[data-color="person"][aria-selected="true"] {
71
+ background-color: var(--person-surface-default);
72
+ }
@@ -0,0 +1,22 @@
1
+ .label {
2
+ display: flex;
3
+ flex-direction: column;
4
+ padding: 0 0.25rem;
5
+ }
6
+
7
+ .title[data-size="lg"] {
8
+ font-size: 1.125rem;
9
+ line-height: 1.25;
10
+ font-weight: 500;
11
+ }
12
+
13
+ .title[data-size="sm"] {
14
+ font-size: 1rem;
15
+ line-height: 1.25;
16
+ font-weight: 400;
17
+ }
18
+
19
+ .description {
20
+ font-size: 14px;
21
+ color: var(--theme-text-subtle);
22
+ }