@ndla/ui 47.1.2 → 47.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 (87) hide show
  1. package/es/BlogPost/BlogPost.js +6 -7
  2. package/es/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +15 -32
  3. package/es/ExpandableBox/index.js +9 -0
  4. package/es/Footer/Footer.js +8 -8
  5. package/es/Footer/FooterLinks.js +6 -6
  6. package/es/FramedContent/FramedContent.js +37 -0
  7. package/es/FramedContent/index.js +10 -0
  8. package/es/Image/Image.js +5 -14
  9. package/es/Resource/storyComponents.js +67 -0
  10. package/es/index.js +2 -0
  11. package/es/locale/messages-en.js +17 -5
  12. package/es/locale/messages-nb.js +17 -5
  13. package/es/locale/messages-nn.js +17 -5
  14. package/es/locale/messages-se.js +15 -3
  15. package/es/locale/messages-sma.js +19 -7
  16. package/lib/BlogPost/BlogPost.js +6 -7
  17. package/lib/ExpandableBox/ExpandableBox.d.ts +15 -0
  18. package/lib/ExpandableBox/ExpandableBox.js +41 -0
  19. package/lib/ExpandableBox/index.d.ts +8 -0
  20. package/lib/ExpandableBox/index.js +18 -0
  21. package/lib/Footer/Footer.d.ts +5 -9
  22. package/lib/Footer/Footer.js +8 -8
  23. package/lib/Footer/FooterLinks.d.ts +5 -9
  24. package/lib/Footer/FooterLinks.js +6 -6
  25. package/lib/FramedContent/FramedContent.d.ts +12 -0
  26. package/lib/{Image/LazyLoadImage.js → FramedContent/FramedContent.js} +25 -37
  27. package/lib/FramedContent/index.d.ts +9 -0
  28. package/lib/FramedContent/index.js +17 -0
  29. package/lib/Image/Image.js +5 -14
  30. package/lib/Resource/storyComponents.d.ts +12 -0
  31. package/lib/Resource/storyComponents.js +74 -0
  32. package/lib/index.d.ts +2 -0
  33. package/lib/index.js +20 -0
  34. package/lib/locale/messages-en.d.ts +14 -2
  35. package/lib/locale/messages-en.js +17 -5
  36. package/lib/locale/messages-nb.d.ts +14 -2
  37. package/lib/locale/messages-nb.js +17 -5
  38. package/lib/locale/messages-nn.d.ts +14 -2
  39. package/lib/locale/messages-nn.js +17 -5
  40. package/lib/locale/messages-se.d.ts +14 -2
  41. package/lib/locale/messages-se.js +15 -3
  42. package/lib/locale/messages-sma.d.ts +14 -2
  43. package/lib/locale/messages-sma.js +19 -7
  44. package/package.json +19 -19
  45. package/src/Article/ArticleByline.stories.tsx +52 -0
  46. package/src/BlogPost/BlogPost.tsx +1 -7
  47. package/src/Breadcrumb/Breadcrumb.stories.tsx +77 -0
  48. package/src/Breadcrumb/HomeBreadcrumb.stories.tsx +57 -0
  49. package/src/ContentLoader/ContentLoader.stories.tsx +64 -0
  50. package/src/CreatedBy/CreatedBy.stories.tsx +38 -0
  51. package/src/ErrorMessage/ErrorMessage.stories.tsx +59 -0
  52. package/src/ExpandableBox/ExpandableBox.stories.tsx +34 -0
  53. package/src/ExpandableBox/ExpandableBox.tsx +21 -0
  54. package/src/ExpandableBox/index.ts +9 -0
  55. package/src/FactBox/Factbox.stories.tsx +62 -0
  56. package/src/FileList/FileList.stories.tsx +48 -0
  57. package/src/Footer/Footer.stories.tsx +116 -0
  58. package/src/Footer/Footer.tsx +5 -9
  59. package/src/Footer/FooterLinks.tsx +5 -9
  60. package/src/FramedContent/FramedContent.stories.tsx +88 -0
  61. package/src/FramedContent/FramedContent.tsx +29 -0
  62. package/src/FramedContent/index.ts +10 -0
  63. package/src/Image/Image.stories.tsx +63 -0
  64. package/src/Image/Image.tsx +3 -17
  65. package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +19 -10
  66. package/src/List/OrderedList.stories.tsx +114 -0
  67. package/src/List/UnorderedList.stories.tsx +46 -0
  68. package/src/Logo/Logo.stories.tsx +50 -0
  69. package/src/Messages/MessageBanner.stories.tsx +33 -0
  70. package/src/Messages/MessageBox.stories.tsx +60 -0
  71. package/src/MyNdla/Resource/Folder.stories.tsx +31 -4
  72. package/src/MyNdla/Resource/FolderInput.stories.tsx +29 -0
  73. package/src/Resource/BlockResource.stories.tsx +51 -5
  74. package/src/Resource/ListResource.stories.tsx +98 -0
  75. package/src/Resource/storyComponents.tsx +46 -0
  76. package/src/SnackBar/Snack.stories.tsx +91 -0
  77. package/src/Table/Table.stories.tsx +701 -0
  78. package/src/TagSelector/TagSelector.stories.tsx +88 -0
  79. package/src/index.ts +2 -0
  80. package/src/locale/messages-en.ts +13 -4
  81. package/src/locale/messages-nb.ts +16 -4
  82. package/src/locale/messages-nn.ts +16 -4
  83. package/src/locale/messages-se.ts +11 -2
  84. package/src/locale/messages-sma.ts +15 -6
  85. package/lib/Image/LazyLoadImage.d.ts +0 -17
  86. package/src/Image/LazyLoadImage.tsx +0 -37
  87. package/src/Resource/Resource.stories.tsx +0 -81
