@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.
- package/es/Aside/Aside.js +55 -17
- package/es/ContentTypeBadge/ContentTypeBadge.js +162 -83
- package/es/FramedContent/FramedContent.js +7 -11
- package/es/ResourceGroup/ResourceItem.js +9 -9
- package/es/SearchTypeResult/components/ItemResourceHeader.js +6 -6
- package/es/SearchTypeResult/components/ItemTopicHeader.js +4 -4
- package/es/all.css +1 -1
- package/es/locale/messages-en.js +3 -2
- package/es/locale/messages-nb.js +3 -2
- package/es/locale/messages-nn.js +3 -2
- package/es/locale/messages-se.js +3 -2
- package/es/locale/messages-sma.js +3 -2
- package/lib/Aside/Aside.d.ts +3 -7
- package/lib/Aside/Aside.js +55 -19
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +3 -2
- package/lib/ContentTypeBadge/ContentTypeBadge.js +162 -85
- package/lib/FramedContent/FramedContent.d.ts +1 -1
- package/lib/FramedContent/FramedContent.js +8 -11
- package/lib/ResourceGroup/ResourceItem.js +9 -9
- package/lib/SearchTypeResult/components/ItemResourceHeader.js +6 -6
- package/lib/SearchTypeResult/components/ItemTopicHeader.js +4 -4
- package/lib/all.css +1 -1
- package/lib/locale/messages-en.d.ts +1 -0
- package/lib/locale/messages-en.js +3 -2
- package/lib/locale/messages-nb.d.ts +1 -0
- package/lib/locale/messages-nb.js +3 -2
- package/lib/locale/messages-nn.d.ts +1 -0
- package/lib/locale/messages-nn.js +3 -2
- package/lib/locale/messages-se.d.ts +1 -0
- package/lib/locale/messages-se.js +3 -2
- package/lib/locale/messages-sma.d.ts +1 -0
- package/lib/locale/messages-sma.js +3 -2
- package/package.json +2 -2
- package/src/Article/component.article.scss +1 -1
- package/src/Aside/Aside.tsx +95 -30
- package/src/ContentTypeBadge/ContentTypeBadge.stories.tsx +81 -0
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +169 -71
- package/src/FramedContent/FramedContent.tsx +37 -14
- package/src/ResourceGroup/ResourceItem.tsx +5 -5
- package/src/SearchTypeResult/components/ItemResourceHeader.tsx +1 -1
- package/src/SearchTypeResult/components/ItemTopicHeader.tsx +1 -1
- package/src/locale/messages-en.ts +2 -2
- package/src/locale/messages-nb.ts +2 -2
- package/src/locale/messages-nn.ts +2 -2
- package/src/locale/messages-se.ts +2 -2
- package/src/locale/messages-sma.ts +2 -2
- package/src/main.scss +0 -3
- package/src/Aside/component.aside.scss +0 -91
- package/src/ContentTypeBadge/component.content-type-badge.scss +0 -223
- package/src/global/components/component.bodybox.scss +0 -60
|
@@ -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?
|
|
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',
|
|
@@ -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?
|
|
1022
|
+
bottomText: 'Savner du en kategori? Gi vår moderator beskjed på moderator@ndla.no',
|
|
1022
1023
|
notification: {
|
|
1023
1024
|
title: 'Varslinger',
|
|
1024
1025
|
showAll: 'Se alle varslinger',
|
|
@@ -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?
|
|
1022
|
+
bottomText: 'Saknar du ein kategori? Gi moderatoren vår beskjed på moderator@ndla.no',
|
|
1022
1023
|
notification: {
|
|
1023
1024
|
title: 'Varslingar',
|
|
1024
1025
|
showAll: 'Sjå alle varslingar',
|
|
@@ -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?
|
|
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',
|
|
@@ -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
|
|
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.
|
|
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": "
|
|
84
|
+
"gitHead": "e2746547c6056cd97e80ced58fe8a3be9edf3c4b"
|
|
85
85
|
}
|
package/src/Aside/Aside.tsx
CHANGED
|
@@ -6,42 +6,107 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
<
|
|
41
|
-
<
|
|
42
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
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'>) => (
|