@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.
Files changed (86) hide show
  1. package/es/DefinitionList/DefinitionDescription.js +2 -2
  2. package/es/DefinitionList/DefinitionTerm.js +2 -2
  3. package/es/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +15 -32
  4. package/es/ExpandableBox/index.js +9 -0
  5. package/es/Footer/Footer.js +8 -8
  6. package/es/Footer/FooterLinks.js +6 -6
  7. package/es/Image/Image.js +5 -14
  8. package/es/LinkBlock/LinkBlock.js +6 -6
  9. package/es/Messages/MessageBox.js +22 -56
  10. package/es/Resource/storyComponents.js +67 -0
  11. package/es/index.js +1 -0
  12. package/es/locale/messages-en.js +15 -4
  13. package/es/locale/messages-nb.js +15 -4
  14. package/es/locale/messages-nn.js +15 -4
  15. package/es/locale/messages-se.js +13 -2
  16. package/es/locale/messages-sma.js +17 -6
  17. package/lib/DefinitionList/DefinitionDescription.js +1 -1
  18. package/lib/DefinitionList/DefinitionTerm.js +1 -1
  19. package/lib/ExpandableBox/ExpandableBox.d.ts +15 -0
  20. package/lib/{Image/LazyLoadImage.js → ExpandableBox/ExpandableBox.js} +18 -32
  21. package/lib/ExpandableBox/index.d.ts +8 -0
  22. package/lib/ExpandableBox/index.js +18 -0
  23. package/lib/Footer/Footer.d.ts +5 -9
  24. package/lib/Footer/Footer.js +8 -8
  25. package/lib/Footer/FooterLinks.d.ts +5 -9
  26. package/lib/Footer/FooterLinks.js +6 -6
  27. package/lib/Image/Image.js +5 -14
  28. package/lib/LinkBlock/LinkBlock.js +6 -6
  29. package/lib/Messages/MessageBox.d.ts +2 -2
  30. package/lib/Messages/MessageBox.js +21 -55
  31. package/lib/Resource/storyComponents.d.ts +12 -0
  32. package/lib/Resource/storyComponents.js +74 -0
  33. package/lib/index.d.ts +1 -0
  34. package/lib/index.js +13 -0
  35. package/lib/locale/messages-en.d.ts +13 -2
  36. package/lib/locale/messages-en.js +15 -4
  37. package/lib/locale/messages-nb.d.ts +13 -2
  38. package/lib/locale/messages-nb.js +15 -4
  39. package/lib/locale/messages-nn.d.ts +13 -2
  40. package/lib/locale/messages-nn.js +15 -4
  41. package/lib/locale/messages-se.d.ts +13 -2
  42. package/lib/locale/messages-se.js +13 -2
  43. package/lib/locale/messages-sma.d.ts +13 -2
  44. package/lib/locale/messages-sma.js +17 -6
  45. package/package.json +18 -18
  46. package/src/Breadcrumb/Breadcrumb.stories.tsx +77 -0
  47. package/src/Breadcrumb/HomeBreadcrumb.stories.tsx +57 -0
  48. package/src/ContentLoader/ContentLoader.stories.tsx +64 -0
  49. package/src/DefinitionList/DefinitionDescription.tsx +1 -2
  50. package/src/DefinitionList/DefinitionTerm.tsx +1 -2
  51. package/src/Embed/FootnoteEmbed.stories.tsx +134 -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/Image/Image.stories.tsx +63 -0
  61. package/src/Image/Image.tsx +3 -17
  62. package/src/Image/__tests__/__snapshots__/Image-test.jsx.snap +19 -10
  63. package/src/LinkBlock/LinkBlock.tsx +1 -1
  64. package/src/List/OrderedList.stories.tsx +114 -0
  65. package/src/List/UnorderedList.stories.tsx +46 -0
  66. package/src/Messages/MessageBanner.stories.tsx +33 -0
  67. package/src/Messages/MessageBox.stories.tsx +97 -0
  68. package/src/Messages/MessageBox.tsx +28 -62
  69. package/src/MyNdla/Resource/Folder.stories.tsx +31 -4
  70. package/src/MyNdla/Resource/FolderInput.stories.tsx +29 -0
  71. package/src/Resource/BlockResource.stories.tsx +51 -5
  72. package/src/Resource/ListResource.stories.tsx +98 -0
  73. package/src/Resource/storyComponents.tsx +46 -0
  74. package/src/ResourceGroup/ResourceItem.stories.tsx +103 -0
  75. package/src/SnackBar/Snack.stories.tsx +91 -0
  76. package/src/Table/Table.stories.tsx +701 -0
  77. package/src/TreeStructure/TreeStructure.stories.tsx +271 -0
  78. package/src/index.ts +1 -0
  79. package/src/locale/messages-en.ts +12 -4
  80. package/src/locale/messages-nb.ts +15 -4
  81. package/src/locale/messages-nn.ts +15 -4
  82. package/src/locale/messages-se.ts +10 -2
  83. package/src/locale/messages-sma.ts +14 -6
  84. package/lib/Image/LazyLoadImage.d.ts +0 -17
  85. package/src/Image/LazyLoadImage.tsx +0 -37
  86. package/src/Resource/Resource.stories.tsx +0 -81
