@ndla/ui 47.1.3 → 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 (70) hide show
  1. package/es/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +15 -32
  2. package/es/ExpandableBox/index.js +9 -0
  3. package/es/Footer/Footer.js +8 -8
  4. package/es/Footer/FooterLinks.js +6 -6
  5. package/es/Image/Image.js +5 -14
  6. package/es/Resource/storyComponents.js +67 -0
  7. package/es/index.js +1 -0
  8. package/es/locale/messages-en.js +15 -4
  9. package/es/locale/messages-nb.js +15 -4
  10. package/es/locale/messages-nn.js +15 -4
  11. package/es/locale/messages-se.js +13 -2
  12. package/es/locale/messages-sma.js +17 -6
  13. package/lib/ExpandableBox/ExpandableBox.d.ts +15 -0
  14. package/lib/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +18 -32
  15. package/lib/ExpandableBox/index.d.ts +8 -0
  16. package/lib/ExpandableBox/index.js +18 -0
  17. package/lib/Footer/Footer.d.ts +5 -9
  18. package/lib/Footer/Footer.js +8 -8
  19. package/lib/Footer/FooterLinks.d.ts +5 -9
  20. package/lib/Footer/FooterLinks.js +6 -6
  21. package/lib/Image/Image.js +5 -14
  22. package/lib/Resource/storyComponents.d.ts +12 -0
  23. package/lib/Resource/storyComponents.js +74 -0
  24. package/lib/index.d.ts +1 -0
  25. package/lib/index.js +13 -0
  26. package/lib/locale/messages-en.d.ts +13 -2
  27. package/lib/locale/messages-en.js +15 -4
  28. package/lib/locale/messages-nb.d.ts +13 -2
  29. package/lib/locale/messages-nb.js +15 -4
  30. package/lib/locale/messages-nn.d.ts +13 -2
  31. package/lib/locale/messages-nn.js +15 -4
  32. package/lib/locale/messages-se.d.ts +13 -2
  33. package/lib/locale/messages-se.js +13 -2
  34. package/lib/locale/messages-sma.d.ts +13 -2
  35. package/lib/locale/messages-sma.js +17 -6
  36. package/package.json +18 -18
  37. package/src/Breadcrumb/Breadcrumb.stories.tsx +77 -0
  38. package/src/Breadcrumb/HomeBreadcrumb.stories.tsx +57 -0
  39. package/src/ContentLoader/ContentLoader.stories.tsx +64 -0
  40. package/src/ExpandableBox/ExpandableBox.stories.tsx +34 -0
  41. package/src/ExpandableBox/ExpandableBox.tsx +21 -0
  42. package/src/ExpandableBox/index.ts +9 -0
  43. package/src/FactBox/Factbox.stories.tsx +62 -0
  44. package/src/FileList/FileList.stories.tsx +48 -0
  45. package/src/Footer/Footer.stories.tsx +116 -0
  46. package/src/Footer/Footer.tsx +5 -9
  47. package/src/Footer/FooterLinks.tsx +5 -9
  48. package/src/Image/Image.stories.tsx +63 -0
  49. package/src/Image/Image.tsx +3 -17
  50. package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +19 -10
  51. package/src/List/OrderedList.stories.tsx +114 -0
  52. package/src/List/UnorderedList.stories.tsx +46 -0
  53. package/src/Messages/MessageBanner.stories.tsx +33 -0
  54. package/src/Messages/MessageBox.stories.tsx +60 -0
  55. package/src/MyNdla/Resource/Folder.stories.tsx +31 -4
  56. package/src/MyNdla/Resource/FolderInput.stories.tsx +29 -0
  57. package/src/Resource/BlockResource.stories.tsx +51 -5
  58. package/src/Resource/ListResource.stories.tsx +98 -0
  59. package/src/Resource/storyComponents.tsx +46 -0
  60. package/src/SnackBar/Snack.stories.tsx +91 -0
  61. package/src/Table/Table.stories.tsx +701 -0
  62. package/src/index.ts +1 -0
  63. package/src/locale/messages-en.ts +12 -4
  64. package/src/locale/messages-nb.ts +15 -4
  65. package/src/locale/messages-nn.ts +15 -4
  66. package/src/locale/messages-se.ts +10 -2
  67. package/src/locale/messages-sma.ts +14 -6
  68. package/lib/Image/LazyLoadImage.d.ts +0 -17
  69. package/src/Image/LazyLoadImage.tsx +0 -37
  70. package/src/Resource/Resource.stories.tsx +0 -81
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2018-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 ContentLoader from '.';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+
13
+ export default {
14
+ title: 'Components/ContentLoader',
15
+ tags: ['autodocs'],
16
+ parameters: {
17
+ inlineStories: true,
18
+ ...defaultParameters,
19
+ },
20
+ args: {
21
+ speed: 2,
22
+ },
23
+ argTypes: {
24
+ children: { control: false },
25
+ },
26
+ component: ContentLoader,
27
+ } as Meta<typeof ContentLoader>;
28
+
29
+ export const ImageOrVideo: StoryObj<typeof ContentLoader> = {
30
+ args: {
31
+ width: 1000,
32
+ height: 750,
33
+ children: (
34
+ <>
35
+ <rect x="0" y="0" rx="3" ry="3" width="800" height="600" />
36
+ <rect x="20" y="610" rx="3" ry="3" width="600" height="30" />
37
+ <rect x="20" y="650" rx="3" ry="3" width="400" height="30" />
38
+ <circle cx="30" cy="700" r="15" fill="purple" />
39
+ <circle cx="70" cy="700" r="15" fill="purple" />
40
+ <circle cx="110" cy="700" r="15" fill="purple" />
41
+ </>
42
+ ),
43
+ },
44
+ };
45
+
46
+ export const Article: StoryObj<typeof ContentLoader> = {
47
+ args: {
48
+ width: 1000,
49
+ height: 1050,
50
+ children: (
51
+ <>
52
+ <rect x="100" y="0" rx="3" ry="3" width="800" height="60" />
53
+ <rect x="100" y="100" rx="3" ry="3" width="800" height="25" />
54
+ <rect x="100" y="140" rx="3" ry="3" width="800" height="25" />
55
+ <rect x="100" y="180" rx="3" ry="3" width="400" height="25" />
56
+ <rect x="0" y="260" rx="3" ry="3" width="1000" height="600" />
57
+ <rect x="100" y="900" rx="3" ry="3" width="800" height="20" />
58
+ <rect x="100" y="930" rx="3" ry="3" width="800" height="20" />
59
+ <rect x="100" y="970" rx="3" ry="3" width="800" height="20" />
60
+ <rect x="100" y="1000" rx="3" ry="3" width="600" height="20" />
61
+ </>
62
+ ),
63
+ },
64
+ };
@@ -0,0 +1,34 @@
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 { ExpandableBox, ExpandableBoxSummary } from './ExpandableBox';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+
13
+ /**
14
+ * This is just a thin wrapper around the native HTML details element.
15
+ * `ExpandableBoxSummary` is a thin wrapper around the native HTML summary element.
16
+ * The components will eventually add style and functionality to the native elements, as opposed to the components being styled by global css.
17
+ */
18
+ export default {
19
+ title: 'Components/ExpandableBox',
20
+ tags: ['autodocs'],
21
+ parameters: {
22
+ inlineStories: true,
23
+ ...defaultParameters,
24
+ },
25
+ component: ExpandableBox,
26
+ render: (args) => (
27
+ <ExpandableBox {...args}>
28
+ <ExpandableBoxSummary>Open me</ExpandableBoxSummary>
29
+ Everything here is only visible when the box is open
30
+ </ExpandableBox>
31
+ ),
32
+ } as Meta<typeof ExpandableBox>;
33
+
34
+ export const Default: StoryObj<typeof ExpandableBox> = {};
@@ -0,0 +1,21 @@
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 { HTMLAttributes } from 'react';
10
+
11
+ interface Props extends HTMLAttributes<HTMLDetailsElement> {}
12
+
13
+ export const ExpandableBox = ({ children, ...rest }: Props) => {
14
+ return <details {...rest}>{children}</details>;
15
+ };
16
+
17
+ interface SummaryProps extends HTMLAttributes<HTMLElement> {}
18
+
19
+ export const ExpandableBoxSummary = ({ children, ...rest }: SummaryProps) => {
20
+ return <summary {...rest}>{children}</summary>;
21
+ };
@@ -0,0 +1,9 @@
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
+ export { ExpandableBox, ExpandableBoxSummary } from './ExpandableBox';
@@ -0,0 +1,62 @@
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 styled from '@emotion/styled';
10
+ import { Meta, StoryObj } from '@storybook/react';
11
+ import { spacing } from '@ndla/core';
12
+ import { Heading, Text } from '@ndla/typography';
13
+ import FactBoxV2 from './FactBoxV2';
14
+ import { defaultParameters } from '../../../../stories/defaults';
15
+
16
+ const Wrapper = styled.div`
17
+ padding: ${spacing.normal};
18
+ `;
19
+
20
+ /**
21
+ *For alt nytt innhold på ndla.no skal ikke flytende høyrespalte benyttes. I stedet benytter vi faktabokser innenfor innholdsspalten.
22
+ */
23
+ export default {
24
+ title: 'Components/FactBox',
25
+ component: FactBoxV2,
26
+ tags: ['autodocs'],
27
+ paramemeters: {
28
+ inlineStories: true,
29
+ ...defaultParameters,
30
+ },
31
+ decorators: [
32
+ (Story) => (
33
+ <Wrapper>
34
+ <Story />
35
+ </Wrapper>
36
+ ),
37
+ ],
38
+ args: {
39
+ children: (
40
+ <>
41
+ <Heading element="h2" headingStyle="h2">
42
+ Faktaboks
43
+ </Heading>
44
+ <Text textStyle="content">
45
+ En faktaboks kan inneholde punktlister eller korte fakta som er relevant for artikkelens innhold.
46
+ </Text>
47
+ <Text textStyle="content">
48
+ Det anbefales å ikke ha for mye innhold i faktaboks, slik at lese-konteksten i størst mulig grad beholdes.
49
+ </Text>
50
+ <Heading element="h2" headingStyle="h2">
51
+ Enkel tittel
52
+ </Heading>
53
+ <Text textStyle="content">
54
+ Faktaboksen kan også brukes til å oppsummere innhold i slutten av en artikkel, og den kan inneholde
55
+ lisensiering om eksternt innhold er brukt.
56
+ </Text>
57
+ </>
58
+ ),
59
+ },
60
+ } as Meta<typeof FactBoxV2>;
61
+
62
+ export const Default: StoryObj<typeof FactBoxV2> = {};
@@ -0,0 +1,48 @@
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 FileV2 from './FileV2';
11
+ import { defaultParameters } from '../../../../stories/defaults';
12
+ import FileListV2 from './FileListV2';
13
+
14
+ export default {
15
+ title: 'Components/FileList',
16
+ tags: ['autodocs'],
17
+ component: FileV2,
18
+ parameters: {
19
+ inlineStories: true,
20
+ ...defaultParameters,
21
+ },
22
+ args: {
23
+ title: 'Min fil',
24
+ url: 'https://www.ndla.no',
25
+ fileExists: true,
26
+ fileType: 'pdf',
27
+ },
28
+ render: (args) => (
29
+ <FileListV2>
30
+ <FileV2 {...args} />
31
+ </FileListV2>
32
+ ),
33
+ } as Meta<typeof FileV2>;
34
+
35
+ export const FileNotFound: StoryObj<typeof FileV2> = {
36
+ args: { fileExists: false },
37
+ };
38
+
39
+ export const SeveralFiles: StoryObj<typeof FileV2> = {
40
+ render: () => (
41
+ <FileListV2>
42
+ <FileV2 title="Fil 1" url="https://ndla.no/1" fileExists fileType="mp4" />
43
+ <FileV2 title="Fil 2" url="https://ndla.no/2" fileExists={false} fileType="pdf" />
44
+ <FileV2 title="Fil 3" url="https://ndla.no/3" fileExists fileType="docx" />
45
+ <FileV2 title="Fil 4" url="https://ndla.no/4" fileExists fileType="docx" />
46
+ </FileListV2>
47
+ ),
48
+ };
@@ -0,0 +1,116 @@
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 { EmailOutline, Facebook, Instagram, LinkedIn, Share, Youtube } from '@ndla/icons/common';
11
+ import Footer from './Footer';
12
+ import { defaultParameters } from '../../../../stories/defaults';
13
+ import { FooterText } from './FooterText';
14
+ import { EditorName } from './EditorName';
15
+ import { LanguageSelector } from '../LanguageSelector';
16
+
17
+ const mockFooterLinks = [
18
+ {
19
+ to: 'https://www.facebook.com/ndla.no',
20
+ text: 'NDLA på Facebook',
21
+ icon: <Facebook />,
22
+ },
23
+ {
24
+ to: 'https://instagram.com/ndla_no/',
25
+ text: 'NDLA på Instagram',
26
+ icon: <Instagram />,
27
+ },
28
+ {
29
+ to: 'https://www.linkedin.com/company/ndla/',
30
+ text: 'NDLA på LinkedIn',
31
+ icon: <LinkedIn />,
32
+ },
33
+ {
34
+ to: 'https://www.youtube.com/channel/UCBlt6T8B0mmvDh3k5q7EhsA',
35
+ text: 'NDLA på YouTube',
36
+ icon: <Youtube />,
37
+ },
38
+ {
39
+ to: 'https://om.ndla.no/nyhetsbrev/',
40
+ text: 'Meld deg på vårt nyhetsbrev',
41
+ icon: <EmailOutline />,
42
+ },
43
+ {
44
+ to: '#',
45
+ text: 'Del denne siden',
46
+ icon: <Share />,
47
+ },
48
+ ];
49
+
50
+ const privacyLinks = [
51
+ { label: 'Personvernerklæring', url: 'https://om.ndla.no/gdpr' },
52
+ { label: 'Erklæring om informasjonskapsler', url: 'https://om.ndla.no/cookies' },
53
+ ];
54
+
55
+ export default {
56
+ title: 'Components/Footer',
57
+ tags: ['autodocs'],
58
+ component: Footer,
59
+ parameters: {
60
+ inlineStories: true,
61
+ ...defaultParameters,
62
+ },
63
+
64
+ args: {
65
+ children: (
66
+ <>
67
+ <FooterText>
68
+ <EditorName title="Ansvarlig redaktør:" name="Sigurd Trageton" />
69
+ </FooterText>
70
+ <FooterText>Nettstedet er utarbeidet av NDLA med åpen kildekode.</FooterText>
71
+ </>
72
+ ),
73
+ },
74
+ argTypes: {
75
+ children: { control: false },
76
+ languageSelector: { control: false },
77
+ auth: { control: false },
78
+ },
79
+ render: (args) => <Footer {...args}></Footer>,
80
+ } as Meta<typeof Footer>;
81
+
82
+ export const Default: StoryObj<typeof Footer> = {};
83
+
84
+ export const WithContentAndLinks: StoryObj<typeof Footer> = {
85
+ args: {
86
+ privacyLinks: privacyLinks,
87
+ links: mockFooterLinks,
88
+ },
89
+ };
90
+
91
+ export const WithoutContent: StoryObj<typeof Footer> = {
92
+ args: {
93
+ children: undefined,
94
+ links: mockFooterLinks,
95
+ privacyLinks: privacyLinks,
96
+ },
97
+ };
98
+
99
+ export const WithLanguageSelector: StoryObj<typeof Footer> = {
100
+ args: {
101
+ privacyLinks: privacyLinks,
102
+ links: mockFooterLinks,
103
+ // eslint-disable-next-line no-console
104
+ languageSelector: <LanguageSelector inverted locales={['nn', 'nb']} onSelect={console.log} />,
105
+ },
106
+ };
107
+
108
+ export const WithAuthBlock: StoryObj<typeof Footer> = {
109
+ args: {
110
+ privacyLinks: privacyLinks,
111
+ links: mockFooterLinks,
112
+ // eslint-disable-next-line no-console
113
+ languageSelector: <LanguageSelector inverted locales={['nn', 'nb']} onSelect={console.log} />,
114
+ auth: <div>Auth info can be placed down here</div>,
115
+ },
116
+ };
@@ -113,15 +113,11 @@ const StyledLanguageWrapper = styled.div`
113
113
  type Props = {
114
114
  children: ReactNode;
115
115
  lang: Locale;
116
- links?: [
117
- {
118
- to: string;
119
- text: string;
120
- icon: ReactNode;
121
- facebook: string;
122
- twitter: string;
123
- },
124
- ];
116
+ links?: {
117
+ to: string;
118
+ text: string;
119
+ icon: ReactNode;
120
+ }[];
125
121
  privacyLinks?: {
126
122
  url: string;
127
123
  label: string;
@@ -26,15 +26,11 @@ const StyledLinksWrapper = styled.div`
26
26
  `;
27
27
 
28
28
  type FooterLinksProps = {
29
- links: [
30
- {
31
- to: string;
32
- text: string;
33
- icon: ReactNode;
34
- facebook: string;
35
- twitter: string;
36
- },
37
- ];
29
+ links: {
30
+ to: string;
31
+ text: string;
32
+ icon: ReactNode;
33
+ }[];
38
34
  };
39
35
 
40
36
  const commonLinks = [
@@ -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
+ );