@ndla/ui 50.5.0 → 50.5.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 (50) hide show
  1. package/es/Aside/Aside.js +55 -17
  2. package/es/ContentTypeBadge/ContentTypeBadge.js +162 -83
  3. package/es/FramedContent/FramedContent.js +7 -11
  4. package/es/ResourceGroup/ResourceItem.js +9 -9
  5. package/es/SearchTypeResult/components/ItemResourceHeader.js +6 -6
  6. package/es/SearchTypeResult/components/ItemTopicHeader.js +4 -4
  7. package/es/all.css +1 -1
  8. package/es/locale/messages-en.js +3 -2
  9. package/es/locale/messages-nb.js +3 -2
  10. package/es/locale/messages-nn.js +3 -2
  11. package/es/locale/messages-se.js +3 -2
  12. package/es/locale/messages-sma.js +3 -2
  13. package/lib/Aside/Aside.d.ts +3 -7
  14. package/lib/Aside/Aside.js +55 -19
  15. package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +3 -2
  16. package/lib/ContentTypeBadge/ContentTypeBadge.js +162 -85
  17. package/lib/FramedContent/FramedContent.d.ts +1 -1
  18. package/lib/FramedContent/FramedContent.js +8 -11
  19. package/lib/ResourceGroup/ResourceItem.js +9 -9
  20. package/lib/SearchTypeResult/components/ItemResourceHeader.js +6 -6
  21. package/lib/SearchTypeResult/components/ItemTopicHeader.js +4 -4
  22. package/lib/all.css +1 -1
  23. package/lib/locale/messages-en.d.ts +1 -0
  24. package/lib/locale/messages-en.js +3 -2
  25. package/lib/locale/messages-nb.d.ts +1 -0
  26. package/lib/locale/messages-nb.js +3 -2
  27. package/lib/locale/messages-nn.d.ts +1 -0
  28. package/lib/locale/messages-nn.js +3 -2
  29. package/lib/locale/messages-se.d.ts +1 -0
  30. package/lib/locale/messages-se.js +3 -2
  31. package/lib/locale/messages-sma.d.ts +1 -0
  32. package/lib/locale/messages-sma.js +3 -2
  33. package/package.json +2 -2
  34. package/src/Article/component.article.scss +1 -1
  35. package/src/Aside/Aside.tsx +95 -30
  36. package/src/ContentTypeBadge/ContentTypeBadge.stories.tsx +81 -0
  37. package/src/ContentTypeBadge/ContentTypeBadge.tsx +169 -71
  38. package/src/FramedContent/FramedContent.tsx +37 -14
  39. package/src/ResourceGroup/ResourceItem.tsx +5 -5
  40. package/src/SearchTypeResult/components/ItemResourceHeader.tsx +1 -1
  41. package/src/SearchTypeResult/components/ItemTopicHeader.tsx +1 -1
  42. package/src/locale/messages-en.ts +2 -2
  43. package/src/locale/messages-nb.ts +2 -2
  44. package/src/locale/messages-nn.ts +2 -2
  45. package/src/locale/messages-se.ts +2 -2
  46. package/src/locale/messages-sma.ts +2 -2
  47. package/src/main.scss +0 -3
  48. package/src/Aside/component.aside.scss +0 -91
  49. package/src/ContentTypeBadge/component.content-type-badge.scss +0 -223
  50. package/src/global/components/component.bodybox.scss +0 -60
@@ -986,6 +986,7 @@ declare const messages: {
986
986
  delete: string;
987
987
  };
988
988
  fetchMore: string;
989
+ deleted: string;
989
990
  };
990
991
  flag: {
991
992
  title: string;
@@ -1004,7 +1004,8 @@ const messages = {
1004
1004
  edit: 'Edit post',
1005
1005
  delete: 'Delete post'
1006
1006
  },
1007
- fetchMore: 'Fetch more answers'
1007
+ fetchMore: 'Fetch more answers',
1008
+ deleted: 'This post has been deleted by the author.'
1008
1009
  },
