@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,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
+ };
@@ -0,0 +1,46 @@
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 { DropdownMenu, DropdownTrigger, DropdownContent, DropdownItem } from '@ndla/dropdown-menu';
10
+ import { IconButtonV2, ButtonV2 } from '@ndla/button';
11
+ import { HorizontalMenu } from '@ndla/icons/contentType';
12
+ import { Pencil } from '@ndla/icons/action';
13
+ import { DeleteForever } from '@ndla/icons/editor';
14
+
15
+ export const resourceTypesArr = [
16
+ { id: 'urn:resourcetype:learningPath', name: 'Læringssti' },
17
+ { id: 'urn:resourcetype:subjectMaterial', name: 'Fagstoff' },
18
+ { id: 'urn:resourcetype:tasksAndActivities', name: 'Oppgaver og aktiviteter' },
19
+ { id: 'urn:resourcetype:reviewResource', name: 'Vurderingsressurs' },
20
+ { id: 'urn:resourcetype:externalResource', name: 'Ekstern læringsressurs' },
21
+ { id: 'urn:resourcetype:SourceMaterial', name: 'Kildemateriale' },
22
+ ];
23
+
24
+ export const StoryResourceMenu = () => (
25
+ <DropdownMenu>
26
+ <DropdownTrigger>
27
+ <IconButtonV2 aria-label="Show more" title="Show more" variant="ghost" colorTheme="light">
28
+ <HorizontalMenu />
29
+ </IconButtonV2>
30
+ </DropdownTrigger>
31
+ <DropdownContent>
32
+ <DropdownItem>
33
+ <ButtonV2 variant="ghost" colorTheme="light" shape="sharp" size="small" fontWeight="normal">
34
+ <Pencil />
35
+ Rediger
36
+ </ButtonV2>
37
+ </DropdownItem>
38
+ <DropdownItem>
39
+ <ButtonV2 variant="ghost" colorTheme="danger" shape="sharp" size="small" fontWeight="normal">
40
+ <DeleteForever />
41
+ Slett
42
+ </ButtonV2>
43
+ </DropdownItem>
44
+ </DropdownContent>
45
+ </DropdownMenu>
46
+ );
@@ -0,0 +1,91 @@
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 { ButtonV2 } from '@ndla/button';
11
+ import { PersonOutlined } from '@ndla/icons/common';
12
+ import { Snack, SnackbarProvider, useSnack } from '.';
13
+ import { defaultParameters } from '../../../../stories/defaults';
14
+
15
+ const SnackComponent = ({ ...args }: Snack) => {
16
+ const { addSnack } = useSnack();
17
+ const onClick = () => {
18
+ addSnack({ ...args });
19
+ };
20
+
21
+ return (
22
+ <ButtonV2 variant="outline" onClick={onClick}>
23
+ Show snack
24
+ </ButtonV2>
25
+ );
26
+ };
27
+
28
+ export default {
29
+ title: 'Components/Snack',
30
+ tags: ['autodocs'],
31
+ parameters: {
32
+ inlineStories: true,
33
+ ...defaultParameters,
34
+ },
35
+ args: {
36
+ content: <span>This is a snack</span>,
37
+ duration: 5000,
38
+ render: undefined,
39
+ id: 'default',
40
+ icon: undefined,
41
+ closable: true,
42
+ },
43
+ argTypes: {
44
+ content: { control: false, description: 'Any JSX component, but usually a span-like element' },
45
+ render: { control: false, description: 'Replaces the entire snack with a custom render' },
46
+ icon: { control: false, description: 'An additional icon to be shown on the left-hand side of the snack' },
47
+ },
48
+ decorators: [
49
+ (Story) => (
50
+ <SnackbarProvider>
51
+ <Story />
52
+ </SnackbarProvider>
53
+ ),
54
+ ],
55
+ render: ({ ...args }) => <SnackComponent {...args} />,
56
+ } as Meta<Snack>;
57
+
58
+ export const Default: StoryObj<Snack> = {};
59
+
60
+ const CustomSnack = (snack: Snack) => {
61
+ const { closeSnack } = useSnack();
62
+ return (
63
+ <div style={{ backgroundColor: 'gray', zIndex: 1000, display: 'flex', pointerEvents: 'all' }}>
64
+ <p>Custom render!</p>
65
+ <ButtonV2 onClick={() => closeSnack(snack)}>Close</ButtonV2>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export const WithCustomRender: StoryObj<Snack> = {
71
+ args: {
72
+ id: 'customRender',
73
+ content: undefined,
74
+ duration: 2000000,
75
+ render: (id) => <CustomSnack id={id} />,
76
+ },
77
+ };
78
+
79
+ export const NotClosable: StoryObj<Snack> = {
80
+ args: {
81
+ id: 'nonClosable',
82
+ closable: false,
83
+ },
84
+ };
85
+
86
+ export const WithIcon: StoryObj<Snack> = {
87
+ args: {
88
+ id: 'customIcon',
89
+ icon: <PersonOutlined />,
90
+ },
91
+ };