@@ -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,103 @@
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 { FavoriteButton } from '@ndla/button';
11
+ import ResourceItem from './ResourceItem';
12
+ import { defaultParameters } from '../../../../stories/defaults';
13
+
14
+ export default {
15
+ title: 'Components/ResourceItem',
16
+ tags: ['autodocs'],
17
+ component: ResourceItem,
18
+ parameters: {
19
+ inlineStories: true,
20
+ ...defaultParameters,
21
+ },
22
+ args: {
23
+ id: 'urn:resource:a7a49c0a-32ea-4343-8b11-bd6d65c24f87',
24
+ name: 'Refleksjonsoppgave om ideer og idéutvikling',
25
+ path: '',
26
+ contentType: 'subject-material',
27
+ additional: false,
28
+ heartButton: () => <FavoriteButton />,
29
+ access: undefined,
30
+ },
31
+ } as Meta<typeof ResourceItem>;
32
+
33
+ export const Default: StoryObj<typeof ResourceItem> = {};
34
+
35
+ export const WithCoreOrAdditionalIndicator: StoryObj<typeof ResourceItem> = {
36
+ args: {
37
+ contentTypeName: 'Fagstoff',
38
+ contentTypeDescription: 'Kjernestoff',
39
+ showAdditionalResources: true,
40
+ },
41
+ };
42
+
43
+ export const WithCoreOrAdditionalIndicatorAdditional: StoryObj<typeof ResourceItem> = {
44
+ args: {
45
+ additional: true,
46
+ contentTypeName: 'Fagstoff',
47
+ contentTypeDescription: 'Tilleggsstoff',
48
+ showAdditionalResources: true,
49
+ },
50
+ };
51
+
52
+ export const RelevanceIndicatorWithoutLabel: StoryObj<typeof ResourceItem> = {
53
+ args: {
54
+ contentTypeDescription: 'Kjernestoff',
55
+ showAdditionalResources: true,
56
+ },
57
+ };
58
+
59
+ export const OnlyAvailableForTeachers: StoryObj<typeof ResourceItem> = {
60
+ args: {
61
+ access: 'teacher',
62
+ },
63
+ };
64
+
65
+ export const CurrentPage: StoryObj<typeof ResourceItem> = {
66
+ args: { active: true },
67
+ };
68
+
69
+ export const SubjectMaterial: StoryObj<typeof ResourceItem> = {
70
+ args: {
71
+ contentType: 'subject-material',
72
+ },
73
+ };
74
+
75
+ export const TasksAndActivities: StoryObj<typeof ResourceItem> = {
76
+ args: {
77
+ contentType: 'tasks-and-activities',
78
+ },
79
+ };
80
+
81
+ export const AssessmentResource: StoryObj<typeof ResourceItem> = {
82
+ args: {
83
+ contentType: 'assessment-resources',
84
+ },
85
+ };
86
+
87
+ export const ExternalLearningResource: StoryObj<typeof ResourceItem> = {
88
+ args: {
89
+ contentType: 'external-learning-resources',
90
+ },
91
+ };
92
+
93
+ export const SourceMaterial: StoryObj<typeof ResourceItem> = {
94
+ args: {
95
+ contentType: 'source-material',
96
+ },
97
+ };
98
+
99
+ export const LearningPath: StoryObj<typeof ResourceItem> = {
100
+ args: {
101
+ contentType: 'learning-path',
102
+ },
103
+ };
@@ -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
+ };