1009
1010
  flag: {
1010
1011
  title: 'Report post / comment',
@@ -1018,7 +1019,7 @@ const messages = {
1018
1019
  maxLength: 'The maximum length for the text field is reached',
1019
1020
  error: 'The field is required'
1020
1021
  },
1021
- bottomText: 'Are you missing a category? You can request new categories. Use "Ask NDLA" or send an email to moderator@ndla.no',
1022
+ bottomText: 'Are you missing a category? Let our moderator know at moderator@ndla.no',
1022
1023
  notification: {
1023
1024
  title: 'Notifications',
1024
1025
  showAll: 'View all notifications',
@@ -986,6 +986,7 @@ declare const messages: {
986
986
  delete: string;
987
987
  };
988
988
  fetchMore: string;
989
+ deleted: string;
989
990
  };
990
991
  flag: {
991
992
  title: string;
@@ -1004,7 +1004,8 @@ const messages = {
1004
1004
  edit: 'Rediger innlegg',
1005
1005
  delete: 'Slett innlegget'
1006
1006
  },
1007
- fetchMore: 'Hent flere svar'
1007
+ fetchMore: 'Hent flere svar',
1008
+ deleted: 'Dette innlegget er slettet av forfatteren.'
1008
1009
  },
1009
1010
  flag: {
1010
1011
  title: 'Rapporter innlegg / kommentar',
@@ -1018,7 +1019,7 @@ const messages = {
1018
1019
  maxLength: 'Maksimal lengde for tekstfeltet er nådd',
1019
1020
  error: 'Feltet er påkrevd'
1020
1021
  },
1021
- bottomText: 'Savner du en kategori? Du kan be om nye kategorier. Bruk “Spør NDLA” eller send en epost til moderator@ndla.no',
1022
+ bottomText: 'Savner du en kategori? Gi vår moderator beskjed moderator@ndla.no',
1022
1023
  notification: {
1023
1024
  title: 'Varslinger',
1024
1025
  showAll: 'Se alle varslinger',
@@ -986,6 +986,7 @@ declare const messages: {
986
986
  delete: string;
987
987
  };
988
988
  fetchMore: string;
989
+ deleted: string;
989
990
  };
990
991
  flag: {
991
992
  title: string;
@@ -1004,7 +1004,8 @@ const messages = {
1004
1004
  edit: 'Rediger innlegg',
1005
1005
  delete: 'Slett innlegget'
1006
1006
  },
1007
- fetchMore: 'Hent fleire svar'
1007
+ fetchMore: 'Hent fleire svar',
1008
+ deleted: 'Dette innlegget er sletta av forfatteren.'
1008
1009
  },
1009
1010
  flag: {
1010
1011
  title: 'Rapporter innlegg / kommentar',
@@ -1018,7 +1019,7 @@ const messages = {
1018
1019
  maxLength: 'Maksimal lengd for tekstfeltet er nådd',
1019
1020
  error: 'Feltet er påkravd'
1020
1021
  },
1021
- bottomText: 'Saknar du ein kategori? Du kan be om nye kategoriar. Bruk "Spør NDLA" eller send ein epost til moderator@ndla.no',
1022
+ bottomText: 'Saknar du ein kategori? Gi moderatoren vår beskjed moderator@ndla.no',
1022
1023
  notification: {
1023
1024
  title: 'Varslingar',
1024
1025
  showAll: 'Sjå alle varslingar',
@@ -986,6 +986,7 @@ declare const messages: {
986
986
  delete: string;
987
987
  };
988
988
  fetchMore: string;
989
+ deleted: string;
989
990
  };
990
991
  flag: {
991
992
  title: string;
@@ -1004,7 +1004,8 @@ const messages = {
1004
1004
  edit: 'Doaimmat čállosa',
1005
1005
  delete: 'Sihko čállosa'
1006
1006
  },
1007
- fetchMore: 'Viečča eanet vástádusaid'
1007
+ fetchMore: 'Viečča eanet vástádusaid',
1008
+ deleted: 'Čálli lea sihkon dán sáhkavuoru.'
1008
1009
  },
1009
1010
  flag: {
1010
1011
  title: 'Rapportere čállosa / kommentára',
@@ -1018,7 +1019,7 @@ const messages = {
1018
1019
  maxLength: 'Teakstagieddeguhkkodat lea joavdan',
1019
1020
  error: 'Fealta gáibiduvvo'
1020
1021
  },
1021
- bottomText: 'Váillahat go ovtta lági? Sáhtát jearrat ođđa lágiid. Geavat "Gihtten NDLA" dahje sádde e-poastta moderatator@ndla.no',
1022
+ bottomText: 'Váillahat go ovtta lági? Atte min moderatora dieđu dása moderator@ndla.no',
1022
1023
  notification: {
1023
1024
  title: 'Muittuhusat',
1024
1025
  showAll: 'Čájet buot dieđuid',
@@ -986,6 +986,7 @@ declare const messages: {
986
986
  delete: string;
987
987
  };
988
988
  fetchMore: string;
989
+ deleted: string;
989
990
  };
990
991
  flag: {
991
992
  title: string;
@@ -1004,7 +1004,8 @@ const messages = {
1004
1004
  edit: 'Jarkelimmie håalemistie',
1005
1005
  delete: 'Slett innlegget'
1006
1006
  },
1007
- fetchMore: 'Jienebh vaestiedassh veedtjedh'
1007
+ fetchMore: 'Jienebh vaestiedassh veedtjedh',
1008
+ deleted: 'Daate tjaalege lea tjaalegen tjïrrh sliejhteme.'
1008
1009
  },
1009
1010
  flag: {
1010
1011
  title: 'Påastem reektehtidh / kommentaarem',
@@ -1018,7 +1019,7 @@ const messages = {
1018
1019
  maxLength: 'Jeenjemes gåhkoe tjaalegegievleste båateme',
1019
1020
  error: 'Bielie daerpies'
1020
1021
  },
1021
- bottomText: 'Akte kategorije datne ohtsedh ? Datne maahtah orre kategoriji bïjre rohkelidh Nuhtjh "Gihtjh NDLA" jallh seedth e-påastem moderaator@ndla.no',
1022
+ bottomText: 'Akte kategorije datne ohtsedh? Vedtieh mijjen moderatovrese bieljelimmiem moderatore@ndla.no',
1022
1023
  notification: {
1023
1024
  title: 'Bïeljelimmie',
1024
1025
  showAll: 'Gaajhkh bæjhkoehtimmieh vuartasjidh',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "50.5.0",
3
+ "version": "50.5.1",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "33f14792431d5c46241455f1f5e05ac9a81ab7d6"
84
+ "gitHead": "e2746547c6056cd97e80ced58fe8a3be9edf3c4b"
85
85
  }
@@ -145,7 +145,7 @@
145
145
  padding-left: 0;
146
146
  }
147
147
 
148
- .c-content-type-badge {
148
+ [data-badge] {
149
149
  position: absolute;
150
150
  left: 0;
151
151
 
@@ -6,42 +6,107 @@
6
6
  *
7
7
  */
8
8
 
9
- import { ReactNode } from 'react';
10
- import BEMHelper from 'react-bem-helper';
11
-
12
- const classes = BEMHelper({
13
- prefix: 'c-',
14
- name: 'aside',
15
- });
16
-
17
- interface Props {
18
- dangerouslySetInnerHTML?: {
19
- __html: string;
20
- };
21
- children?: ReactNode;
9
+ import { ComponentProps, useMemo } from 'react';
10
+ import { css } from '@emotion/react';
11
+ import styled from '@emotion/styled';
12
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
13
+
14
+ interface Props extends ComponentProps<'aside'> {
22
15
  narrowScreen?: boolean;
23
16
  wideScreen?: boolean;
24
17
  alwaysShow?: boolean;
25
18
  }
26
19
 
27
- const Aside = ({
28
- children,
29
- narrowScreen = false,
30
- dangerouslySetInnerHTML,
31
- wideScreen = false,
32
- alwaysShow = false,
33
- }: Props) => {
34
- const modifiers = {
35
- narrowScreen,
36
- wideScreen,
37
- alwaysShow,
38
- };
20
+ const StyledAside = styled.aside`
21
+ position: relative;
22
+ margin: ${spacing.large} 0px;
23
+ ${mq.range({ from: breakpoints.tablet })} {
24
+ max-width: 350px;
25
+ float: right;
26
+ clear: right;
27
+ width: 50%;
28
+ left: auto !important;
29
+ padding: 0;
30
+ padding-left: ${spacing.small};
31
+ ${mq.range({ from: breakpoints.desktop })} {
32
+ width: 75%;
33
+ }
34
+ }
35
+
36
+ border-left: 4px solid ${colors.background.dark};
37
+ `;
38
+
39
+ const wideScreenStyle = css`
40
+ display: none;
41
+ ${mq.range({ from: breakpoints.tablet })} {
42
+ display: block;
43
+ }
44
+ `;
45
+
46
+ const narrowScreenStyle = css`
47
+ ${mq.range({ from: breakpoints.tablet })} {
48
+ display: none;
49
+ }
50
+ `;
51
+
52
+ const alwaysShowStyle = css`
53
+ display: block !important;
54
+ `;
55
+
56
+ const StyledAsideContent = styled.div`
57
+ color: ${colors.brand.greyDark};
58
+ padding: ${spacing.normal};
59
+
60
+ & > *:first-child {
61
+ margin-top: 0;
62
+ }
63
+ & > *:last-child {
64
+ margin-bottom: 0;
65
+ }
66
+
67
+ h2,
68
+ h3,
69
+ h4,
70
+ h5 {
71
+ ${fonts.size.text.metaText.small};
72
+ margin-top: ${spacing.normal};
73
+ margin-bottom: ${spacing.small};
74
+ }
75
+
76
+ & > ul:not([class]),
77
+ :not(li) > ul:not([class]) {
78
+ ${mq.range({ from: breakpoints.desktop })} {
79
+ margin-left: ${spacing.normal};
80
+ }
81
+ }
82
+
83
+ & > ol:not([class]),
84
+ :not(li) > ol:not([class]) {
85
+ ${mq.range({ from: breakpoints.desktop })} {
86
+ margin-left: ${spacing.large};
87
+ }
88
+ }
89
+ `;
90
+
91
+ const Aside = ({ children, narrowScreen = false, wideScreen = false, alwaysShow = false, ...rest }: Props) => {
92
+ const styling = useMemo(() => {
93
+ const styles = [];
94
+ if (narrowScreen) {
95
+ styles.push(narrowScreenStyle);
96
+ }
97
+ if (wideScreen) {
98
+ styles.push(wideScreenStyle);
99
+ }
100
+ if (alwaysShow) {
101
+ styles.push(alwaysShowStyle);
102
+ }
103
+ return styles;
104
+ }, [alwaysShow, narrowScreen, wideScreen]);
105
+
39
106
  return (
40
- <aside {...classes('', modifiers)}>
41
- <div {...classes('content')} dangerouslySetInnerHTML={dangerouslySetInnerHTML}>
42
- {children}
43
- </div>
44
- </aside>
107
+ <StyledAside css={styling} {...rest}>
108
+ <StyledAsideContent>{children}</StyledAsideContent>
109
+ </StyledAside>
45
110
  );
46
111
  };
47
112
 
@@ -0,0 +1,81 @@
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, StoryFn, StoryObj } from '@storybook/react';
11
+ import { spacing } from '@ndla/core';
12
+ import { ContentTypeBadge } from './ContentTypeBadge';
13
+ import { defaultParameters } from '../../../../stories/defaults';
14
+ import * as contentTypes from '../model/ContentType';
15
+
16
+ export default {
17
+ title: 'Components/ContentTypeBadge',
18
+ tags: ['autodocs'],
19
+ parameters: {
20
+ inlineStories: true,
21
+ ...defaultParameters,
22
+ },
23
+ args: {
24
+ size: 'small',
25
+ border: true,
26
+ type: 'subject-material',
27
+ background: true,
28
+ title: "I'm a badge",
29
+ },
30
+ argTypes: {
31
+ children: { control: false },
32
+ },
33
+ component: ContentTypeBadge,
34
+ } as Meta<typeof ContentTypeBadge>;
35
+
36
+ export const Default: StoryObj<typeof ContentTypeBadge> = {};
37
+
38
+ export const Sizes: StoryFn<typeof ContentTypeBadge> = ({ ...args }) => (
39
+ <>
40
+ <ContentTypeBadge {...args} size="xx-small" />
41
+ <ContentTypeBadge {...args} size="x-small" />
42
+ <ContentTypeBadge {...args} size="small" />
43
+ <ContentTypeBadge {...args} size="large" />
44
+ </>
45
+ );
46
+
47
+ export const NoBorder: StoryObj<typeof ContentTypeBadge> = {
48
+ args: {
49
+ border: false,
50
+ },
51
+ };
52
+
53
+ export const NoBackground: StoryObj<typeof ContentTypeBadge> = {
54
+ args: {
55
+ background: false,
56
+ },
57
+ };
58
+
59
+ const BadgesWrapper = styled.div`
60
+ display: flex;
61
+ align-items: center;
62
+ gap: ${spacing.small};
63
+ `;
64
+
65
+ export const AllBadges: StoryFn<typeof ContentTypeBadge> = ({ ...args }) => (
66
+ <BadgesWrapper>
67
+ <ContentTypeBadge {...args} type={contentTypes.SUBJECT_MATERIAL} />
68
+ <ContentTypeBadge {...args} type={contentTypes.TASKS_AND_ACTIVITIES} />
69
+ <ContentTypeBadge {...args} type={contentTypes.ASSESSMENT_RESOURCES} />
70
+ <ContentTypeBadge {...args} type={contentTypes.SUBJECT} />
71
+ <ContentTypeBadge {...args} type={contentTypes.EXTERNAL_LEARNING_RESOURCES} />
72
+ <ContentTypeBadge {...args} type={contentTypes.SOURCE_MATERIAL} />
73
+ <ContentTypeBadge {...args} type={contentTypes.LEARNING_PATH} />
74
+ <ContentTypeBadge {...args} type={contentTypes.TOPIC} />
75
+ <ContentTypeBadge {...args} type={contentTypes.MULTIDISCIPLINARY_TOPIC} />
76
+ <ContentTypeBadge {...args} type={contentTypes.resourceEmbedTypeMapping.image} />
77
+ <ContentTypeBadge {...args} type={contentTypes.resourceEmbedTypeMapping.audio} />
78
+ <ContentTypeBadge {...args} type={contentTypes.resourceEmbedTypeMapping.video} />
79
+ <ContentTypeBadge {...args} type={contentTypes.resourceEmbedTypeMapping.concept} />
80
+ </BadgesWrapper>
81
+ );
@@ -6,8 +6,11 @@
6
6
  *
7
7
  */
8
8
 
9
- import BEMHelper from 'react-bem-helper';
9
+ import { CSSProperties, ComponentProps, useMemo } from 'react';
10
10
 
11
+ import { css } from '@emotion/react';
12
+ import styled from '@emotion/styled';
13
+ import { breakpoints, colors, mq } from '@ndla/core';
11
14
  import { MenuBook } from '@ndla/icons/action';
12
15
  import {
13
16
  SubjectMaterial,
@@ -24,12 +27,7 @@ import { Concept, ImageNormal, SquareAudio, SquareVideo } from '@ndla/icons/edit
24
27
 
25
28
  import * as contentTypes from '../model/ContentType';
26
29
 
27
- const classes = new BEMHelper({
28
- name: 'content-type-badge',
29
- prefix: 'c-',
30
- });
31
-
32
- interface Props {
30
+ interface Props extends ComponentProps<'div'> {
33
31
  size?: 'xx-small' | 'x-small' | 'small' | 'large';
34
32
  type: string;
35
33
  title?: string;
@@ -38,70 +36,170 @@ interface Props {
38
36
  className?: string;
39
37
  }
40
38
 
41
- export const ContentTypeBadge = ({ type, background, title, size = 'small', border = true, className }: Props) => {
42
- const modifiers = [type, size];
43
-
44
- let embedResource = false;
45
-
46
- let icon = null;
47
- switch (type) {
48
- case contentTypes.SUBJECT_MATERIAL:
49
- icon = <SubjectMaterial title={title} />;
50
- break;
51
- case contentTypes.TASKS_AND_ACTIVITIES:
52
- icon = <TasksAndActivities title={title} />;
53
- break;
54
- case contentTypes.ASSESSMENT_RESOURCES:
55
- icon = <AssessmentResource title={title} />;
56
- break;
57
- case contentTypes.SUBJECT:
58
- icon = <MenuBook title={title} />;
59
- break;
60
- case contentTypes.EXTERNAL_LEARNING_RESOURCES:
61
- icon = <ExternalLearningResource title={title} />;
62
- break;
63
- case contentTypes.SOURCE_MATERIAL:
64
- icon = <SharedResource title={title} />;
65
- break;
66
- case contentTypes.LEARNING_PATH:
67
- icon = <LearningPath title={title} />;
68
- break;
69
- case contentTypes.TOPIC:
70
- icon = <Subject title={title} />;
71
- break;
72
- case contentTypes.MULTIDISCIPLINARY_TOPIC:
73
- icon = <MultidisciplinaryTopic />;
74
- break;
75
- case contentTypes.resourceEmbedTypeMapping.image:
76
- icon = <ImageNormal />;
77
- embedResource = true;
78
- break;
79
- case contentTypes.resourceEmbedTypeMapping.audio:
80
- icon = <SquareAudio />;
81
- embedResource = true;
82
- break;
83
- case contentTypes.resourceEmbedTypeMapping.video:
84
- icon = <SquareVideo />;
85
- embedResource = true;
86
- break;
87
- case contentTypes.resourceEmbedTypeMapping.concept:
88
- icon = <Concept />;
89
- embedResource = true;
90
- break;
91
- default:
92
- break;
93
- }
94
-
95
- if (embedResource) {
96
- modifiers.push('embed-resource');
97
- }
98
- if (background) {
99
- modifiers.push('background');
100
- }
101
- if (border) {
102
- modifiers.push('border');
103
- }
104
- return <div {...classes('', modifiers, className)}>{icon}</div>;
39
+ const sizes = {
40
+ 'xx-small': css`
41
+ width: 20px;
42
+ height: 20px;
43
+ border: 1px solid;
44
+ svg {
45
+ width: 10px;
46
+ height: 10x;
47
+ }
48
+ `,
49
+ 'x-small': css`
50
+ width: 20px;
51
+ height: 20px;
52
+ border: 1px solid;
53
+ ${mq.range({ from: breakpoints.tablet })} {
54
+ height: 26px;
55
+ width: 26px;
56
+ }
57
+ svg {
58
+ width: 10px;
59
+ height: 10x;
60
+ ${mq.range({ from: breakpoints.tablet })} {
61
+ width: 12px;
62
+ height: 12px;
63
+ }
64
+ }
65
+ `,
66
+ small: '',
67
+ large: css`
68
+ width: 50px;
69
+ height: 50px;
70
+ svg {
71
+ width: 25px;
72
+ height: 25px;
73
+ }
74
+ `,
75
+ } as const;
76
+
77
+ const BaseContentTypeBadge = styled.div`
78
+ display: inline-flex;
79
+ align-items: center;
80
+ justify-content: center;
81
+ border-radius: 100%;
82
+ width: 34px;
83
+ height: 34px;
84
+ color: var(--icon-color);
85
+ `;
86
+
87
+ const borderStyle = css`
88
+ border: 2px solid;
89
+ border-color: var(--icon-color);
90
+ `;
91
+
92
+ const backgroundStyle = css`
93
+ background-color: var(--background-color);
94
+ `;
95
+
96
+ const iconMap = {
97
+ [contentTypes.SUBJECT_MATERIAL]: {
98
+ icon: SubjectMaterial,
99
+ iconColor: colors.subjectMaterial.dark,
100
+ backgroundColor: colors.subjectMaterial.light,
101
+ },
102
+ [contentTypes.TASKS_AND_ACTIVITIES]: {
103
+ icon: TasksAndActivities,
104
+ iconColor: colors.tasksAndActivities.dark,
105
+ backgroundColor: colors.tasksAndActivities.light,
106
+ },
107
+ [contentTypes.ASSESSMENT_RESOURCES]: {
108
+ icon: AssessmentResource,
109
+ iconColor: colors.assessmentResource.dark,
110
+ backgroundColor: colors.assessmentResource.light,
111
+ },
112
+ [contentTypes.SUBJECT]: {
113
+ icon: MenuBook,
114
+ iconColor: colors.subject.dark,
115
+ backgroundColor: colors.subject.light,
116
+ },
117
+ [contentTypes.EXTERNAL_LEARNING_RESOURCES]: {
118
+ icon: ExternalLearningResource,
119
+ iconColor: colors.externalLearningResource.dark,
120
+ backgroundColor: colors.externalLearningResource.light,
121
+ },
122
+ [contentTypes.SOURCE_MATERIAL]: {
123
+ icon: SharedResource,
124
+ iconColor: colors.sourceMaterial.dark,
125
+ backgroundColor: colors.sourceMaterial.light,
126
+ },
127
+ [contentTypes.LEARNING_PATH]: {
128
+ icon: LearningPath,
129
+ iconColor: colors.learningPath.dark,
130
+ backgroundColor: colors.learningPath.light,
131
+ },
132
+ [contentTypes.TOPIC]: {
133
+ icon: Subject,
134
+ iconColor: colors.subject.dark,
135
+ backgroundColor: colors.subject.light,
136
+ },
137
+ [contentTypes.MULTIDISCIPLINARY_TOPIC]: {
138
+ icon: MultidisciplinaryTopic,
139
+ backgroundColor: '#b9b37b',
140
+ },
141
+ [contentTypes.resourceEmbedTypeMapping.image]: {
142
+ icon: ImageNormal,
143
+ iconColor: colors.brand.grey,
144
+ backgroundColor: colors.brand.greyLight,
145
+ },
146
+ [contentTypes.resourceEmbedTypeMapping.audio]: {
147
+ icon: SquareAudio,
148
+ iconColor: colors.brand.grey,
149
+ backgroundColor: colors.brand.greyLight,
150
+ },
151
+ [contentTypes.resourceEmbedTypeMapping.video]: {
152
+ icon: SquareVideo,
153
+ iconColor: colors.brand.grey,
154
+ backgroundColor: colors.brand.greyLight,
155
+ },
156
+ [contentTypes.resourceEmbedTypeMapping.concept]: {
157
+ icon: Concept,
158
+ iconColor: colors.brand.grey,
159
+ backgroundColor: colors.brand.greyLight,
160
+ },
161
+ } as const;
162
+
163
+ export const ContentTypeBadge = ({
164
+ type,
165
+ background,
166
+ title,
167
+ size = 'small',
168
+ border = true,
169
+ className,
170
+ ...rest
171
+ }: Props) => {
172
+ const { Icon, style } = useMemo(() => {
173
+ const fromMap = iconMap[type];
174
+ const style = { '--icon-color': fromMap.iconColor, '--background-color': fromMap.backgroundColor } as CSSProperties;
175
+ return { Icon: fromMap.icon, style };
176
+ }, [type]);
177
+
178
+ const cssStyles = useMemo(() => {
179
+ const styles = [sizes[size]];
180
+ if (background) {
181
+ styles.push(backgroundStyle);
182
+ }
183
+ if (border) {
184
+ styles.push(borderStyle);
185
+ }
186
+ return styles;
187
+ }, [background, border, size]);
188
+
189
+ return (
190
+ <BaseContentTypeBadge
191
+ css={cssStyles}
192
+ title={title}
193
+ style={style}
194
+ aria-label={title}
195
+ className={className}
196
+ data-badge=""
197
+ data-type={type}
198
+ {...rest}
199
+ >
200
+ <Icon />
201
+ </BaseContentTypeBadge>
202
+ );
105
203
  };
106
204
 
107
205
  export const SubjectMaterialBadge = (props: Omit<Props, 'type'>) => (