@altinn/altinn-components 0.4.0 → 0.4.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 (28) hide show
  1. package/.storybook/main.ts +1 -1
  2. package/CHANGELOG.md +7 -0
  3. package/lib/components/Dialog/DialogListItem.tsx +0 -1
  4. package/lib/components/Dialog/DialogNav.tsx +1 -1
  5. package/lib/components/Dialog/dialogNav.module.css +12 -0
  6. package/lib/components/Header/Header.tsx +0 -5
  7. package/lib/components/History/HistoryAttachments.tsx +22 -0
  8. package/lib/components/History/HistoryItem.stories.ts +27 -18
  9. package/lib/components/History/HistoryItem.tsx +7 -15
  10. package/lib/components/History/HistoryList.stories.ts +34 -22
  11. package/lib/components/Layout/LayoutBase.tsx +1 -1
  12. package/lib/components/Layout/index.tsx +1 -0
  13. package/lib/components/Layout/layoutBase.module.css +2 -14
  14. package/lib/components/Layout/layoutContent.module.css +6 -1
  15. package/lib/components/Layout/layoutSidebar.module.css +1 -0
  16. package/lib/components/LayoutAction/ActionFooter.stories.tsx +1 -1
  17. package/lib/components/LayoutAction/ActionHeader.tsx +1 -1
  18. package/lib/components/LayoutAction/ActionMenu.stories.tsx +1 -0
  19. package/lib/components/LayoutAction/ActionMenu.tsx +5 -2
  20. package/lib/components/LayoutAction/actionMenu.module.css +8 -6
  21. package/lib/components/Menu/{MenuItem.stories.ts → MenuItem.stories.tsx} +32 -0
  22. package/lib/components/Menu/MenuItemBase.tsx +1 -1
  23. package/lib/components/Menu/{menuItem.module.css → __menuItem.module.css} +0 -6
  24. package/lib/components/Menu/menuItemBase.module.css +12 -18
  25. package/lib/components/Menu/menuItemMedia.module.css +2 -0
  26. package/lib/css/global.css +1 -0
  27. package/lib/css/theme-global-dark.css +19 -0
  28. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { StorybookConfig } from "@storybook/react-vite";
2
2
 
