@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.
- package/dist/shared-ui.cjs +1 -1
- package/dist/shared-ui.cjs.map +1 -1
- package/dist/shared-ui.es.js +119 -12
- package/dist/shared-ui.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/components/checkbox-group/checkbox-group.stories.d.ts +12 -0
- package/dist/types/components/checkbox-group/index.d.ts +53 -0
- package/dist/types/components/radio-group/index.d.ts +52 -0
- package/dist/types/components/radio-group/radio-group.stories.d.ts +11 -0
- package/dist/types/components/tag-list/index.d.ts +7 -0
- package/dist/types/components/tag-list/tag-list.stories.d.ts +7 -0
- package/dist/types/index.d.ts +5 -0
- package/package.json +13 -2
- package/src/components/app-bar/app-bar.stories.tsx +22 -0
- package/src/components/app-bar/index.tsx +12 -0
- package/src/components/app-bar/styles.module.scss +7 -0
- package/src/components/checkbox-group/checkbox-group.stories.tsx +143 -0
- package/src/components/checkbox-group/index.tsx +105 -0
- package/src/components/copy-button/copy-button.stories.tsx +28 -0
- package/src/components/copy-button/index.tsx +54 -0
- package/src/components/core/ds-overrides.scss +105 -0
- package/src/components/core/mixins.scss +143 -0
- package/src/components/core/reset.css +131 -0
- package/src/components/core/tokens.scss +26 -0
- package/src/components/helptext/helptext.module.scss +46 -0
- package/src/components/helptext/helptext.stories.tsx +42 -0
- package/src/components/helptext/index.tsx +37 -0
- package/src/components/hstack/hstack.module.scss +5 -0
- package/src/components/hstack/hstack.stories.tsx +38 -0
- package/src/components/hstack/index.tsx +17 -0
- package/src/components/org-logo/index.tsx +27 -0
- package/src/components/org-logo/org-logo.stories.tsx +35 -0
- package/src/components/org-logo/styles.module.scss +20 -0
- package/src/components/radio-group/index.tsx +101 -0
- package/src/components/radio-group/radio-group.stories.tsx +141 -0
- package/src/components/tag-list/index.tsx +39 -0
- package/src/components/tag-list/styles.module.scss +8 -0
- package/src/components/tag-list/tag-list.stories.tsx +107 -0
- package/src/components/vstack/index.tsx +16 -0
- package/src/components/vstack/vstack.module.scss +5 -0
- package/src/components/vstack/vstack.stories.tsx +37 -0
- package/src/index.ts +11 -0
- package/src/styles/storybook.scss +34 -0
- 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,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,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
|
+
}
|