@@ -0,0 +1,63 @@
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 Image from './Image';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+
13
+ export default {
14
+ title: 'Components/Image',
15
+ tags: ['autodocs'],
16
+ component: Image,
17
+ parameters: {
18
+ inlineStories: true,
19
+ ...defaultParameters,
20
+ },
21
+ args: {
22
+ alt: 'Mann med maske',
23
+ src: 'https://api.test.ndla.no/image-api/raw/id/604',
24
+ },
25
+ } as Meta<typeof Image>;
26
+
27
+ export const Default: StoryObj<typeof Image> = {};
28
+
29
+ export const Crop: StoryObj<typeof Image> = {
30
+ args: {
31
+ crop: {
32
+ startX: 14.59,
33
+ endX: 79.63,
34
+ startY: 20,
35
+ endY: 100,
36
+ },
37
+ },
38
+ };
39
+
40
+ export const FocalPoint: StoryObj<typeof Image> = {
41
+ args: {
42
+ focalPoint: {
43
+ x: 65.08,
44
+ y: 45.28,
45
+ },
46
+ sizes: '(min-width: 320px) 320px',
47
+ },
48
+ };
49
+
50
+ export const LazyLoad: StoryObj<typeof Image> = {
51
+ args: {
52
+ alt: 'Lyspære',
53
+ src: 'https://api.staging.ndla.no/image-api/raw/Ide.jpg',
54
+ lazyLoad: true,
55
+ lazyLoadSrc: `data:image/svg+xml;utf8,
56
+ <svg xmlns="http://www.w3.org/2000/svg" height="400" width="100%">
57
+ <rect x="0" y="0" width="100%" height="100%" style="fill:#EFF0F2;">
58
+ <animate attributeType="XML" attributeName="fill" values="#EFF0F2;#E8E3E3;#EFF0F2;" dur="3s" repeatCount="indefinite"/>
59
+ </rect>
60
+ </svg>
61
+ `,
62
+ },
63
+ };
@@ -9,7 +9,6 @@
9
9
  import { ReactNode } from 'react';
10
10
  import { colors } from '@ndla/core';
11
11
  import styled from '@emotion/styled';
12
- import LazyLoadImage from './LazyLoadImage';
13
12
 
