@ndla/ui 56.0.74-alpha.0 → 56.0.75-alpha.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.
- package/dist/panda.buildinfo.json +3 -21
- package/dist/styles.css +8 -76
- package/es/Article/Article.js +2 -2
- package/es/ContentTypeBadge/ContentTypeBadge.js +35 -213
- package/es/ContentTypeHero/ContentTypeHero.js +2 -1
- package/es/RelatedArticleList/RelatedArticleList.js +1 -1
- package/es/index.js +1 -3
- package/es/locale/messages-en.js +2 -1
- package/es/locale/messages-nb.js +2 -1
- package/es/locale/messages-nn.js +2 -1
- package/es/locale/messages-se.js +2 -1
- package/es/locale/messages-sma.js +2 -1
- package/es/model/ContentType.js +2 -0
- package/lib/Article/Article.d.ts +1 -1
- package/lib/Article/Article.js +1 -1
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +9 -19
- package/lib/ContentTypeBadge/ContentTypeBadge.js +36 -223
- package/lib/ContentTypeBlockQuote/ContentTypeBlockQuote.d.ts +1 -1
- package/lib/ContentTypeHero/ContentTypeHero.d.ts +1 -1
- package/lib/ContentTypeHero/ContentTypeHero.js +2 -1
- package/lib/RelatedArticleList/RelatedArticleList.js +2 -2
- package/lib/index.d.ts +2 -4
- package/lib/index.js +5 -61
- package/lib/locale/messages-en.d.ts +1 -0
- package/lib/locale/messages-en.js +2 -1
- package/lib/locale/messages-nb.d.ts +1 -0
- package/lib/locale/messages-nb.js +2 -1
- package/lib/locale/messages-nn.d.ts +1 -0
- package/lib/locale/messages-nn.js +2 -1
- package/lib/locale/messages-se.d.ts +1 -0
- package/lib/locale/messages-se.js +2 -1
- package/lib/locale/messages-sma.d.ts +1 -0
- package/lib/locale/messages-sma.js +2 -1
- package/lib/model/ContentType.d.ts +1 -0
- package/lib/model/ContentType.js +3 -1
- package/package.json +8 -8
- package/src/Article/Article.tsx +3 -3
- package/src/ContentTypeBadge/ContentTypeBadge.stories.tsx +45 -53
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +63 -211
- package/src/ContentTypeBlockQuote/ContentTypeBlockQuote.tsx +1 -1
- package/src/ContentTypeHero/ContentTypeHero.tsx +2 -1
- package/src/RelatedArticleList/RelatedArticleList.tsx +1 -1
- package/src/index.ts +2 -18
- package/src/locale/messages-en.ts +1 -0
- package/src/locale/messages-nb.ts +1 -0
- package/src/locale/messages-nn.ts +1 -0
- package/src/locale/messages-se.ts +1 -0
- package/src/locale/messages-sma.ts +1 -0
- package/src/model/ContentType.ts +2 -0
- package/es/ContentLoader/index.js +0 -82
- package/es/ContentTypeBadge/ContentTypeBadgeNew.js +0 -49
- package/es/ContentTypeBadge/index.js +0 -11
- package/lib/ContentLoader/index.d.ts +0 -16
- package/lib/ContentLoader/index.js +0 -88
- package/lib/ContentTypeBadge/ContentTypeBadgeNew.d.ts +0 -16
- package/lib/ContentTypeBadge/ContentTypeBadgeNew.js +0 -57
- package/lib/ContentTypeBadge/index.d.ts +0 -10
- package/lib/ContentTypeBadge/index.js +0 -57
- package/src/ContentLoader/ContentLoader.stories.tsx +0 -62
- package/src/ContentLoader/index.tsx +0 -73
- package/src/ContentTypeBadge/ContentTypeBadgeNew.stories.tsx +0 -70
- package/src/ContentTypeBadge/ContentTypeBadgeNew.tsx +0 -77
- package/src/ContentTypeBadge/index.ts +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "56.0.
|
|
3
|
+
"version": "56.0.75-alpha.0",
|
|
4
4
|
"description": "UI component library for NDLA",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ndla/core": "^5.0.2",
|
|
36
|
-
"@ndla/icons": "^8.0.
|
|
36
|
+
"@ndla/icons": "^8.0.46-alpha.0",
|
|
37
37
|
"@ndla/licenses": "^8.0.4-alpha.0",
|
|
38
|
-
"@ndla/primitives": "^1.0.
|
|
39
|
-
"@ndla/safelink": "^7.0.
|
|
40
|
-
"@ndla/styled-system": "^0.0.
|
|
38
|
+
"@ndla/primitives": "^1.0.59-alpha.0",
|
|
39
|
+
"@ndla/safelink": "^7.0.60-alpha.0",
|
|
40
|
+
"@ndla/styled-system": "^0.0.29",
|
|
41
41
|
"@ndla/util": "^5.0.1-alpha.0",
|
|
42
42
|
"html-react-parser": "^5.1.8",
|
|
43
43
|
"i18next-browser-languagedetector": "^7.1.0"
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"react-router-dom": "> 6.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@ndla/preset-panda": "^0.0.
|
|
53
|
+
"@ndla/preset-panda": "^0.0.47",
|
|
54
54
|
"@ndla/types-backend": "^0.2.86",
|
|
55
55
|
"@ndla/types-embed": "^5.0.4-alpha.0",
|
|
56
|
-
"@pandacss/dev": "^0.
|
|
56
|
+
"@pandacss/dev": "^0.48.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "8929fb445477b02e740a9a21fd2d3ef08287d99c"
|
|
62
62
|
}
|
package/src/Article/Article.tsx
CHANGED
|
@@ -12,9 +12,9 @@ import { Heading, Text } from "@ndla/primitives";
|
|
|
12
12
|
import { cx } from "@ndla/styled-system/css";
|
|
13
13
|
import { Stack, styled } from "@ndla/styled-system/jsx";
|
|
14
14
|
import { JsxStyleProps } from "@ndla/styled-system/types";
|
|
15
|
-
import {
|
|
15
|
+
import { ContentTypeBadge } from "..";
|
|
16
16
|
import { ArticleByline } from "./ArticleByline";
|
|
17
|
-
import { ContentType } from "../ContentTypeBadge/
|
|
17
|
+
import { ContentType } from "../ContentTypeBadge/ContentTypeBadge";
|
|
18
18
|
import { Article as ArticleType } from "../types";
|
|
19
19
|
|
|
20
20
|
const StyledArticleContent = styled(ark.section, {}, { baseComponent: true });
|
|
@@ -135,7 +135,7 @@ export const ArticleTitle = ({
|
|
|
135
135
|
<ArticleHGroup>
|
|
136
136
|
{(!!contentType || !!heartButton) && (
|
|
137
137
|
<StyledStack justify="space-between" align="center" direction="row" gap="small">
|
|
138
|
-
{!!contentType && <
|
|
138
|
+
{!!contentType && <ContentTypeBadge contentType={contentType}>{contentTypeLabel}</ContentTypeBadge>}
|
|
139
139
|
{heartButton}
|
|
140
140
|
</StyledStack>
|
|
141
141
|
)}
|
|
@@ -1,83 +1,75 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the GPLv3 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { useTranslation } from "react-i18next";
|
|
9
10
|
import { Meta, StoryFn, StoryObj } from "@storybook/react";
|
|
10
|
-
import {
|
|
11
|
+
import { MovieLine } from "@ndla/icons/editor";
|
|
12
|
+
import { HStack, styled } from "@ndla/styled-system/jsx";
|
|
11
13
|
import { ContentTypeBadge } from "./ContentTypeBadge";
|
|
12
|
-
import * as contentTypes from "../model/ContentType";
|
|
13
14
|
|
|
14
15
|
export default {
|
|
15
16
|
title: "Components/ContentTypeBadge",
|
|
17
|
+
component: ContentTypeBadge,
|
|
16
18
|
tags: ["autodocs"],
|
|
17
19
|
parameters: {
|
|
18
20
|
inlineStories: true,
|
|
19
21
|
},
|
|
20
22
|
args: {
|
|
21
|
-
|
|
22
|
-
border: true,
|
|
23
|
-
type: "subject-material",
|
|
24
|
-
background: true,
|
|
25
|
-
title: "I'm a badge",
|
|
26
|
-
},
|
|
27
|
-
argTypes: {
|
|
28
|
-
children: { control: false },
|
|
23
|
+
contentType: "subject-material",
|
|
29
24
|
},
|
|
30
|
-
|
|
31
|
-
} as Meta<typeof ContentTypeBadge>;
|
|
25
|
+
} satisfies Meta<typeof ContentTypeBadge>;
|
|
32
26
|
|
|
33
27
|
export const Default: StoryObj<typeof ContentTypeBadge> = {};
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<ContentTypeBadge {...args} size="x-small" />
|
|
39
|
-
<ContentTypeBadge {...args} size="small" />
|
|
40
|
-
<ContentTypeBadge {...args} size="large" />
|
|
41
|
-
</>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export const NoBorder: StoryObj<typeof ContentTypeBadge> = {
|
|
45
|
-
args: {
|
|
46
|
-
border: false,
|
|
29
|
+
const StyledHStack = styled(HStack, {
|
|
30
|
+
base: {
|
|
31
|
+
flexWrap: "wrap",
|
|
47
32
|
},
|
|
48
|
-
};
|
|
33
|
+
});
|
|
49
34
|
|
|
50
|
-
export const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
export const AllBadges: StoryFn<typeof ContentTypeBadge> = () => (
|
|
36
|
+
<StyledHStack gap="3xsmall">
|
|
37
|
+
<ContentTypeBadge contentType="subject-material" />
|
|
38
|
+
<ContentTypeBadge contentType="tasks-and-activities" />
|
|
39
|
+
<ContentTypeBadge contentType="assessment-resources" />
|
|
40
|
+
<ContentTypeBadge contentType="subject" />
|
|
41
|
+
<ContentTypeBadge contentType="source-material" />
|
|
42
|
+
<ContentTypeBadge contentType="learning-path" />
|
|
43
|
+
<ContentTypeBadge contentType="topic" />
|
|
44
|
+
<ContentTypeBadge contentType="multidisciplinary" />
|
|
45
|
+
<ContentTypeBadge contentType="concept" />
|
|
46
|
+
<ContentTypeBadge contentType="external" />
|
|
47
|
+
<ContentTypeBadge contentType="image" />
|
|
48
|
+
<ContentTypeBadge contentType="audio" />
|
|
49
|
+
<ContentTypeBadge contentType="video" />
|
|
50
|
+
<ContentTypeBadge contentType="missing" />
|
|
51
|
+
<ContentTypeBadge contentType="frontpage-article" />
|
|
52
|
+
<ContentTypeBadge contentType="programme" />
|
|
53
|
+
<ContentTypeBadge contentType="podcast" />
|
|
54
|
+
<ContentTypeBadge contentType="podcast-series" />
|
|
55
|
+
<ContentTypeBadge contentType="gloss" />
|
|
56
|
+
</StyledHStack>
|
|
57
|
+
);
|
|
55
58
|
|
|
56
|
-
const
|
|
59
|
+
const StyledContentTypeBadge = styled(ContentTypeBadge, {
|
|
57
60
|
base: {
|
|
58
61
|
display: "flex",
|
|
62
|
+
gap: "4xsmall",
|
|
59
63
|
alignItems: "center",
|
|
60
|
-
gap: "xsmall",
|
|
61
64
|
},
|
|
62
65
|
});
|
|
63
66
|
|
|
64
|
-
export const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<ContentTypeBadge {...args} type={contentTypes.MULTIDISCIPLINARY} />
|
|
74
|
-
<ContentTypeBadge {...args} type={contentTypes.CONCEPT} />
|
|
75
|
-
<ContentTypeBadge {...args} type={contentTypes.EXTERNAL} />
|
|
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.GLOSS} />
|
|
80
|
-
<ContentTypeBadge {...args} type={contentTypes.PROGRAMME} />
|
|
81
|
-
<ContentTypeBadge {...args} type={contentTypes.PODCAST_SERIES} />
|
|
82
|
-
</BadgesWrapper>
|
|
83
|
-
);
|
|
67
|
+
export const ContentOverride: StoryFn<typeof ContentTypeBadge> = () => {
|
|
68
|
+
const { t } = useTranslation();
|
|
69
|
+
return (
|
|
70
|
+
<StyledContentTypeBadge contentType="video">
|
|
71
|
+
<MovieLine size="small" />
|
|
72
|
+
{t("contentTypes.video")}
|
|
73
|
+
</StyledContentTypeBadge>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -1,227 +1,79 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2024-present, NDLA.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the GPLv3 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import { BookmarkLine, SubtractLine } from "@ndla/icons/action";
|
|
13
|
-
import { BookReadFill, ShareFill, VoicePrintLine } from "@ndla/icons/common";
|
|
14
|
-
import { MenuSearchLine, LearningPath, SharedResource, TasksAndActivities } from "@ndla/icons/contentType";
|
|
15
|
-
import { ChatLine, FileListLine, LinkMedium, ImageLine, MovieLine } from "@ndla/icons/editor";
|
|
16
|
-
import { styled } from "@ndla/styled-system/jsx";
|
|
17
|
-
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
11
|
+
import { Badge, BadgeProps, type BadgeVariant } from "@ndla/primitives";
|
|
18
12
|
import * as contentTypes from "../model/ContentType";
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
interface Props extends ComponentPropsWithoutRef<"div"> {
|
|
23
|
-
size?: "xx-small" | "x-small" | "small" | "large";
|
|
24
|
-
type: string;
|
|
25
|
-
title?: string;
|
|
26
|
-
background?: boolean;
|
|
27
|
-
border?: boolean;
|
|
28
|
-
className?: string;
|
|
14
|
+
export interface ContentTypeBadgeProps extends Omit<BadgeProps, "colorTheme"> {
|
|
15
|
+
contentType: ContentType | undefined;
|
|
29
16
|
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
width: "10px",
|
|
52
|
-
height: "10px",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
"x-small": {
|
|
56
|
-
width: "20px",
|
|
57
|
-
height: "20px",
|
|
58
|
-
border: "1px solid",
|
|
59
|
-
tablet: {
|
|
60
|
-
height: "26px",
|
|
61
|
-
width: "26px",
|
|
62
|
-
},
|
|
63
|
-
"& svg": {
|
|
64
|
-
width: "10px",
|
|
65
|
-
height: "10px",
|
|
66
|
-
tablet: {
|
|
67
|
-
width: "12px",
|
|
68
|
-
height: "12px",
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
small: {
|
|
73
|
-
width: "34px",
|
|
74
|
-
height: "34px",
|
|
75
|
-
},
|
|
76
|
-
large: {
|
|
77
|
-
width: "50px",
|
|
78
|
-
height: "50px",
|
|
79
|
-
"& svg": {
|
|
80
|
-
width: "25px",
|
|
81
|
-
height: "25px",
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
border: {
|
|
86
|
-
true: {
|
|
87
|
-
border: "2px solid",
|
|
88
|
-
borderColor: "var(--icon-color)",
|
|
89
|
-
},
|
|
90
|
-
false: {},
|
|
91
|
-
},
|
|
92
|
-
background: {
|
|
93
|
-
true: {
|
|
94
|
-
backgroundColor: "var(--background-color)",
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
});
|
|
18
|
+
export type StrictContentType =
|
|
19
|
+
| typeof contentTypes.SUBJECT_MATERIAL
|
|
20
|
+
| typeof contentTypes.TASKS_AND_ACTIVITIES
|
|
21
|
+
| typeof contentTypes.ASSESSMENT_RESOURCES
|
|
22
|
+
| typeof contentTypes.SUBJECT
|
|
23
|
+
| typeof contentTypes.SOURCE_MATERIAL
|
|
24
|
+
| typeof contentTypes.LEARNING_PATH
|
|
25
|
+
| typeof contentTypes.TOPIC
|
|
26
|
+
| typeof contentTypes.MULTIDISCIPLINARY
|
|
27
|
+
| typeof contentTypes.CONCEPT
|
|
28
|
+
| typeof contentTypes.EXTERNAL
|
|
29
|
+
| typeof contentTypes.IMAGE
|
|
30
|
+
| typeof contentTypes.AUDIO
|
|
31
|
+
| typeof contentTypes.VIDEO
|
|
32
|
+
| typeof contentTypes.MISSING
|
|
33
|
+
| typeof contentTypes.PODCAST
|
|
34
|
+
| typeof contentTypes.GLOSS
|
|
35
|
+
| typeof contentTypes.PROGRAMME
|
|
36
|
+
| typeof contentTypes.PODCAST_SERIES
|
|
37
|
+
| typeof contentTypes.FRONTPAGE_ARTICLE;
|
|
99
38
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
backgroundColor: colors.subjectMaterial.light,
|
|
105
|
-
},
|
|
106
|
-
[contentTypes.TASKS_AND_ACTIVITIES]: {
|
|
107
|
-
icon: TasksAndActivities,
|
|
108
|
-
iconColor: colors.tasksAndActivities.dark,
|
|
109
|
-
backgroundColor: colors.tasksAndActivities.light,
|
|
110
|
-
},
|
|
111
|
-
[contentTypes.ASSESSMENT_RESOURCES]: {
|
|
112
|
-
icon: MenuSearchLine,
|
|
113
|
-
iconColor: colors.assessmentResource.dark,
|
|
114
|
-
backgroundColor: colors.assessmentResource.light,
|
|
115
|
-
},
|
|
116
|
-
[contentTypes.SUBJECT]: {
|
|
117
|
-
icon: BookReadFill,
|
|
118
|
-
iconColor: colors.subject.dark,
|
|
119
|
-
backgroundColor: colors.subject.light,
|
|
120
|
-
},
|
|
121
|
-
[contentTypes.SOURCE_MATERIAL]: {
|
|
122
|
-
icon: SharedResource,
|
|
123
|
-
iconColor: colors.sourceMaterial.dark,
|
|
124
|
-
backgroundColor: colors.sourceMaterial.light,
|
|
125
|
-
},
|
|
126
|
-
[contentTypes.LEARNING_PATH]: {
|
|
127
|
-
icon: LearningPath,
|
|
128
|
-
iconColor: colors.learningPath.dark,
|
|
129
|
-
backgroundColor: colors.learningPath.light,
|
|
130
|
-
},
|
|
131
|
-
[contentTypes.TOPIC]: {
|
|
132
|
-
icon: BookmarkLine,
|
|
133
|
-
iconColor: colors.subject.dark,
|
|
134
|
-
backgroundColor: colors.subject.light,
|
|
135
|
-
},
|
|
136
|
-
[contentTypes.MULTIDISCIPLINARY]: {
|
|
137
|
-
icon: ShareFill,
|
|
138
|
-
backgroundColor: "#b9b37b",
|
|
139
|
-
},
|
|
140
|
-
[contentTypes.CONCEPT]: {
|
|
141
|
-
icon: ChatLine,
|
|
142
|
-
iconColor: colors.concept.text,
|
|
143
|
-
backgroundColor: colors.concept.light,
|
|
144
|
-
},
|
|
145
|
-
[contentTypes.EXTERNAL]: {
|
|
146
|
-
icon: LinkMedium,
|
|
147
|
-
iconColor: colors.external.dark,
|
|
148
|
-
backgroundColor: colors.external.light,
|
|
149
|
-
},
|
|
150
|
-
[contentTypes.resourceEmbedTypeMapping.image]: {
|
|
151
|
-
icon: ImageLine,
|
|
152
|
-
iconColor: colors.brand.grey,
|
|
153
|
-
backgroundColor: colors.brand.greyLight,
|
|
154
|
-
},
|
|
155
|
-
[contentTypes.resourceEmbedTypeMapping.audio]: {
|
|
156
|
-
icon: VoicePrintLine,
|
|
157
|
-
iconColor: colors.brand.grey,
|
|
158
|
-
backgroundColor: colors.brand.greyLight,
|
|
159
|
-
},
|
|
160
|
-
[contentTypes.resourceEmbedTypeMapping.video]: {
|
|
161
|
-
icon: MovieLine,
|
|
162
|
-
iconColor: colors.brand.grey,
|
|
163
|
-
backgroundColor: colors.brand.greyLight,
|
|
164
|
-
},
|
|
165
|
-
[contentTypes.MISSING]: {
|
|
166
|
-
icon: SubtractLine,
|
|
167
|
-
iconColor: colors.brand.grey,
|
|
168
|
-
backgroundColor: colors.brand.greyLight,
|
|
169
|
-
},
|
|
170
|
-
} as const;
|
|
171
|
-
|
|
172
|
-
export const ContentTypeBadge = ({
|
|
173
|
-
type,
|
|
174
|
-
background,
|
|
175
|
-
title,
|
|
176
|
-
size = "small",
|
|
177
|
-
border = true,
|
|
178
|
-
className,
|
|
179
|
-
...rest
|
|
180
|
-
}: Props) => {
|
|
181
|
-
const { Icon, style } = useMemo(() => {
|
|
182
|
-
const fromMap = iconMap[type];
|
|
183
|
-
const style = {
|
|
184
|
-
"--icon-color": fromMap.iconColor,
|
|
185
|
-
"--background-color": fromMap.backgroundColor,
|
|
186
|
-
} as CSSProperties;
|
|
187
|
-
return { Icon: fromMap.icon, style };
|
|
188
|
-
}, [type]);
|
|
39
|
+
export type ContentType =
|
|
40
|
+
| StrictContentType
|
|
41
|
+
// This allows for us to fallback to string without getting a ts error, while still keeping intellisense
|
|
42
|
+
| (string & {});
|
|
189
43
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
44
|
+
export const contentTypeToBadgeVariantMap: Record<ContentType, BadgeVariant> = {
|
|
45
|
+
[contentTypes.SUBJECT_MATERIAL]: "brand1",
|
|
46
|
+
[contentTypes.TASKS_AND_ACTIVITIES]: "brand2",
|
|
47
|
+
[contentTypes.ASSESSMENT_RESOURCES]: "brand2",
|
|
48
|
+
[contentTypes.SUBJECT]: "neutral",
|
|
49
|
+
[contentTypes.SOURCE_MATERIAL]: "brand1",
|
|
50
|
+
[contentTypes.LEARNING_PATH]: "brand3",
|
|
51
|
+
[contentTypes.TOPIC]: "neutral",
|
|
52
|
+
[contentTypes.MULTIDISCIPLINARY]: "neutral",
|
|
53
|
+
[contentTypes.CONCEPT]: "brand1",
|
|
54
|
+
[contentTypes.EXTERNAL]: "brand2",
|
|
55
|
+
[contentTypes.IMAGE]: "brand1",
|
|
56
|
+
[contentTypes.AUDIO]: "brand1",
|
|
57
|
+
[contentTypes.PODCAST]: "brand1",
|
|
58
|
+
[contentTypes.VIDEO]: "brand1",
|
|
59
|
+
[contentTypes.MISSING]: "neutral",
|
|
60
|
+
[contentTypes.PODCAST_SERIES]: "brand1",
|
|
61
|
+
[contentTypes.GLOSS]: "brand1",
|
|
62
|
+
[contentTypes.PROGRAMME]: "neutral",
|
|
63
|
+
[contentTypes.FRONTPAGE_ARTICLE]: "brand2",
|
|
206
64
|
};
|
|
207
65
|
|
|
208
|
-
export const
|
|
209
|
-
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
export const LearningPathBadge = (props: Omit<Props, "type">) => (
|
|
222
|
-
<ContentTypeBadge {...props} type={contentTypes.LEARNING_PATH} />
|
|
223
|
-
);
|
|
224
|
-
export const MultidisciplinaryTopicBadge = (props: Omit<Props, "type">) => (
|
|
225
|
-
<ContentTypeBadge {...props} type={contentTypes.MULTIDISCIPLINARY} />
|
|
66
|
+
export const ContentTypeBadge = forwardRef<HTMLDivElement, ContentTypeBadgeProps>(
|
|
67
|
+
({ contentType, children, ...props }, ref) => {
|
|
68
|
+
const { t } = useTranslation();
|
|
69
|
+
return (
|
|
70
|
+
<Badge
|
|
71
|
+
colorTheme={contentTypeToBadgeVariantMap[contentType ?? "missing"] ?? contentTypeToBadgeVariantMap["missing"]}
|
|
72
|
+
{...props}
|
|
73
|
+
ref={ref}
|
|
74
|
+
>
|
|
75
|
+
{children ?? t(`contentTypes.${contentType}`)}
|
|
76
|
+
</Badge>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
226
79
|
);
|
|
227
|
-
export const ConceptBadge = (props: Omit<Props, "type">) => <ContentTypeBadge {...props} type={contentTypes.CONCEPT} />;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { forwardRef } from "react";
|
|
10
10
|
import { BlockQuote, BlockQuoteProps, BlockQuoteVariantProps } from "@ndla/primitives";
|
|
11
|
-
import { ContentType } from "../ContentTypeBadge/
|
|
11
|
+
import { ContentType } from "../ContentTypeBadge/ContentTypeBadge";
|
|
12
12
|
|
|
13
13
|
export type ContentTypeBlockQuoteVariant = "colored" | "neutral";
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { forwardRef } from "react";
|
|
10
10
|
import { Hero, HeroProps, HeroVariant } from "@ndla/primitives";
|
|
11
|
-
import { ContentType } from "../ContentTypeBadge/
|
|
11
|
+
import { ContentType } from "../ContentTypeBadge/ContentTypeBadge";
|
|
12
12
|
import * as contentTypes from "../model/ContentType";
|
|
13
13
|
|
|
14
14
|
export const contentTypeToHeroMap: Record<ContentType, HeroVariant> = {
|
|
@@ -34,6 +34,7 @@ export const contentTypeToHeroMap: Record<ContentType, HeroVariant> = {
|
|
|
34
34
|
[contentTypes.PROGRAMME]: "primary",
|
|
35
35
|
// this will never happen
|
|
36
36
|
[contentTypes.PODCAST_SERIES]: "primary",
|
|
37
|
+
[contentTypes.FRONTPAGE_ARTICLE]: "primary",
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
export interface ContentTypeHeroProps extends HeroProps {
|
|
@@ -13,7 +13,7 @@ import { CardContent, CardHeading, CardRoot, Text, Heading, Button } from "@ndla
|
|
|
13
13
|
import { SafeLink } from "@ndla/safelink";
|
|
14
14
|
import { styled } from "@ndla/styled-system/jsx";
|
|
15
15
|
import { linkOverlay } from "@ndla/styled-system/patterns";
|
|
16
|
-
import { ContentTypeBadge } from "../ContentTypeBadge/
|
|
16
|
+
import { ContentTypeBadge } from "../ContentTypeBadge/ContentTypeBadge";
|
|
17
17
|
import { contentTypes } from "../model/ContentType";
|
|
18
18
|
import { HeadingLevel } from "../types";
|
|
19
19
|
|
package/src/index.ts
CHANGED
|
@@ -54,8 +54,6 @@ export {
|
|
|
54
54
|
|
|
55
55
|
export { getPossiblyRelativeUrl } from "./utils/relativeUrl";
|
|
56
56
|
|
|
57
|
-
export { default as ContentLoader } from "./ContentLoader";
|
|
58
|
-
|
|
59
57
|
export { default as RelatedArticleList, RelatedArticle } from "./RelatedArticleList";
|
|
60
58
|
|
|
61
59
|
export { ErrorResourceAccessDenied, default as ErrorMessage } from "./ErrorMessage";
|
|
@@ -94,22 +92,8 @@ export {
|
|
|
94
92
|
useVideoSearchTranslations,
|
|
95
93
|
} from "./i18n";
|
|
96
94
|
|
|
97
|
-
export {
|
|
98
|
-
|
|
99
|
-
SubjectMaterialBadge,
|
|
100
|
-
TasksAndActivitiesBadge,
|
|
101
|
-
AssessmentResourcesBadge,
|
|
102
|
-
LearningPathBadge,
|
|
103
|
-
SubjectBadge,
|
|
104
|
-
SourceMaterialBadge,
|
|
105
|
-
ConceptBadge,
|
|
106
|
-
} from "./ContentTypeBadge";
|
|
107
|
-
|
|
108
|
-
export type { ContentTypeBadgeProps, StrictContentType, ContentType } from "./ContentTypeBadge/ContentTypeBadgeNew";
|
|
109
|
-
export {
|
|
110
|
-
ContentTypeBadge as ContentTypeBadgeNew,
|
|
111
|
-
contentTypeToBadgeVariantMap,
|
|
112
|
-
} from "./ContentTypeBadge/ContentTypeBadgeNew";
|
|
95
|
+
export type { ContentTypeBadgeProps, StrictContentType, ContentType } from "./ContentTypeBadge/ContentTypeBadge";
|
|
96
|
+
export { ContentTypeBadge, contentTypeToBadgeVariantMap } from "./ContentTypeBadge/ContentTypeBadge";
|
|
113
97
|
|
|
114
98
|
export { ContentTypeBlockQuote } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
|
|
115
99
|
export { type ContentTypeBlockQuoteVariant } from "./ContentTypeBlockQuote/ContentTypeBlockQuote";
|
package/src/model/ContentType.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const PODCAST = "podcast";
|
|
|
24
24
|
export const GLOSS = "gloss";
|
|
25
25
|
export const PROGRAMME = "programme";
|
|
26
26
|
export const PODCAST_SERIES = "podcast-series";
|
|
27
|
+
export const FRONTPAGE_ARTICLE = "frontpage-article";
|
|
27
28
|
|
|
28
29
|
export const contentTypes = {
|
|
29
30
|
SUBJECT_MATERIAL,
|
|
@@ -57,6 +58,7 @@ export const contentTypeMapping: Record<string, string> = {
|
|
|
57
58
|
[RESOURCE_TYPE_CONCEPT]: CONCEPT,
|
|
58
59
|
[MULTIDISCIPLINARY]: MULTIDISCIPLINARY,
|
|
59
60
|
[TOPIC]: TOPIC,
|
|
61
|
+
[FRONTPAGE_ARTICLE]: FRONTPAGE_ARTICLE,
|
|
60
62
|
default: SUBJECT_MATERIAL,
|
|
61
63
|
};
|
|
62
64
|
|