@ndla/ui 47.1.3 → 47.3.0
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/es/DefinitionList/DefinitionDescription.js +2 -2
- package/es/DefinitionList/DefinitionTerm.js +2 -2
- package/es/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +15 -32
- package/es/ExpandableBox/index.js +9 -0
- package/es/Footer/Footer.js +8 -8
- package/es/Footer/FooterLinks.js +6 -6
- package/es/Image/Image.js +5 -14
- package/es/LinkBlock/LinkBlock.js +6 -6
- package/es/Messages/MessageBox.js +22 -56
- package/es/Resource/storyComponents.js +67 -0
- package/es/index.js +1 -0
- package/es/locale/messages-en.js +15 -4
- package/es/locale/messages-nb.js +15 -4
- package/es/locale/messages-nn.js +15 -4
- package/es/locale/messages-se.js +13 -2
- package/es/locale/messages-sma.js +17 -6
- package/lib/DefinitionList/DefinitionDescription.js +1 -1
- package/lib/DefinitionList/DefinitionTerm.js +1 -1
- package/lib/ExpandableBox/ExpandableBox.d.ts +15 -0
- package/lib/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +18 -32
- package/lib/ExpandableBox/index.d.ts +8 -0
- package/lib/ExpandableBox/index.js +18 -0
- package/lib/Footer/Footer.d.ts +5 -9
- package/lib/Footer/Footer.js +8 -8
- package/lib/Footer/FooterLinks.d.ts +5 -9
- package/lib/Footer/FooterLinks.js +6 -6
- package/lib/Image/Image.js +5 -14
- package/lib/LinkBlock/LinkBlock.js +6 -6
- package/lib/Messages/MessageBox.d.ts +2 -2
- package/lib/Messages/MessageBox.js +21 -55
- package/lib/Resource/storyComponents.d.ts +12 -0
- package/lib/Resource/storyComponents.js +74 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +13 -0
- package/lib/locale/messages-en.d.ts +13 -2
- package/lib/locale/messages-en.js +15 -4
- package/lib/locale/messages-nb.d.ts +13 -2
- package/lib/locale/messages-nb.js +15 -4
- package/lib/locale/messages-nn.d.ts +13 -2
- package/lib/locale/messages-nn.js +15 -4
- package/lib/locale/messages-se.d.ts +13 -2
- package/lib/locale/messages-se.js +13 -2
- package/lib/locale/messages-sma.d.ts +13 -2
- package/lib/locale/messages-sma.js +17 -6
- package/package.json +18 -18
- package/src/Breadcrumb/Breadcrumb.stories.tsx +77 -0
- package/src/Breadcrumb/HomeBreadcrumb.stories.tsx +57 -0
- package/src/ContentLoader/ContentLoader.stories.tsx +64 -0
- package/src/DefinitionList/DefinitionDescription.tsx +1 -2
- package/src/DefinitionList/DefinitionTerm.tsx +1 -2
- package/src/Embed/FootnoteEmbed.stories.tsx +134 -0
- package/src/ExpandableBox/ExpandableBox.stories.tsx +34 -0
- package/src/ExpandableBox/ExpandableBox.tsx +21 -0
- package/src/ExpandableBox/index.ts +9 -0
- package/src/FactBox/Factbox.stories.tsx +62 -0
- package/src/FileList/FileList.stories.tsx +48 -0
- package/src/Footer/Footer.stories.tsx +116 -0
- package/src/Footer/Footer.tsx +5 -9
- package/src/Footer/FooterLinks.tsx +5 -9
- package/src/Image/Image.stories.tsx +63 -0
- package/src/Image/Image.tsx +3 -17
- package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +19 -10
- package/src/LinkBlock/LinkBlock.tsx +1 -1
- package/src/List/OrderedList.stories.tsx +114 -0
- package/src/List/UnorderedList.stories.tsx +46 -0
- package/src/Messages/MessageBanner.stories.tsx +33 -0
- package/src/Messages/MessageBox.stories.tsx +97 -0
- package/src/Messages/MessageBox.tsx +28 -62
- package/src/MyNdla/Resource/Folder.stories.tsx +31 -4
- package/src/MyNdla/Resource/FolderInput.stories.tsx +29 -0
- package/src/Resource/BlockResource.stories.tsx +51 -5
- package/src/Resource/ListResource.stories.tsx +98 -0
- package/src/Resource/storyComponents.tsx +46 -0
- package/src/ResourceGroup/ResourceItem.stories.tsx +103 -0
- package/src/SnackBar/Snack.stories.tsx +91 -0
- package/src/Table/Table.stories.tsx +701 -0
- package/src/TreeStructure/TreeStructure.stories.tsx +271 -0
- package/src/index.ts +1 -0
- package/src/locale/messages-en.ts +12 -4
- package/src/locale/messages-nb.ts +15 -4
- package/src/locale/messages-nn.ts +15 -4
- package/src/locale/messages-se.ts +10 -2
- package/src/locale/messages-sma.ts +14 -6
- package/lib/Image/LazyLoadImage.d.ts +0 -17
- package/src/Image/LazyLoadImage.tsx +0 -37
- package/src/Resource/Resource.stories.tsx +0 -81
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
10
|
+
import OrderedList from './OrderedList';
|
|
11
|
+
import { defaultParameters } from '../../../../stories/defaults';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Lister bør ikke inneholde flere enn 10 punkter. Har du mye mer, bør du vurdere å organisere innholdet annerledes.
|
|
15
|
+
*/
|
|
16
|
+
export default {
|
|
17
|
+
title: 'Base Styles/Ordered List',
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
component: OrderedList,
|
|
20
|
+
parameters: {
|
|
21
|
+
inlineStories: true,
|
|
22
|
+
...defaultParameters,
|
|
23
|
+
},
|
|
24
|
+
render: ({ ...args }) => (
|
|
25
|
+
<OrderedList {...args}>
|
|
26
|
+
<li>Listepunkt 1</li>
|
|
27
|
+
<li>Listepunkt 2</li>
|
|
28
|
+
<li>
|
|
29
|
+
Listepunkt 3
|
|
30
|
+
<OrderedList {...args}>
|
|
31
|
+
<li>Listepunkt 1</li>
|
|
32
|
+
<li>Listepunkt 2</li>
|
|
33
|
+
<li>
|
|
34
|
+
Listepunkt 3
|
|
35
|
+
<OrderedList {...args}>
|
|
36
|
+
<li>Listepunkt 1</li>
|
|
37
|
+
<li>Listepunkt 2</li>
|
|
38
|
+
<li>Listepunkt 3</li>
|
|
39
|
+
</OrderedList>
|
|
40
|
+
</li>
|
|
41
|
+
</OrderedList>
|
|
42
|
+
</li>
|
|
43
|
+
<li>Listepunkt 4</li>
|
|
44
|
+
</OrderedList>
|
|
45
|
+
),
|
|
46
|
+
} as Meta<typeof OrderedList>;
|
|
47
|
+
|
|
48
|
+
export const Default: StoryObj = {};
|
|
49
|
+
|
|
50
|
+
export const Letters: StoryObj = {
|
|
51
|
+
args: {
|
|
52
|
+
'data-type': 'letters',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WithNumbersAndLetters: StoryFn = () => (
|
|
57
|
+
<OrderedList>
|
|
58
|
+
<li>Listepunkt 1</li>
|
|
59
|
+
<li>Listepunkt 2</li>
|
|
60
|
+
<li>
|
|
61
|
+
Listepunkt 3
|
|
62
|
+
<OrderedList data-type="letters">
|
|
63
|
+
<li>Listepunkt 1</li>
|
|
64
|
+
<li>Listepunkt 2</li>
|
|
65
|
+
<li>
|
|
66
|
+
Listepunkt 3
|
|
67
|
+
<OrderedList data-type="letters">
|
|
68
|
+
<li>Listepunkt 1</li>
|
|
69
|
+
<li>Listepunkt 2</li>
|
|
70
|
+
<li>
|
|
71
|
+
Listepunkt 3
|
|
72
|
+
<OrderedList data-type="letters">
|
|
73
|
+
<li>Listepunkt 1</li>
|
|
74
|
+
<li>Listepunkt 2</li>
|
|
75
|
+
<li>Listepunkt 3</li>
|
|
76
|
+
</OrderedList>
|
|
77
|
+
</li>
|
|
78
|
+
</OrderedList>
|
|
79
|
+
</li>
|
|
80
|
+
</OrderedList>
|
|
81
|
+
</li>
|
|
82
|
+
<li>Listepunkt 4</li>
|
|
83
|
+
</OrderedList>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export const StartingAtFive: StoryFn = () => (
|
|
87
|
+
<OrderedList start={5} className="ol-reset-5">
|
|
88
|
+
<li>Listepunkt 1</li>
|
|
89
|
+
<li>Listepunkt 2</li>
|
|
90
|
+
<li>
|
|
91
|
+
Listepunkt 3
|
|
92
|
+
<OrderedList data-type="letters">
|
|
93
|
+
<li>Listepunkt 1</li>
|
|
94
|
+
<li>Listepunkt 2</li>
|
|
95
|
+
<li>
|
|
96
|
+
Listepunkt 3
|
|
97
|
+
<OrderedList data-type="letters">
|
|
98
|
+
<li>Listepunkt 1</li>
|
|
99
|
+
<li>Listepunkt 2</li>
|
|
100
|
+
<li>
|
|
101
|
+
Listepunkt 3
|
|
102
|
+
<OrderedList className="ol-reset-5" data-type="letters" start={5}>
|
|
103
|
+
<li>Listepunkt 1</li>
|
|
104
|
+
<li>Listepunkt 2</li>
|
|
105
|
+
<li>Listepunkt 3</li>
|
|
106
|
+
</OrderedList>
|
|
107
|
+
</li>
|
|
108
|
+
</OrderedList>
|
|
109
|
+
</li>
|
|
110
|
+
</OrderedList>
|
|
111
|
+
</li>
|
|
112
|
+
<li>Listepunkt 4</li>
|
|
113
|
+
</OrderedList>
|
|
114
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
10
|
+
import UnOrderedList from './UnOrderedList';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Base styles/UnorderedList',
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
component: UnOrderedList,
|
|
16
|
+
} as Meta<typeof UnOrderedList>;
|
|
17
|
+
|
|
18
|
+
export const Default: StoryFn = () => (
|
|
19
|
+
<UnOrderedList>
|
|
20
|
+
<li>Listepunkt 1</li>
|
|
21
|
+
<li>Listepunkt 2</li>
|
|
22
|
+
<li>
|
|
23
|
+
Listepunkt 3
|
|
24
|
+
<UnOrderedList>
|
|
25
|
+
<li>Listepunkt 1</li>
|
|
26
|
+
<li>Listepunkt 2</li>
|
|
27
|
+
<li>
|
|
28
|
+
Listepunkt 3
|
|
29
|
+
<UnOrderedList>
|
|
30
|
+
<li>Listepunkt 1</li>
|
|
31
|
+
<li>Listepunkt 2</li>
|
|
32
|
+
<li>
|
|
33
|
+
Listepunkt 3
|
|
34
|
+
<UnOrderedList>
|
|
35
|
+
<li>Listepunkt 1</li>
|
|
36
|
+
<li>Listepunkt 2</li>
|
|
37
|
+
<li>Listepunkt 3</li>
|
|
38
|
+
</UnOrderedList>
|
|
39
|
+
</li>
|
|
40
|
+
</UnOrderedList>
|
|
41
|
+
</li>
|
|
42
|
+
</UnOrderedList>
|
|
43
|
+
</li>
|
|
44
|
+
<li>Listepunkt 4</li>
|
|
45
|
+
</UnOrderedList>
|
|
46
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
11
|
+
import MessageBanner from './MessageBanner';
|
|
12
|
+
import { defaultParameters } from '../../../../stories/defaults';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Brukes i toppen av nettleseren når noe trenger mye oppmerksomhet globalt i systemet.
|
|
16
|
+
*/
|
|
17
|
+
export default {
|
|
18
|
+
title: 'Patterns/MessageBanner',
|
|
19
|
+
component: MessageBanner,
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
parameters: {
|
|
22
|
+
inlineStories: true,
|
|
23
|
+
...defaultParameters,
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
showCloseButton: true,
|
|
27
|
+
},
|
|
28
|
+
} as Meta<typeof MessageBanner>;
|
|
29
|
+
|
|
30
|
+
export const Default: StoryFn<typeof MessageBanner> = ({ ...args }) => {
|
|
31
|
+
const { t } = useTranslation();
|
|
32
|
+
return <MessageBanner {...args}>{t('messageBoxInfo.updateBrowser')}</MessageBanner>;
|
|
33
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
11
|
+
import { Alarm, HumanMaleBoard, InformationOutline, WarningOutline } from '@ndla/icons/common';
|
|
12
|
+
import MessageBox from './MessageBox';
|
|
13
|
+
import { defaultParameters } from '../../../../stories/defaults';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Patterns/MessageBox',
|
|
17
|
+
component: MessageBox,
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
parameters: {
|
|
20
|
+
inlineStories: true,
|
|
21
|
+
...defaultParameters,
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
showCloseButton: true,
|
|
25
|
+
},
|
|
26
|
+
} as Meta<typeof MessageBox>;
|
|
27
|
+
|
|
28
|
+
export const Default: StoryFn<typeof MessageBox> = ({ ...args }) => {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
return (
|
|
31
|
+
<MessageBox {...args}>
|
|
32
|
+
<InformationOutline />
|
|
33
|
+
{t('messageBoxInfo.noContent')}
|
|
34
|
+
</MessageBox>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const WithoutCloseButton: StoryFn<typeof MessageBox> = () => {
|
|
39
|
+
const { t } = useTranslation();
|
|
40
|
+
return (
|
|
41
|
+
<MessageBox>
|
|
42
|
+
<InformationOutline />
|
|
43
|
+
{t('messageBoxInfo.subjectOutdated')}
|
|
44
|
+
</MessageBox>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const WithLinks: StoryFn<typeof MessageBox> = () => {
|
|
49
|
+
const { t } = useTranslation();
|
|
50
|
+
return (
|
|
51
|
+
<MessageBox
|
|
52
|
+
links={[
|
|
53
|
+
{ text: 'link 1', href: '#' },
|
|
54
|
+
{ text: 'link 2', href: '#' },
|
|
55
|
+
{ text: 'link 3', href: '#' },
|
|
56
|
+
]}
|
|
57
|
+
>
|
|
58
|
+
<InformationOutline />
|
|
59
|
+
{t('messageBoxInfo.newVersion')}
|
|
60
|
+
</MessageBox>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Ghost: StoryFn<typeof MessageBox> = () => {
|
|
65
|
+
const { t } = useTranslation();
|
|
66
|
+
return (
|
|
67
|
+
<MessageBox type="ghost">
|
|
68
|
+
<HumanMaleBoard />
|
|
69
|
+
{t('messageBoxInfo.feide')}
|
|
70
|
+
</MessageBox>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const Danger: StoryFn<typeof MessageBox> = () => {
|
|
75
|
+
const { t } = useTranslation();
|
|
76
|
+
return (
|
|
77
|
+
<MessageBox type="danger">
|
|
78
|
+
<WarningOutline />
|
|
79
|
+
{t('messageBoxInfo.feide')}
|
|
80
|
+
</MessageBox>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const WithCustomIcon: StoryFn<typeof MessageBox> = () => {
|
|
85
|
+
const { t } = useTranslation();
|
|
86
|
+
return (
|
|
87
|
+
<MessageBox type="danger">
|
|
88
|
+
<Alarm />
|
|
89
|
+
{t('messageBoxInfo.feide')}
|
|
90
|
+
</MessageBox>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const WithoutIcon: StoryFn<typeof MessageBox> = () => {
|
|
95
|
+
const { t } = useTranslation();
|
|
96
|
+
return <MessageBox type="danger">{t('messageBoxInfo.feide')}</MessageBox>;
|
|
97
|
+
};
|
|
@@ -8,19 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
10
|
import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import { Forward } from '@ndla/icons/common';
|
|
13
12
|
import { CloseButton } from '@ndla/button';
|
|
14
13
|
import { css } from '@emotion/react';
|
|
15
14
|
import { ReactNode } from 'react';
|
|
16
15
|
|
|
17
16
|
type MessageBoxType = 'ghost' | 'danger';
|
|
18
17
|
|
|
19
|
-
interface
|
|
18
|
+
interface LinkProps {
|
|
19
|
+
href?: string;
|
|
20
|
+
text?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface MessageBoxProps {
|
|
20
24
|
type?: MessageBoxType;
|
|
25
|
+
children?: ReactNode;
|
|
26
|
+
links?: LinkProps[];
|
|
27
|
+
showCloseButton?: boolean;
|
|
28
|
+
onClose?: () => void;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
const MessageBoxWrapper = styled.div
|
|
31
|
+
const MessageBoxWrapper = styled.div`
|
|
24
32
|
display: flex;
|
|
25
33
|
padding: ${spacing.small};
|
|
26
34
|
font-family: ${fonts.sans};
|
|
@@ -32,21 +40,14 @@ const MessageBoxWrapper = styled.div<StyledProps>`
|
|
|
32
40
|
${mq.range({ until: breakpoints.tabletWide })} {
|
|
33
41
|
${fonts.sizes('16px')};
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
${({ type }) =>
|
|
45
|
-
type === 'danger' &&
|
|
46
|
-
css`
|
|
47
|
-
background: ${colors.support.redLightest};
|
|
48
|
-
color: ${colors.text.primary};
|
|
49
|
-
`}
|
|
43
|
+
&[data-type='ghost'] {
|
|
44
|
+
background: transparent;
|
|
45
|
+
color: ${colors.brand.greyDark};
|
|
46
|
+
}
|
|
47
|
+
&[data-type='danger'] {
|
|
48
|
+
background: ${colors.support.redLightest};
|
|
49
|
+
color: ${colors.text.primary};
|
|
50
|
+
}
|
|
50
51
|
`;
|
|
51
52
|
|
|
52
53
|
const InfoWrapper = styled.div`
|
|
@@ -54,23 +55,14 @@ const InfoWrapper = styled.div`
|
|
|
54
55
|
flex-direction: row;
|
|
55
56
|
flex: 1;
|
|
56
57
|
padding: ${spacing.small};
|
|
57
|
-
padding-right: 0;
|
|
58
58
|
`;
|
|
59
59
|
|
|
60
|
-
const
|
|
61
|
-
& p {
|
|
62
|
-
margin: 0;
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
const IconWrapper = styled.div`
|
|
60
|
+
const ChildrenWrapper = styled.div`
|
|
67
61
|
display: flex;
|
|
68
|
-
|
|
69
|
-
padding-right: ${spacing.small};
|
|
70
|
-
|
|
62
|
+
gap: ${spacing.small};
|
|
71
63
|
svg {
|
|
72
|
-
width: 24px;
|
|
73
|
-
height: 24px;
|
|
64
|
+
min-width: 24px;
|
|
65
|
+
min-height: 24px;
|
|
74
66
|
}
|
|
75
67
|
`;
|
|
76
68
|
|
|
@@ -79,7 +71,7 @@ const LinkWrapper = styled.div`
|
|
|
79
71
|
flex-wrap: wrap;
|
|
80
72
|
gap: ${spacing.normal};
|
|
81
73
|
padding-top: ${spacing.nsmall};
|
|
82
|
-
|
|
74
|
+
padding-left: ${spacing.mediumlarge};
|
|
83
75
|
svg {
|
|
84
76
|
flex-shrink: 0;
|
|
85
77
|
}
|
|
@@ -97,38 +89,12 @@ const StyledClosebutton = styled(CloseButton)`
|
|
|
97
89
|
padding: 0;
|
|
98
90
|
`;
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
href?: string;
|
|
102
|
-
text?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
interface Props {
|
|
106
|
-
type?: MessageBoxType;
|
|
107
|
-
children?: ReactNode;
|
|
108
|
-
links?: LinkProps[];
|
|
109
|
-
showCloseButton?: boolean;
|
|
110
|
-
onClose?: () => void;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const Icon = ({ type }: StyledProps) => {
|
|
114
|
-
if (type === 'ghost') {
|
|
115
|
-
return <HumanMaleBoard />;
|
|
116
|
-
}
|
|
117
|
-
if (type === 'danger') {
|
|
118
|
-
return <WarningOutline />;
|
|
119
|
-
}
|
|
120
|
-
return <InformationOutline />;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const MessageBox = ({ type, children = '', links, showCloseButton, onClose }: Props) => {
|
|
92
|
+
export const MessageBox = ({ type, children, links, showCloseButton, onClose }: MessageBoxProps) => {
|
|
124
93
|
return (
|
|
125
|
-
<MessageBoxWrapper type={type}>
|
|
94
|
+
<MessageBoxWrapper data-type={type}>
|
|
126
95
|
<InfoWrapper>
|
|
127
|
-
<IconWrapper>
|
|
128
|
-
<Icon type={type} />
|
|
129
|
-
</IconWrapper>
|
|
130
96
|
<div>
|
|
131
|
-
<
|
|
97
|
+
<ChildrenWrapper>{children}</ChildrenWrapper>
|
|
132
98
|
{links && (
|
|
133
99
|
<LinkWrapper>
|
|
134
100
|
{links.map((x) => (
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import styled from '@emotion/styled';
|
|
10
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
11
|
+
import { spacing } from '@ndla/core';
|
|
2
12
|
import { Pencil } from '@ndla/icons/action';
|
|
3
13
|
import { DeleteForever } from '@ndla/icons/editor';
|
|
4
14
|
import { DropdownMenu, DropdownTrigger, DropdownContent, DropdownItem } from '@ndla/dropdown-menu';
|
|
@@ -9,7 +19,7 @@ import { defaultParameters } from '../../../../../stories/defaults';
|
|
|
9
19
|
import Folder from './Folder';
|
|
10
20
|
|
|
11
21
|
export default {
|
|
12
|
-
title: '
|
|
22
|
+
title: 'My NDLA/Folder',
|
|
13
23
|
component: Folder,
|
|
14
24
|
tags: ['autodocs'],
|
|
15
25
|
parameters: {
|
|
@@ -55,6 +65,23 @@ export default {
|
|
|
55
65
|
},
|
|
56
66
|
} as Meta<typeof Folder>;
|
|
57
67
|
|
|
58
|
-
export const FolderStory:
|
|
59
|
-
|
|
68
|
+
export const FolderStory: StoryObj<typeof Folder> = {};
|
|
69
|
+
|
|
70
|
+
export const WithoutMenu: StoryObj<typeof Folder> = {
|
|
71
|
+
args: { menu: undefined },
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const BlockWrapper = styled.div`
|
|
75
|
+
display: flex;
|
|
76
|
+
gap: ${spacing.small};
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
export const BlockFolder: StoryFn<typeof Folder> = (args) => {
|
|
80
|
+
return (
|
|
81
|
+
<BlockWrapper>
|
|
82
|
+
<Folder {...args} type="block" />
|
|
83
|
+
<Folder {...args} type="block" />
|
|
84
|
+
<Folder {...args} type="block" />
|
|
85
|
+
</BlockWrapper>
|
|
86
|
+
);
|
|
60
87
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
10
|
+
import FolderInput from './FolderInput';
|
|
11
|
+
import { defaultParameters } from '../../../../../stories/defaults';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
title: 'My NDLA/FolderInput',
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
component: FolderInput,
|
|
17
|
+
parameters: {
|
|
18
|
+
inlineStories: true,
|
|
19
|
+
...defaultParameters,
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
labelHidden: false,
|
|
23
|
+
loading: false,
|
|
24
|
+
label: 'Create new folder',
|
|
25
|
+
name: 'folder',
|
|
26
|
+
},
|
|
27
|
+
} as Meta<typeof FolderInput>;
|
|
28
|
+
|
|
29
|
+
export const Default: StoryObj = {};
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Meta, StoryFn } from '@storybook/react';
|
|
9
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
10
|
+
import styled from '@emotion/styled';
|
|
11
|
+
import { spacing } from '@ndla/core';
|
|
10
12
|
import { defaultParameters } from '../../../../stories/defaults';
|
|
11
13
|
import BlockResource from './BlockResource';
|
|
14
|
+
import { StoryResourceMenu, resourceTypesArr } from './storyComponents';
|
|
12
15
|
|
|
13
16
|
export default {
|
|
14
|
-
title: '
|
|
17
|
+
title: 'My NDLA/BlockResource',
|
|
15
18
|
component: BlockResource,
|
|
16
19
|
tags: ['autodocs'],
|
|
17
20
|
parameters: {
|
|
@@ -35,8 +38,9 @@ export default {
|
|
|
35
38
|
id: '1234',
|
|
36
39
|
link: '',
|
|
37
40
|
title: 'Tittel til ressurs',
|
|
41
|
+
description: 'Dette er for eksempel en fagbeskrivelse! Dersom den er for lang vil den bli forkortet',
|
|
38
42
|
resourceImage: {
|
|
39
|
-
src: '',
|
|
43
|
+
src: 'https://cdn.pixabay.com/photo/2022/06/12/22/35/village-7258991_1280.jpg',
|
|
40
44
|
alt: '',
|
|
41
45
|
},
|
|
42
46
|
resourceTypes: [{ id: 'urn:resourcetype:learningPath', name: 'Læringssti' }],
|
|
@@ -44,8 +48,50 @@ export default {
|
|
|
44
48
|
},
|
|
45
49
|
} as Meta<typeof BlockResource>;
|
|
46
50
|
|
|
47
|
-
export const
|
|
51
|
+
export const WithImage: StoryFn<typeof BlockResource> = (args) => {
|
|
48
52
|
return <BlockResource {...args} />;
|
|
49
53
|
};
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
export const WithoutImage: StoryObj<typeof BlockResource> = {
|
|
56
|
+
args: { resourceImage: { src: '', alt: '' } },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const WithoutTags: StoryObj<typeof BlockResource> = {
|
|
60
|
+
args: { tags: [] },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const WithOverflowingDescription: StoryObj<typeof BlockResource> = {
|
|
64
|
+
args: {
|
|
65
|
+
description:
|
|
66
|
+
'Beskrivelser trenger ikke å være så veldig lange. Det er ganske vanskelig å få plass til en livshistorie. Det lærte jeg da jeg var ung',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const WithMenu: StoryObj<typeof BlockResource> = {
|
|
71
|
+
args: {
|
|
72
|
+
menu: <StoryResourceMenu />,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const Loading: StoryObj<typeof BlockResource> = {
|
|
77
|
+
args: {
|
|
78
|
+
isLoading: true,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const BlockWrapper = styled.div`
|
|
83
|
+
display: flex;
|
|
84
|
+
gap: ${spacing.small};
|
|
85
|
+
flex-wrap: wrap;
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
export const BlockView: StoryObj<typeof BlockResource> = {
|
|
89
|
+
args: { resourceImage: { src: '', alt: '' } },
|
|
90
|
+
render: ({ ...args }) => (
|
|
91
|
+
<BlockWrapper>
|
|
92
|
+
{resourceTypesArr.map((rt) => (
|
|
93
|
+
<BlockResource {...args} key={rt.id} resourceTypes={[rt]} />
|
|
94
|
+
))}
|
|
95
|
+
</BlockWrapper>
|
|
96
|
+
),
|
|
97
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import styled from '@emotion/styled';
|
|
10
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
11
|
+
import ListResource from './ListResource';
|
|
12
|
+
import { defaultParameters } from '../../../../stories/defaults';
|
|
13
|
+
import { StoryResourceMenu, resourceTypesArr } from './storyComponents';
|
|
14
|
+
import { spacing } from '../../../core/src';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'My NDLA/ListResource',
|
|
18
|
+
component: ListResource,
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
parameters: {
|
|
21
|
+
...defaultParameters,
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
resourceImage: {
|
|
25
|
+
control: false,
|
|
26
|
+
},
|
|
27
|
+
resourceTypes: {
|
|
28
|
+
control: false,
|
|
29
|
+
},
|
|
30
|
+
headingLevel: {
|
|
31
|
+
control: false,
|
|
32
|
+
},
|
|
33
|
+
menu: {
|
|
34
|
+
control: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
args: {
|
|
38
|
+
id: '1234',
|
|
39
|
+
link: '',
|
|
40
|
+
title: 'Tittel til ressurs',
|
|
41
|
+
resourceImage: {
|
|
42
|
+
src: 'https://cdn.pixabay.com/photo/2022/06/12/22/35/village-7258991_1280.jpg',
|
|
43
|
+
alt: '',
|
|
44
|
+
},
|
|
45
|
+
resourceTypes: [{ id: 'urn:resourcetype:learningPath', name: 'Læringssti' }],
|
|
46
|
+
tags: ['tag', 'tag', 'tag', 'tag'],
|
|
47
|
+
},
|
|
48
|
+
} as Meta<typeof ListResource>;
|
|
49
|
+
|
|
50
|
+
export const WithImage: StoryFn<typeof ListResource> = (args) => {
|
|
51
|
+
return <ListResource {...args} />;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const WithoutImage: StoryObj<typeof ListResource> = {
|
|
55
|
+
args: {
|
|
56
|
+
resourceImage: { src: '', alt: '' },
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const WithoutTags: StoryObj<typeof ListResource> = {
|
|
61
|
+
args: { tags: [] },
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const WithOverflowingDescription: StoryObj<typeof ListResource> = {
|
|
65
|
+
args: {
|
|
66
|
+
description:
|
|
67
|
+
'Beskrivelser trenger ikke å være så veldig lange. Det er ganske vanskelig å få plass til en livshistorie. Det lærte jeg da jeg var en ung utvikler og utviklet denne komponenten. Jeg husker det nærmest som om det var i går, men det var det egentlig ikke. Det var i det gode år 2022',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const WithMenu: StoryObj<typeof ListResource> = {
|
|
72
|
+
args: {
|
|
73
|
+
menu: <StoryResourceMenu />,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Loading: StoryObj<typeof ListResource> = {
|
|
78
|
+
args: {
|
|
79
|
+
isLoading: true,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const Wrapper = styled.div`
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
gap: ${spacing.small};
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
export const BlockView: StoryObj<typeof ListResource> = {
|
|
90
|
+
args: { resourceImage: { src: '', alt: '' } },
|
|
91
|
+
render: ({ ...args }) => (
|
|
92
|
+
<Wrapper>
|
|
93
|
+
{resourceTypesArr.map((rt) => (
|
|
94
|
+
<ListResource {...args} key={rt.id} resourceTypes={[rt]} />
|
|
95
|
+
))}
|
|
96
|
+
</Wrapper>
|
|
97
|
+
),
|
|
98
|
+
};
|