14
13
  export interface ImageCrop {
15
14
  startX: number;
@@ -97,25 +96,12 @@ const Image = ({
97
96
  }: Props) => {
98
97
  const srcSet = rest.srcSet ?? getSrcSet(src, crop, focalPoint);
99
98
  const queryString = makeSrcQueryString(fallbackWidth, crop, focalPoint);
99
+ const loading = lazyLoad ? 'lazy' : undefined;
100
100
 
101
101
  if (contentType && contentType === 'image/gif') {
102
102
  return (
103
103
  <StyledImageWrapper data-border={border}>
104
- <StyledImage alt={alt} src={`${src}`} {...rest} data-border={border} />
105
- </StyledImageWrapper>
106
- );
107
- }
108
-
109
- if (lazyLoad) {
110
- return (
111
- <StyledImageWrapper>
112
- <LazyLoadImage
113
- alt={alt}
114
- src={`${src}?${queryString}`}
115
- srcSet={srcSet}
116
- sizes={sizes}
117
- lazyLoadSrc={lazyLoadSrc}
118
- />
104
+ <StyledImage alt={alt} loading={loading} src={`${src}`} {...rest} data-border={border} />
119
105
  </StyledImageWrapper>
120
106
  );
121
107
  }
@@ -124,7 +110,7 @@ const Image = ({
124
110
  <StyledImageWrapper data-svg={contentType === 'image/svg+xml'} data-border={border}>
125
111
  <picture>
126
112
  <source type={contentType} srcSet={srcSet} sizes={sizes} />
127
- <StyledImage alt={alt} src={`${src}?${queryString}`} {...rest} data-border={border} />
113
+ <StyledImage alt={alt} loading={loading} src={`${src}?${queryString}`} {...rest} data-border={border} />
128
114
  </picture>
129
115
  {expandButton}
130
116
  </StyledImageWrapper>
@@ -132,19 +132,28 @@ exports[`Lazyloaded image renderers correctly 1`] = `
132
132
  border-bottom-right-radius: 0;
133
133
  }
134
134
 
135
+ .emotion-1[data-border='true'] {
136
+ border-radius: 3px;
137
+ border-bottom-left-radius: 0;
138
+ border-bottom-right-radius: 0;
139
+ }
140
+
135
141
  <div
136
142
  class="emotion-0"
143
+ data-svg="false"
137
144
  >
138
- <noscript />
139
- <img
140
- alt="example"
141
- class="lazyload"
142
- data-sizes="(min-width: 1024px) 1024px, 100vw"
143
- data-src="https://example.com/image.png?width=1024"
144
- data-src-set="https://example.com/image.png?width=2720 2720w, https://example.com/image.png?width=2080 2080w, https://example.com/image.png?width=1760 1760w, https://example.com/image.png?width=1440 1440w, https://example.com/image.png?width=1120 1120w, https://example.com/image.png?width=1000 1000w, https://example.com/image.png?width=960 960w, https://example.com/image.png?width=800 800w, https://example.com/image.png?width=640 640w, https://example.com/image.png?width=480 480w, https://example.com/image.png?width=320 320w, https://example.com/image.png?width=240 240w, https://example.com/image.png?width=180 180w"
145
- src="https://example.com/blurry.png"
146
- style="width: 100%;"
147
- />
145
+ <picture>
146
+ <source
147
+ sizes="(min-width: 1024px) 1024px, 100vw"
148
+ srcset="https://example.com/image.png?width=2720 2720w, https://example.com/image.png?width=2080 2080w, https://example.com/image.png?width=1760 1760w, https://example.com/image.png?width=1440 1440w, https://example.com/image.png?width=1120 1120w, https://example.com/image.png?width=1000 1000w, https://example.com/image.png?width=960 960w, https://example.com/image.png?width=800 800w, https://example.com/image.png?width=640 640w, https://example.com/image.png?width=480 480w, https://example.com/image.png?width=320 320w, https://example.com/image.png?width=240 240w, https://example.com/image.png?width=180 180w"
149
+ />
150
+ <img
151
+ alt="example"
152
+ class="emotion-1"
153
+ loading="lazy"
154
+ src="https://example.com/image.png?width=1024"
155
+ />
156
+ </picture>
148
157
  </div>
149
158
  `;
150
159
 
@@ -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,50 @@
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 Logo from './Logo';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+
13
+ /***
14
+ * Logoen er vårt tydeligste kjennetegn og vårt viktigste verktøy for kommunikasjon. Den skal inspirere målgruppen elever og lærere i videregående opplæring og gjøre dem nysgjerrige på NDLA.
15
+ *
16
+ * Logoen består av navnet NDLA i en spesiell typografi og bør hovedsakelig benyttes sammen med underteksten. Logo uten undertekst kan benyttes i tilfeller der det kommer godt fram andre steder hva NDLA er, eksempelvis på ndla.no.
17
+ *
18
+ * Logo uten undertekst kan kompletteres med en beskrivende tekst til høyre. Logoen kan benyttes i blått, eller i svart eller hvitt avhengig av bakgrunn. Den skal plasseres i det øverste eller nederste hjørnet av en ytterkant. Logoen skal ikke sentreres.
19
+ */
20
+ export default {
21
+ title: 'Components/Logo',
22
+ component: Logo,
23
+ tags: ['autodocs'],
24
+ parameters: {
25
+ inlineStories: true,
26
+ ...defaultParameters,
27
+ },
28
+ args: {
29
+ cssModifier: 'large',
30
+ name: true,
31
+ label: 'Nasjonal digital læringsarena',
32
+ },
33
+ } as Meta<typeof Logo>;
34
+
35
+ export const WithoutUrl: StoryObj<typeof Logo> = {
36
+ args: {},
37
+ };
38
+
39
+ export const WithUrl: StoryObj<typeof Logo> = {
40
+ args: {
41
+ to: '/',
42
+ },
43
+ };
44
+
45
+ export const EnglishLogo: StoryObj<typeof Logo> = {
46
+ args: {
47
+ locale: 'en',
48
+ label: 'Norwegian digital learning arena',
49
+ },
50
+ };
@@ -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,60 @@
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 MessageBox from './MessageBox';
12
+ import { defaultParameters } from '../../../../stories/defaults';
13
+
14
+ export default {
15
+ title: 'Patterns/MessageBox',
16
+ component: MessageBox,
17
+ tags: ['autodocs'],
18
+ parameters: {
19
+ inlineStories: true,
20
+ ...defaultParameters,
21
+ },
22
+ args: {
23
+ showCloseButton: true,
24
+ },
25
+ } as Meta<typeof MessageBox>;
26
+
27
+ export const Default: StoryFn<typeof MessageBox> = ({ ...args }) => {
28
+ const { t } = useTranslation();
29
+ return <MessageBox {...args}>{t('messageBoxInfo.noContent')}</MessageBox>;
30
+ };
31
+
32
+ export const WithoutCloseButton: StoryFn<typeof MessageBox> = () => {
33
+ const { t } = useTranslation();
34
+ return <MessageBox>{t('messageBoxInfo.subjectOutdated')}</MessageBox>;
35
+ };
36
+
37
+ export const WithLinks: StoryFn<typeof MessageBox> = () => {
38
+ const { t } = useTranslation();
39
+ return (
40
+ <MessageBox
41
+ links={[
42
+ { text: 'link 1', href: '#' },
43
+ { text: 'link 2', href: '#' },
44
+ { text: 'link 3', href: '#' },
45
+ ]}
46
+ >
47
+ {t('messageBoxInfo.newVersion')}
48
+ </MessageBox>
49
+ );
50
+ };
51
+
52
+ export const Ghost: StoryFn<typeof MessageBox> = () => {
53
+ const { t } = useTranslation();
54
+ return <MessageBox type="ghost">{t('messageBoxInfo.feide')}</MessageBox>;
55
+ };
56
+
57
+ export const Danger: StoryFn<typeof MessageBox> = () => {
58
+ const { t } = useTranslation();
59
+ return <MessageBox type="danger">{t('messageBoxInfo.feide')}</MessageBox>;
60
+ };
@@ -1,4 +1,14 @@
1
- import { Meta, StoryFn } from '@storybook/react';
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: 'Components/Folder',
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: StoryFn<typeof Folder> = (args) => {
59
- return <Folder {...args} />;
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: 'Components/Resources/BlockResource',
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 BlockResourceStory: StoryFn<typeof BlockResource> = (args) => {
51
+ export const WithImage: StoryFn<typeof BlockResource> = (args) => {
48
52
  return <BlockResource {...args} />;
49
53
  };
50
54
 
51
- BlockResourceStory.storyName = 'BlockResource';
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
+ };