3
3
  const config: StorybookConfig = {
4
- stories: ["../lib/components/**/*.stories.@(ts|tsx)"],
4
+ stories: ["../lib/components/**/*.stories.@(ts|tsx)", "../lib/stories/**/*.stories.@(ts|tsx)"],
5
5
  addons: [
6
6
  "@storybook/addon-onboarding",
7
7
  "@storybook/addon-links",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.1](https://github.com/Altinn/altinn-components/compare/v0.4.0...v0.4.1) (2024-11-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * css changes to dialog ([#43](https://github.com/Altinn/altinn-components/issues/43)) ([79e3287](https://github.com/Altinn/altinn-components/commit/79e3287dc2efbce8ba7a9c0b94f955514289c0d3))
9
+
3
10
  ## [0.4.0](https://github.com/Altinn/altinn-components/compare/v0.3.0...v0.4.0) (2024-11-08)
4
11
 
5
12
 
@@ -84,7 +84,6 @@ export const DialogListItem = ({
84
84
  attachmentsCount,
85
85
  title,
86
86
  summary,
87
- onClick,
88
87
  ...rest
89
88
  }: DialogListItemProps) => {
90
89
  return (
@@ -6,7 +6,7 @@ import { ContextMenu, type ContextMenuProps } from '../ContextMenu/ContextMenu.t
6
6
  import { MetaTimestamp } from '../Meta';
7
7
  import { DialogStatus, type DialogStatusProps } from './DialogStatus';
8
8
  import { DialogTouchedBy, type DialogTouchedByActor } from './DialogTouchedBy';
9
- import styles from './dialog.module.css';
9
+ import styles from './dialogNav.module.css';
10
10
 
11
11
  export interface DialogBackButtonProps {
12
12
  as?: ElementType;
@@ -0,0 +1,12 @@
1
+ .nav {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: space-between;
5
+ padding: 0.5rem;
6
+ }
7
+
8
+ .action {
9
+ display: flex;
10
+ align-items: center;
11
+ column-gap: .5rem;
12
+ }
@@ -12,11 +12,6 @@ import styles from './header.module.css';
12
12
 
13
13
  export type HeaderExpandedType = 'search' | 'menu' | null;
14
14
 
15
- export interface HeaderAccountProps {
16
- type?: string;
17
- name?: string;
18
- }
19
-
20
15
  export interface HeaderProps {
21
16
  menu: GlobalMenuProps;
22
17
  search?: HeaderSearchProps;
@@ -0,0 +1,22 @@
1
+ import { type AttachmentLinkProps, AttachmentList } from '../Attachment';
2
+ import { MetaItem } from '../Meta';
3
+
4
+ export interface HistoryAttachmentsProps {
5
+ title?: string;
6
+ items?: AttachmentLinkProps[];
7
+ }
8
+
9
+ export const HistoryAttachments = ({ title = 'Attachments', items }: HistoryAttachmentsProps) => {
10
+ if (!items?.length) {
11
+ return null;
12
+ }
13
+
14
+ return (
15
+ <section>
16
+ <MetaItem as="h2" size="xs">
17
+ {title}
18
+ </MetaItem>
19
+ <AttachmentList size="lg" items={items} />
20
+ </section>
21
+ );
22
+ };
@@ -9,7 +9,8 @@ const meta = {
9
9
  tags: ['autodocs'],
10
10
  parameters: {},
11
11
  args: {
12
- createdAt: '2004-09-22 13:34',
12
+ createdAt: '2024-09-22 13:34',
13
+ createdAtLabel: '22. september 2024 kl 13.34',
13
14
  createdBy: {
14
15
  name: 'Eirik Horneland',
15
16
  },
@@ -26,22 +27,30 @@ export const Default: Story = {
26
27
 
27
28
  export const Attachments: Story = {
28
29
  args: {
29
- attachments: [
30
- {
31
- label: '1-0 Castro.pdf',
32
- },
33
- {
34
- label: '2-0 Kornvig.pdf',
35
- },
36
- {
37
- label: '3-0 Kartum.pdf',
38
- },
39
- {
40
- label: '3-1 Zinkernagel.pdf',
41
- },
42
- {
43
- label: '4-1 Castro.pdf',
44
- },
45
- ],
30
+ attachments: {
31
+ title: '6 vedlegg',
32
+ items: [
33
+ {
34
+ href: '#',
35
+ label: '1-0 Castro.pdf',
36
+ },
37
+ {
38
+ href: '#',
39
+ label: '2-0 Kornvig.pdf',
40
+ },
41
+ {
42
+ href: '#',
43
+ label: '3-0 Kartum.pdf',
44
+ },
45
+ {
46
+ href: '#',
47
+ label: '3-1 Zinkernagel.pdf',
48
+ },
49
+ {
50
+ href: '#',
51
+ label: '4-1 Castro.pdf',
52
+ },
53
+ ],
54
+ },
46
55
  },
47
56
  };
@@ -1,7 +1,7 @@
1
- import { type AttachmentLinkProps, AttachmentList } from '../Attachment';
2
1
  import { Avatar } from '../Avatar/';
3
- import { MetaBase, MetaItem, MetaTimestamp } from '../Meta/';
2
+ import { MetaBase, MetaTimestamp } from '../Meta/';
4
3
  import { Typography } from '../Typography';
4
+ import { HistoryAttachments, type HistoryAttachmentsProps } from './HistoryAttachments';
5
5
  import { HistoryBorder } from './HistoryBorder';
6
6
  import styles from './historyItem.module.css';
7
7
 
@@ -14,8 +14,9 @@ export interface CreatedByProps {
14
14
  export interface HistoryItemProps {
15
15
  createdBy?: CreatedByProps;
16
16
  createdAt?: string;
17
+ createdAtLabel?: string;
17
18
  summary?: string;
18
- attachments?: AttachmentLinkProps[];
19
+ attachments?: HistoryAttachmentsProps;
19
20
  }
20
21
 
21
22
  export const HistoryItem = ({
@@ -23,11 +24,10 @@ export const HistoryItem = ({
23
24
  type: 'person',
24
25
  },
25
26
  createdAt,
27
+ createdAtLabel,
26
28
  summary,
27
29
  attachments,
28
30
  }: HistoryItemProps) => {
29
- const title = attachments?.length + ' vedlegg';
30
-
31
31
  return (
32
32
  <section className={styles.item}>
33
33
  <header className={styles.header}>
@@ -42,20 +42,12 @@ export const HistoryItem = ({
42
42
  <article className={styles.body}>
43
43
  <MetaBase>
44
44
  <MetaTimestamp datetime={createdAt} size="xs">
45
- {createdBy?.name + ', '}
46
- {createdAt}
45
+ {[createdBy?.name, createdAtLabel].join(', ')}
47
46
  </MetaTimestamp>
48
47
  </MetaBase>
49
48
  <Typography size="lg">
50
49
  <p>{summary}</p>
51
- {attachments ? (
52
- <section>
53
- <MetaItem size="xs">{title}</MetaItem>
54
- <AttachmentList items={attachments} />
55
- </section>
56
- ) : (
57
- ''
58
- )}
50
+ {attachments && <HistoryAttachments {...attachments} />}
59
51
  </Typography>
60
52
  </article>
61
53
  </HistoryBorder>
@@ -16,23 +16,31 @@ const meta = {
16
16
  name: 'Eirik Horneland',
17
17
  },
18
18
  summary: 'Brann slo Glimt 4-1 på Stadion.',
19
- attachments: [
20
- {
21
- label: '1-0 Castro.pdf',
22
- },
23
- {
24
- label: '2-0 Kornvig.pdf',
25
- },
26
- {
27
- label: '3-0 Kartum.pdf',
28
- },
29
- {
30
- label: '3-1 Zinkernagel.pdf',
31
- },
32
- {
33
- label: '4-1 Castro.pdf',
34
- },
35
- ],
19
+ attachments: {
20
+ title: '6 vedlegg',
21
+ items: [
22
+ {
23
+ href: '#',
24
+ label: '1-0 Castro.pdf',
25
+ },
26
+ {
27
+ href: '#',
28
+ label: '2-0 Kornvig.pdf',
29
+ },
30
+ {
31
+ href: '#',
32
+ label: '3-0 Kartum.pdf',
33
+ },
34
+ {
35
+ href: '#',
36
+ label: '3-1 Zinkernagel.pdf',
37
+ },
38
+ {
39
+ href: '#',
40
+ label: '4-1 Castro.pdf',
41
+ },
42
+ ],
43
+ },
36
44
  },
37
45
  {
38
46
  createdAt: '2004-09-09 13:34',
@@ -40,11 +48,15 @@ const meta = {
40
48
  name: 'Eirik Horneland',
41
49
  },
42
50
  summary: 'Brann vant 1-0 i Haugesund.',
43
- attachments: [
44
- {
45
- label: 'Målet til Heggebø.pdf',
46
- },
47
- ],
51
+ attachments: {
52
+ title: '1 vedlegg',
53
+ items: [
54
+ {
55
+ href: '#',
56
+ label: 'Målet til Heggebø.pdf',
57
+ },
58
+ ],
59
+ },
48
60
  },
49
61
  ],
50
62
  },
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import styles from './layoutBase.module.css';
3
3
 
4
- export type LayoutTheme = 'global' | 'neutral' | 'company' | 'person';
4
+ export type LayoutTheme = 'global' | 'global-dark' | 'neutral' | 'company' | 'person';
5
5
 
6
6
  export interface LayoutBaseProps {
7
7
  theme?: LayoutTheme;
@@ -2,3 +2,4 @@ export * from './LayoutBase';
2
2
  export * from './LayoutBody';
3
3
  export * from './LayoutContent';
4
4
  export * from './LayoutSidebar';
5
+ export * from './Layout';
@@ -6,18 +6,6 @@
6
6
  overflow: hidden;
7
7
  }
8
8
 
9
- .base[data-theme="global"] {
10
- background-color: var(--neutral-background-default);
11
- }
12
-
13
- .base[data-theme="neutral"] {
14
- background-color: var(--neutral-background-subtle);
15
- }
16
-
17
- .base[data-theme="person"] {
18
- background-color: var(--person-background-subtle);
19
- }
20
-
21
- .base[data-theme="company"] {
22
- background-color: var(--company-background-subtle);
9
+ .base[data-theme] {
10
+ background-color: var(--theme-background-subtle);
23
11
  }
@@ -3,6 +3,11 @@
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  width: 100%;
6
- max-width: 992px;
7
6
  margin: 0 auto;
8
7
  }
8
+
9
+ @media (min-width: 1024px) {
10
+ [aria-hidden="true"] + .content {
11
+ padding: 0 112px;
12
+ }
13
+ }
@@ -8,6 +8,7 @@
8
8
 
9
9
  @media (min-width: 1024px) {
10
10
  .sidebar {
11
+ flex-shrink: 0;
11
12
  display: flex;
12
13
  flex-direction: column;
13
14
  width: 224px;
@@ -63,7 +63,7 @@ export const MenuAndSnackbar: Story = {
63
63
  children: (
64
64
  <>
65
65
  <Snackbar message="Snack 1" />
66
- <ActionMenu {...menu} />
66
+ <ActionMenu {...menu} theme="global-dark" />
67
67
  </>
68
68
  ),
69
69
  },
@@ -11,7 +11,7 @@ export interface ActionHeaderProps {
11
11
 
12
12
  export const ActionHeader = ({ hidden = false, title, dismissable = true, onDismiss }: ActionHeaderProps) => {
13
13
  return (
14
- <header className={styles.header} aria-hidden={hidden}>
14
+ <header className={styles.header} aria-hidden={hidden} data-theme="global-dark">
15
15
  <h2 className={styles.title}>{title}</h2>
16
16
  {dismissable && <IconButton icon="x-mark" onClick={onDismiss} className={styles.dismiss} />}
17
17
  </header>
@@ -8,6 +8,7 @@ const meta = {
8
8
  tags: ['autodocs'],
9
9
  parameters: {},
10
10
  args: {
11
+ theme: 'global-dark',
11
12
  items: [
12
13
  {
13
14
  id: '1',
@@ -1,13 +1,16 @@
1
1
  import { MenuBase, MenuItem, type MenuItemProps } from '../Menu';
2
2
  import styles from './actionMenu.module.css';
3
3
 
4
+ type ActionMenuTheme = 'inherit' | 'global-dark';
5
+
4
6
  export interface ActionMenuProps {
7
+ theme?: ActionMenuTheme;
5
8
  items?: MenuItemProps[];
6
9
  }
7
10
 
8
- export const ActionMenu = ({ items = [] }: ActionMenuProps) => {
11
+ export const ActionMenu = ({ theme = 'inherit', items = [] }: ActionMenuProps) => {
9
12
  return (
10
- <MenuBase className={styles.menu}>
13
+ <MenuBase theme={theme} className={styles.menu}>
11
14
  <ul className={styles.list}>
12
15
  {items.map((item) => {
13
16
  return (
@@ -1,10 +1,16 @@
1
1
  .menu {
2
- background-color: var(--global-base-default);
3
- color: white;
4
2
  padding: 0 .5rem;
5
3
  border-radius: 0.375rem;
6
4
  }
7
5
 
6
+ .menu[data-theme] {
7
+ background-color: var(--theme-background-subtle);
8
+ }
9
+
10
+ .menu[data-theme="inherit"] {
11
+ background-color: inherit;
12
+ }
13
+
8
14
  .list {
9
15
  display: flex;
10
16
  flex-direction: column;
@@ -19,7 +25,3 @@
19
25
  width: auto;
20
26
  }
21
27
  }
22
-
23
- .list .item:hover {
24
- background-color: var(--global-base-hover);
25
- }
@@ -1,5 +1,9 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
+ import { LayoutBase, LayoutSidebar, type LayoutTheme } from '../Layout';
3
+ import { MetaItem } from '../Meta';
4
+ import { MenuBase } from './MenuBase';
2
5
  import { MenuItem } from './MenuItem';
6
+ import type { MenuItemColor } from './MenuItemBase';
3
7
 
4
8
  const meta = {
5
9
  title: 'Menu/MenuItem',
@@ -130,3 +134,31 @@ export const CompanyAccount: Story = {
130
134
  description: 'Org nr.: XX.XX.XXXX',
131
135
  },
132
136
  };
137
+
138
+ export const ThemesAndColors = () => {
139
+ const themes: LayoutTheme[] = ['global', 'neutral', 'company', 'person', 'global-dark'];
140
+ const colors: MenuItemColor[] = ['neutral', 'subtle', 'strong', 'company', 'person'];
141
+
142
+ return (
143
+ <div style={{ display: 'flex', width: '100%' }}>
144
+ {themes.map((theme) => {
145
+ return (
146
+ <div key={theme} style={{ flexGrow: 1 }}>
147
+ <LayoutBase theme={theme}>
148
+ <MenuBase>
149
+ {colors.map((color) => {
150
+ return (
151
+ <div key={color}>
152
+ <MenuItem icon="inbox" title="Title" color={color} id="inbox" />
153
+ <MetaItem>{theme + '/' + color}</MetaItem>
154
+ </div>
155
+ );
156
+ })}
157
+ </MenuBase>
158
+ </LayoutBase>
159
+ </div>
160
+ );
161
+ })}
162
+ </div>
163
+ );
164
+ };
@@ -4,7 +4,7 @@ import { Badge, type BadgeProps } from '../Badge';
4
4
  import { Icon, type IconName } from '../Icon';
5
5
  import styles from './menuItemBase.module.css';
6
6
 
7
- export type MenuItemColor = 'default' | 'subtle' | 'strong' | 'company' | 'person';
7
+ export type MenuItemColor = 'neutral' | 'subtle' | 'strong' | 'company' | 'person';
8
8
  export type MenuItemSize = 'sm' | 'md' | 'lg';
9
9
 
10
10
  export interface MenuItemBaseProps {
@@ -87,8 +87,6 @@
87
87
  color: var(--theme-text-subtle);
88
88
  }
89
89
 
90
- /* colors */
91
-
92
90
  .item:hover {
93
91
  background-color: var(--theme-surface-default);
94
92
  }
@@ -107,8 +105,6 @@
107
105
  color: var(--theme-background-default);
108
106
  }
109
107
 
110
- /* company */
111
-
112
108
  .item[data-color="company"]:hover {
113
109
  background-color: var(--company-background-subtle);
114
110
  }
@@ -121,8 +117,6 @@
121
117
  background-color: var(--company-surface-default);
122
118
  }
123
119
 
124
- /* person */
125
-
126
120
  .item[data-color="person"]:hover {
127
121
  background-color: var(--person-background-subtle);
128
122
  }
@@ -1,5 +1,4 @@
1
1
  .item {
2
- background-color: transparent;
3
2
  display: flex;
4
3
  align-items: center;
5
4
  column-gap: 4px;
@@ -43,30 +42,25 @@
43
42
 
44
43
  /* colors */
45
44
 
45
+ .item {
46
+ background-color: transparent;
47
+ color: var(--theme-text-default);
48
+ }
49
+
46
50
  .item:hover {
47
- background-color: var(--theme-background-default);
51
+ background-color: var(--theme-surface-hover);
48
52
  }
49
53
 
50
54
  .item[aria-selected="true"] {
51
55
  background-color: var(--theme-background-default);
52
56
  }
53
57
 
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);
58
+ .media[data-color="subtle"] {
59
+ background-color: var(--theme-background-default);
60
+ color: var(--theme-text-default);
68
61
  }
69
62
 
70
- .item[data-color="person"][aria-selected="true"] {
71
- background-color: var(--person-surface-default);
63
+ .media[data-color="strong"] {
64
+ background-color: var(--theme-base-default);
65
+ color: var(--theme-background-default);
72
66
  }
@@ -29,8 +29,10 @@
29
29
 
30
30
  .media[data-color="company"] {
31
31
  background-color: var(--company-surface-default);
32
+ color: var(--company-text-default);
32
33
  }
33
34
 
34
35
  .media[data-color="person"] {
35
36
  background-color: var(--person-surface-default);
37
+ color: var(--person-text-default);
36
38
  }
@@ -2,6 +2,7 @@
2
2
  @import "./colors.css";
3
3
  @import "./shadows.css";
4
4
  @import "./theme-global.css";
5
+ @import "./theme-global-dark.css";
5
6
  @import "./theme-article.css";
6
7
  @import "./theme-neutral.css";
7
8
  @import "./theme-company.css";
@@ -0,0 +1,19 @@
1
+ [data-theme="global-dark"] {
2
+ --theme-background-default: var(--company-base-hover);
3
+ --theme-background-subtle: var(--company-base-default);
4
+
5
+ --theme-base-default: var(--company-background-subtle);
6
+ --theme-base-hover: var(--company-base-hover);
7
+ --theme-base-active: var(--company-base-active);
8
+
9
+ --theme-border-default: var(--neutral-border-default);
10
+ --theme-border-strong: var(--neutral-border-strong);
11
+ --theme-border-subtle: var(--neutral-border-subtle);
12
+
13
+ --theme-surface-default: var(--company-base-default);
14
+ --theme-surface-hover: var(--company-base-hover);
15
+ --theme-surface-active: var(--company-base-active);
16
+
17
+ --theme-text-default: var(--company-background-default);
18
+ --theme-text-subtle: var(--company-background-subtle);
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "main": "lib/index.ts",
5
5
  "description": "Reusable react components",
6
6
  "publishConfig": {