@fellesdatakatalog/ui 1.0.14 → 1.0.16

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 (44) hide show
  1. package/dist/shared-ui.cjs +1 -1
  2. package/dist/shared-ui.cjs.map +1 -1
  3. package/dist/shared-ui.es.js +119 -12
  4. package/dist/shared-ui.es.js.map +1 -1
  5. package/dist/styles.css +1 -1
  6. package/dist/types/components/checkbox-group/checkbox-group.stories.d.ts +12 -0
  7. package/dist/types/components/checkbox-group/index.d.ts +53 -0
  8. package/dist/types/components/radio-group/index.d.ts +52 -0
  9. package/dist/types/components/radio-group/radio-group.stories.d.ts +11 -0
  10. package/dist/types/components/tag-list/index.d.ts +7 -0
  11. package/dist/types/components/tag-list/tag-list.stories.d.ts +7 -0
  12. package/dist/types/index.d.ts +5 -0
  13. package/package.json +13 -2
  14. package/src/components/app-bar/app-bar.stories.tsx +22 -0
  15. package/src/components/app-bar/index.tsx +12 -0
  16. package/src/components/app-bar/styles.module.scss +7 -0
  17. package/src/components/checkbox-group/checkbox-group.stories.tsx +143 -0
  18. package/src/components/checkbox-group/index.tsx +105 -0
  19. package/src/components/copy-button/copy-button.stories.tsx +28 -0
  20. package/src/components/copy-button/index.tsx +54 -0
  21. package/src/components/core/ds-overrides.scss +105 -0
  22. package/src/components/core/mixins.scss +143 -0
  23. package/src/components/core/reset.css +131 -0
  24. package/src/components/core/tokens.scss +26 -0
  25. package/src/components/helptext/helptext.module.scss +46 -0
  26. package/src/components/helptext/helptext.stories.tsx +42 -0
  27. package/src/components/helptext/index.tsx +37 -0
  28. package/src/components/hstack/hstack.module.scss +5 -0
  29. package/src/components/hstack/hstack.stories.tsx +38 -0
  30. package/src/components/hstack/index.tsx +17 -0
  31. package/src/components/org-logo/index.tsx +27 -0
  32. package/src/components/org-logo/org-logo.stories.tsx +35 -0
  33. package/src/components/org-logo/styles.module.scss +20 -0
  34. package/src/components/radio-group/index.tsx +101 -0
  35. package/src/components/radio-group/radio-group.stories.tsx +141 -0
  36. package/src/components/tag-list/index.tsx +39 -0
  37. package/src/components/tag-list/styles.module.scss +8 -0
  38. package/src/components/tag-list/tag-list.stories.tsx +107 -0
  39. package/src/components/vstack/index.tsx +16 -0
  40. package/src/components/vstack/vstack.module.scss +5 -0
  41. package/src/components/vstack/vstack.stories.tsx +37 -0
  42. package/src/index.ts +11 -0
  43. package/src/styles/storybook.scss +34 -0
  44. package/src/types/scss.d.ts +9 -0
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { Tag } from '@digdir/designsystemet-react';
4
+ import styles from './styles.module.scss';
5
+
6
+ export type TagListProps = {
7
+ maxTags?: number;
8
+ 'data-size'?: string;
9
+ };
10
+
11
+ const TagList = ({ children, className, maxTags, 'data-size': dataSize, ...props }: TagListProps & React.HTMLAttributes<HTMLUListElement>) => {
12
+ const childArray = React.Children.toArray(children);
13
+ if (!childArray.length) return null;
14
+ return (
15
+ <ul
16
+ className={cn(styles.tagList, className)}
17
+ {...props}
18
+ >
19
+ {childArray
20
+ .filter((child) => Boolean(child))
21
+ .slice(0, maxTags ?? childArray.length)
22
+ .map((child, i) => {
23
+ const key = React.isValidElement(child) && child.key != null
24
+ ? child.key
25
+ : i;
26
+ return <li key={key}>{child}</li>;
27
+ })}
28
+ {maxTags && maxTags < childArray.length && (
29
+ <li>
30
+ <Tag data-size={dataSize || 'sm'}>
31
+ <span>+{childArray.length - maxTags}</span>
32
+ </Tag>
33
+ </li>
34
+ )}
35
+ </ul>
36
+ );
37
+ };
38
+
39
+ export default TagList;
@@ -0,0 +1,8 @@
1
+ .tagList {
2
+ display: flex;
3
+ gap: 0.5rem;
4
+ font-weight: normal;
5
+ font-size: 0.8em;
6
+ align-items: center;
7
+ flex-wrap: wrap;
8
+ }
@@ -0,0 +1,107 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Tag } from '@digdir/designsystemet-react';
4
+ import TagList from '.';
5
+
6
+ const meta: Meta<typeof TagList> = {
7
+ component: TagList,
8
+ title: 'TagList',
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof TagList>;
13
+
14
+ export const Primary: Story = {
15
+ parameters: {
16
+ nextjs: {
17
+ appDirectory: true,
18
+ },
19
+ },
20
+ render: () => (
21
+ <>
22
+ <div style={{ padding: '1rem' }}>
23
+ <TagList>
24
+ <Tag data-size='sm'>My tag</Tag>
25
+ <Tag
26
+ data-size='sm'
27
+ color='success'
28
+ >
29
+ My tag
30
+ </Tag>
31
+ <Tag
32
+ data-size='sm'
33
+ color='neutral'
34
+ >
35
+ My tag
36
+ </Tag>
37
+ <Tag
38
+ data-size='sm'
39
+ color='warning'
40
+ >
41
+ My tag
42
+ </Tag>
43
+ <Tag
44
+ data-size='sm'
45
+ color='danger'
46
+ >
47
+ My tag
48
+ </Tag>
49
+ </TagList>
50
+ </div>
51
+ </>
52
+ ),
53
+ };
54
+
55
+ export const WithMaxTags: Story = {
56
+ parameters: {
57
+ nextjs: {
58
+ appDirectory: true,
59
+ },
60
+ },
61
+ render: () => (
62
+ <>
63
+ <div style={{ padding: '1rem' }}>
64
+ <TagList maxTags={3}>
65
+ <Tag data-size='sm'>Tag 1</Tag>
66
+ <Tag
67
+ data-size='sm'
68
+ color='success'
69
+ >
70
+ Tag 2
71
+ </Tag>
72
+ <Tag
73
+ data-size='sm'
74
+ color='neutral'
75
+ >
76
+ Tag 3
77
+ </Tag>
78
+ <Tag
79
+ data-size='sm'
80
+ color='warning'
81
+ >
82
+ Tag 4
83
+ </Tag>
84
+ <Tag
85
+ data-size='sm'
86
+ color='danger'
87
+ >
88
+ Tag 5
89
+ </Tag>
90
+ <Tag data-size='sm'>Tag 6</Tag>
91
+ <Tag
92
+ data-size='sm'
93
+ color='success'
94
+ >
95
+ Tag 7
96
+ </Tag>
97
+ <Tag
98
+ data-size='sm'
99
+ color='neutral'
100
+ >
101
+ Tag 8
102
+ </Tag>
103
+ </TagList>
104
+ </div>
105
+ </>
106
+ ),
107
+ };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ import styles from './vstack.module.scss';
4
+
5
+ const VStack = ({ children, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
6
+ return (
7
+ <div
8
+ className={styles.wrapper}
9
+ {...props}
10
+ >
11
+ {children}
12
+ </div>
13
+ );
14
+ };
15
+
16
+ export default VStack;
@@ -0,0 +1,5 @@
1
+ .wrapper {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 0.5rem;
5
+ }
@@ -0,0 +1,37 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import VStack from '.';
4
+
5
+ const meta: Meta<typeof VStack> = {
6
+ component: VStack,
7
+ title: 'VStack',
8
+ };
9
+
10
+ export default meta;
11
+ type Story = StoryObj<typeof VStack>;
12
+
13
+ const Item = ({ children }: { children: React.ReactNode }) => (
14
+ <div
15
+ style={{
16
+ padding: '0.25rem 0.5rem',
17
+ background: '#EEF0F2',
18
+ borderRadius: 4,
19
+ }}
20
+ >
21
+ {children}
22
+ </div>
23
+ );
24
+
25
+ export const Primary: Story = {
26
+ render: () => (
27
+ <div style={{ padding: '1rem' }}>
28
+ <VStack>
29
+ <Item>Row 1</Item>
30
+ <Item>Row 2</Item>
31
+ <Item>Row 3</Item>
32
+ </VStack>
33
+ </div>
34
+ ),
35
+ };
36
+
37
+
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ export * from './components/app-bar';
2
+ export * from './components/org-logo';
3
+ export { default as CopyButton } from './components/copy-button';
4
+ export { default as HStack } from './components/hstack';
5
+ export { default as VStack } from './components/vstack';
6
+ export { HelpText } from './components/helptext';
7
+ export { default as TagList } from './components/tag-list';
8
+ export { default as RadioGroup } from './components/radio-group';
9
+ export { default as CheckboxGroup } from './components/checkbox-group';
10
+ export type { RadioGroupProps } from './components/radio-group';
11
+ export type { CheckboxGroupProps } from './components/checkbox-group';
@@ -0,0 +1,34 @@
1
+ @layer reset, fds;
2
+ @import '../components/core/reset.css';
3
+ @import '@digdir/designsystemet-theme';
4
+ @import '@digdir/designsystemet-css';
5
+
6
+ html { font-size: 16px; }
7
+ body { font-size: 1rem; }
8
+
9
+ html, body, #storybook-root {
10
+ height: 100%;
11
+ }
12
+
13
+ /* Place for additional global styles */
14
+ body {
15
+ font-family:
16
+ system-ui,
17
+ -apple-system,
18
+ BlinkMacSystemFont,
19
+ 'Segoe UI',
20
+ Roboto,
21
+ 'Helvetica Neue',
22
+ Arial,
23
+ sans-serif;
24
+ background: var(--color-fdk-navy-dark);
25
+ color: var(--color-text);
26
+
27
+ main {
28
+ background: white;
29
+ }
30
+ }
31
+
32
+ * {
33
+ font-family: inherit;
34
+ }
@@ -0,0 +1,9 @@
1
+ declare module '*.scss' {
2
+ const content: { [className: string]: string };
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.css' {
7
+ const content: { [className: string]: string };
8
+ export default content;
9
+ }