@ndla/ui 50.10.3 → 50.11.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 (76) hide show
  1. package/es/ContentTypeBadge/ContentTypeBadge.js +21 -21
  2. package/es/ContentTypeBadge/index.js +1 -1
  3. package/es/Embed/ConceptEmbed.js +7 -7
  4. package/es/Embed/RelatedContentEmbed.js +1 -1
  5. package/es/Hero/Hero.js +7 -7
  6. package/es/Hero/index.js +1 -1
  7. package/es/RelatedArticleList/RelatedArticleList.js +8 -8
  8. package/es/ResourceGroup/ResourceGroup.js +6 -5
  9. package/es/ResourceGroup/ResourceItem.js +42 -37
  10. package/es/ResourceGroup/ResourceList.js +24 -26
  11. package/es/SearchTypeResult/SearchTypeResult.js +2 -2
  12. package/es/all.css +1 -1
  13. package/es/index.js +2 -2
  14. package/es/locale/messages-en.js +0 -1
  15. package/es/locale/messages-nb.js +0 -1
  16. package/es/locale/messages-nn.js +0 -1
  17. package/es/locale/messages-se.js +0 -1
  18. package/es/locale/messages-sma.js +0 -1
  19. package/es/model/ContentType.js +8 -6
  20. package/es/utils/resourceTypeColor.js +2 -2
  21. package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +1 -1
  22. package/lib/ContentTypeBadge/ContentTypeBadge.js +23 -23
  23. package/lib/ContentTypeBadge/index.d.ts +1 -1
  24. package/lib/ContentTypeBadge/index.js +2 -2
  25. package/lib/Embed/ConceptEmbed.js +7 -7
  26. package/lib/Embed/RelatedContentEmbed.js +1 -1
  27. package/lib/Hero/Hero.d.ts +2 -2
  28. package/lib/Hero/Hero.js +8 -8
  29. package/lib/Hero/index.d.ts +1 -1
  30. package/lib/Hero/index.js +2 -2
  31. package/lib/RelatedArticleList/RelatedArticleList.js +8 -8
  32. package/lib/ResourceGroup/ResourceGroup.js +6 -5
  33. package/lib/ResourceGroup/ResourceItem.js +42 -37
  34. package/lib/ResourceGroup/ResourceList.js +24 -26
  35. package/lib/SearchTypeResult/SearchTypeResult.d.ts +1 -1
  36. package/lib/SearchTypeResult/SearchTypeResult.js +2 -2
  37. package/lib/all.css +1 -1
  38. package/lib/index.d.ts +2 -2
  39. package/lib/index.js +12 -12
  40. package/lib/locale/messages-en.d.ts +0 -1
  41. package/lib/locale/messages-en.js +0 -1
  42. package/lib/locale/messages-nb.d.ts +0 -1
  43. package/lib/locale/messages-nb.js +0 -1
  44. package/lib/locale/messages-nn.d.ts +0 -1
  45. package/lib/locale/messages-nn.js +0 -1
  46. package/lib/locale/messages-se.d.ts +0 -1
  47. package/lib/locale/messages-se.js +0 -1
  48. package/lib/locale/messages-sma.d.ts +0 -1
  49. package/lib/locale/messages-sma.js +0 -1
  50. package/lib/model/ContentType.d.ts +5 -3
  51. package/lib/model/ContentType.js +9 -7
  52. package/lib/model/index.d.ts +2 -1
  53. package/lib/utils/resourceTypeColor.js +2 -2
  54. package/package.json +17 -17
  55. package/src/Article/component.article.scss +2 -2
  56. package/src/ContentTypeBadge/ContentTypeBadge.stories.tsx +2 -2
  57. package/src/ContentTypeBadge/ContentTypeBadge.tsx +15 -19
  58. package/src/ContentTypeBadge/index.ts +1 -1
  59. package/src/Embed/ConceptEmbed.tsx +3 -3
  60. package/src/Embed/RelatedContentEmbed.tsx +1 -1
  61. package/src/Hero/Hero.tsx +8 -10
  62. package/src/Hero/index.ts +1 -1
  63. package/src/RelatedArticleList/RelatedArticleList.tsx +1 -1
  64. package/src/ResourceGroup/ResourceGroup.tsx +2 -2
  65. package/src/ResourceGroup/ResourceItem.stories.tsx +2 -2
  66. package/src/ResourceGroup/ResourceItem.tsx +62 -36
  67. package/src/ResourceGroup/ResourceList.tsx +28 -30
  68. package/src/SearchTypeResult/SearchTypeResult.tsx +1 -1
  69. package/src/index.ts +2 -2
  70. package/src/locale/messages-en.ts +0 -1
  71. package/src/locale/messages-nb.ts +0 -1
  72. package/src/locale/messages-nn.ts +0 -1
  73. package/src/locale/messages-se.ts +0 -1
  74. package/src/locale/messages-sma.ts +0 -1
  75. package/src/model/ContentType.ts +8 -5
  76. package/src/utils/resourceTypeColor.tsx +2 -2
@@ -25,8 +25,8 @@ const listElementActiveColor = (contentType?: string) => {
25
25
  return colors.tasksAndActivities.dark;
26
26
  case contentTypes.ASSESSMENT_RESOURCES:
27
27
  return colors.assessmentResource.dark;
28
- case contentTypes.EXTERNAL_LEARNING_RESOURCES:
29
- return colors.externalLearningResource.dark;
28
+ case contentTypes.CONCEPT:
29
+ return colors.concept.text;
30
30
  case contentTypes.SOURCE_MATERIAL:
31
31
  return colors.sourceMaterial.dark;
32
32
  case contentTypes.LEARNING_PATH:
@@ -63,9 +63,15 @@ const ListElement = styled.li`
63
63
  border-radius: ${misc.borderRadius};
64
64
  background: ${colors.white};
65
65
  margin-bottom: ${spacing.xsmall};
66
- display: flex;
67
- justify-content: space-between;
66
+ display: grid;
68
67
  align-items: center;
68
+ grid-template-areas:
69
+ "badge resourceType typeWrapper"
70
+ "badge resourceLink typeWrapper";
71
+ grid-row-gap: ${spacing.xsmall};
72
+ grid-template-columns: auto 1fr auto;
73
+ grid-template-rows: auto auto;
74
+
69
75
  padding: ${spacing.small};
70
76
  &[data-additional="true"] {
71
77
  border-style: dashed;
@@ -96,9 +102,28 @@ const ListElement = styled.li`
96
102
  &[hidden] {
97
103
  display: none;
98
104
  }
105
+ [data-badge-wrapper="true"] {
106
+ &:has(+ a:hover) {
107
+ svg {
108
+ width: 20px;
109
+ height: 20px;
110
+ }
111
+ }
112
+ }
113
+ &:not([data-content-type]) {
114
+ grid-template-areas: "badge resourceLink typeWrapper";
115
+ grid-row-gap: 0;
116
+ align-items: center;
117
+ }
118
+ ${mq.range({ from: breakpoints.desktop })} {
119
+ grid-template-areas: "badge resourceLink resourceType typeWrapper";
120
+ grid-row-gap: 0;
121
+ align-items: center;
122
+ }
99
123
  `;
100
124
 
101
125
  const ResourceLink = styled(SafeLink)`
126
+ grid-area: resourceLink;
102
127
  display: flex;
103
128
  width: 100%;
104
129
  align-items: center;
@@ -118,35 +143,21 @@ const ResourceLink = styled(SafeLink)`
118
143
  }
119
144
  &:hover {
120
145
  text-decoration: none;
121
- [data-badge-wrapper="true"] {
122
- [data-badge] {
123
- width: ${spacing.mediumlarge};
124
- height: ${spacing.mediumlarge};
125
-
126
- svg {
127
- width: 20px;
128
- height: 20px;
129
- }
130
- [data-type="subject-material"],
131
- [data-type="learning-path"],
132
- [data-type="source-material"],
133
- [data-type="external-learning-resources"] {
134
- svg {
135
- width: ${spacing.medium};
136
- height: ${spacing.medium};
137
- }
138
- }
139
- }
140
- }
141
146
  }
142
147
  `;
143
148
 
144
- const InlineContainer = styled.div`
145
- display: inline;
146
- width: 100%;
149
+ const TitleContainer = styled.div`
150
+ align-items: normal;
151
+ display: flex;
152
+ flex-direction: column;
153
+ ${mq.range({ from: breakpoints.desktop })} {
154
+ align-items: center;
155
+ flex-direction: row;
156
+ }
147
157
  `;
148
158
 
149
159
  const ContentBadgeWrapper = styled.div`
160
+ grid-area: badge;
150
161
  display: flex;
151
162
  flex: 0 0 auto;
152
163
  text-align: center;
@@ -161,29 +172,43 @@ const ContentBadgeWrapper = styled.div`
161
172
  padding-left: ${spacing.xsmall};
162
173
  }
163
174
  ${mq.range({ from: breakpoints.desktop })} {
175
+ align-items: center;
164
176
  padding-right: ${spacing.nsmall};
165
177
  }
166
178
  `;
167
179
 
168
180
  const TypeWrapper = styled.div`
181
+ grid-area: typeWrapper;
169
182
  display: flex;
170
183
  align-items: center;
171
184
  gap: ${spacing.xsmall};
185
+ ${mq.range({ from: breakpoints.desktop })} {
186
+ align-items: center;
187
+ }
172
188
  `;
173
189
 
174
190
  const ContentTypeName = styled.span`
191
+ grid-area: resourceType;
175
192
  font-family: ${fonts.sans};
176
193
  ${fonts.sizes("14px", "18px")};
177
194
  font-weight: ${fonts.weight.semibold};
178
195
  color: ${colors.text.light};
179
- text-align: right;
196
+ text-align: left;
197
+ ${mq.range({ from: breakpoints.desktop })} {
198
+ padding-left: 0;
199
+ text-align: right;
200
+ margin: 0 ${spacing.xsmall};
201
+ }
180
202
  `;
181
203
 
182
204
  const CurrentSmall = styled.small`
183
- margin-left: ${spacing.xsmall};
184
205
  text-decoration: none;
185
206
  color: ${colors.text.primary};
186
207
  font-weight: ${fonts.weight.normal};
208
+ white-space: nowrap;
209
+ ${mq.range({ from: breakpoints.desktop })} {
210
+ padding: 0 ${spacing.xsmall};
211
+ }
187
212
  `;
188
213
 
189
214
  interface Props {
@@ -236,8 +261,12 @@ const ResourceItem = ({
236
261
  hidden={hidden && !active}
237
262
  data-active={active}
238
263
  data-additional={additional}
264
+ data-content-type={contentTypeName}
239
265
  style={listElementVars}
240
266
  >
267
+ <ContentBadgeWrapper data-badge-wrapper={!active}>
268
+ <ContentTypeBadge type={contentType ?? ""} background border={false} />
269
+ </ContentBadgeWrapper>
241
270
  <ResourceLink
242
271
  to={path}
243
272
  lang={language === "nb" ? "no" : language}
@@ -246,16 +275,13 @@ const ResourceItem = ({
246
275
  disabled={active}
247
276
  data-active={active}
248
277
  >
249
- <ContentBadgeWrapper data-badge-wrapper={!active}>
250
- <ContentTypeBadge type={contentType ?? ""} background border={false} />
251
- </ContentBadgeWrapper>
252
- <InlineContainer>
253
- {name}
278
+ <TitleContainer>
279
+ <div>{name}</div>
254
280
  {active ? <CurrentSmall>{t("resource.youAreHere")}</CurrentSmall> : undefined}
255
- </InlineContainer>
281
+ </TitleContainer>
256
282
  </ResourceLink>
283
+ {contentTypeName && <ContentTypeName>{contentTypeName}</ContentTypeName>}
257
284
  <TypeWrapper>
258
- {contentTypeName && <ContentTypeName>{contentTypeName}</ContentTypeName>}
259
285
  {access && access === "teacher" && (
260
286
  <IconWrapper aria-label={t("article.access.onlyTeacher")} title={t("article.access.onlyTeacher")}>
261
287
  <HumanMaleBoard id={accessId} />
@@ -44,38 +44,36 @@ const ResourceList = ({
44
44
  resources.filter((res) => !res.additional).length === 0;
45
45
 
46
46
  return (
47
- <div>
48
- <StyledResourceList>
49
- {resources.map(({ id, ...resource }) => (
50
- <ResourceItem
51
- id={id}
52
- key={id}
53
- contentType={contentType}
54
- showAdditionalResources={showAdditionalResources}
55
- heartButton={heartButton}
56
- {...resource}
57
- contentTypeDescription={
58
- resource.additional ? t("resource.tooltipAdditionalTopic") : t("resource.tooltipCoreTopic")
47
+ <StyledResourceList>
48
+ {resources.map(({ id, ...resource }) => (
49
+ <ResourceItem
50
+ id={id}
51
+ key={id}
52
+ contentType={contentType}
53
+ showAdditionalResources={showAdditionalResources}
54
+ heartButton={heartButton}
55
+ {...resource}
56
+ contentTypeDescription={
57
+ resource.additional ? t("resource.tooltipAdditionalTopic") : t("resource.tooltipCoreTopic")
58
+ }
59
+ />
60
+ ))}
61
+ {renderAdditionalResourceTrigger && (
62
+ <li>
63
+ <NoContentBox
64
+ onClick={onClick}
65
+ buttonText={t("resource.toggleFilterLabel")}
66
+ text={
67
+ title
68
+ ? t("resource.noCoreResourcesAvailable", {
69
+ name: title.toLowerCase(),
70
+ })
71
+ : t("resource.noCoreResourcesAvailableUnspecific")
59
72
  }
60
73
  />
61
- ))}
62
- {renderAdditionalResourceTrigger && (
63
- <li>
64
- <NoContentBox
65
- onClick={onClick}
66
- buttonText={t("resource.toggleFilterLabel")}
67
- text={
68
- title
69
- ? t("resource.noCoreResourcesAvailable", {
70
- name: title.toLowerCase(),
71
- })
72
- : t("resource.noCoreResourcesAvailableUnspecific")
73
- }
74
- />
75
- </li>
76
- )}
77
- </StyledResourceList>
78
- </div>
74
+ </li>
75
+ )}
76
+ </StyledResourceList>
79
77
  );
80
78
  };
81
79
 
@@ -44,7 +44,7 @@ export type ContentType =
44
44
  | typeof constants.contentTypes.SUBJECT_MATERIAL
45
45
  | typeof constants.contentTypes.TASKS_AND_ACTIVITIES
46
46
  | typeof constants.contentTypes.ASSESSMENT_RESOURCES
47
- | typeof constants.contentTypes.EXTERNAL_LEARNING_RESOURCES
47
+ | typeof constants.contentTypes.CONCEPT
48
48
  | typeof constants.contentTypes.SOURCE_MATERIAL
49
49
  | typeof constants.contentTypes.LEARNING_PATH
50
50
  | typeof constants.contentTypes.TOPIC
package/src/index.ts CHANGED
@@ -74,10 +74,10 @@ export {
74
74
  TasksAndActivitiesHero,
75
75
  AssessmentResourcesHero,
76
76
  SubjectHero,
77
- ExternalLearningResourcesHero,
78
77
  SourceMaterialHero,
79
78
  Hero,
80
79
  NdlaFilmHero,
80
+ ConceptHero,
81
81
  HeroContent,
82
82
  } from "./Hero";
83
83
 
@@ -175,8 +175,8 @@ export {
175
175
  AssessmentResourcesBadge,
176
176
  LearningPathBadge,
177
177
  SubjectBadge,
178
- ExternalLearningResourcesBadge,
179
178
  SourceMaterialBadge,
179
+ ConceptBadge,
180
180
  } from "./ContentTypeBadge";
181
181
 
182
182
  export { SubjectHeader, SubjectBanner } from "./Subject";
@@ -548,7 +548,6 @@ const messages = {
548
548
  "learning-path": "Learning path",
549
549
  "subject-material": "Subject material",
550
550
  "tasks-and-activities": "Task and activities",
551
- "external-learning-resources": "External learning resources",
552
551
  "source-material": "Source material",
553
552
  "assessment-resources": "Assessment resource",
554
553
  topic: "Topic",
@@ -548,7 +548,6 @@ const messages = {
548
548
  "learning-path": "Læringssti",
549
549
  "subject-material": "Fagstoff",
550
550
  "tasks-and-activities": "Oppgaver og aktiviteter",
551
- "external-learning-resources": "Ekstern læringsressurs",
552
551
  "source-material": "Kildemateriale",
553
552
  "assessment-resources": "Vurderingsressurs",
554
553
  topic: "Emne",
@@ -548,7 +548,6 @@ const messages = {
548
548
  "learning-path": "Læringssti",
549
549
  "subject-material": "Fagstoff",
550
550
  "tasks-and-activities": "Oppgåver og aktivitetar",
551
- "external-learning-resources": "Ekstern læringsressurs",
552
551
  "source-material": "Kjeldemateriale",
553
552
  "assessment-resources": "Vurderingsressurs",
554
553
  topic: "Emne",
@@ -550,7 +550,6 @@ const messages = {
550
550
  "learning-path": "Oahppanbálggis",
551
551
  "subject-material": "Fágaávdnasat",
552
552
  "tasks-and-activities": "Bihtát ja doaimmat",
553
- "external-learning-resources": "Olgguldas oahppanresursa",
554
553
  "source-material": "Gáldomateriála",
555
554
  "assessment-resources": "Árvoštallanresursa",
556
555
  topic: "Fáddá",
@@ -552,7 +552,6 @@ const messages = {
552
552
  "learning-path": "Lïeremebaalka",
553
553
  "subject-material": "Faage-aamhtese",
554
554
  "tasks-and-activities": "Laavenjassh jïh darjomh",
555
- "external-learning-resources": "Byjngetje lïeremevierhtie",
556
555
  "source-material": "Gaaltijevierhtieh",
557
556
  "assessment-resources": "Vuarjasjimmievierhtie",
558
557
  topic: "Teema",
@@ -10,41 +10,44 @@ export const SUBJECT_MATERIAL = "subject-material";
10
10
  export const TASKS_AND_ACTIVITIES = "tasks-and-activities";
11
11
  export const ASSESSMENT_RESOURCES = "assessment-resources";
12
12
  export const SUBJECT = "subject";
13
- export const EXTERNAL_LEARNING_RESOURCES = "external-learning-resources";
14
13
  export const SOURCE_MATERIAL = "source-material";
15
14
  export const LEARNING_PATH = "learning-path";
16
15
  export const TOPIC = "topic";
17
16
  export const MULTIDISCIPLINARY_TOPIC = "multidisciplinary-topic";
17
+ export const CONCEPT = "concept";
18
+ export const EXTERNAL = "external";
18
19
 
19
20
  export const contentTypes = {
20
21
  SUBJECT_MATERIAL,
21
22
  TASKS_AND_ACTIVITIES,
22
23
  ASSESSMENT_RESOURCES,
23
24
  SUBJECT,
24
- EXTERNAL_LEARNING_RESOURCES,
25
25
  SOURCE_MATERIAL,
26
26
  LEARNING_PATH,
27
27
  TOPIC,
28
28
  MULTIDISCIPLINARY_TOPIC,
29
+ CONCEPT,
30
+ EXTERNAL,
29
31
  };
30
32
 
31
33
  export const RESOURCE_TYPE_LEARNING_PATH = "urn:resourcetype:learningPath";
32
34
  export const RESOURCE_TYPE_SUBJECT_MATERIAL = "urn:resourcetype:subjectMaterial";
33
35
  export const RESOURCE_TYPE_TASKS_AND_ACTIVITIES = "urn:resourcetype:tasksAndActivities";
34
36
  export const RESOURCE_TYPE_ASSESSMENT_RESOURCES = "urn:resourcetype:reviewResource";
35
- export const RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES = "urn:resourcetype:externalResource";
36
37
  export const RESOURCE_TYPE_SOURCE_MATERIAL = "urn:resourcetype:SourceMaterial";
38
+ export const RESOURCE_TYPE_CONCEPT = "urn:resourcetype:concept";
37
39
 
38
40
  export const ListOfContentTypes = [
39
41
  "SUBJECT_MATERIAL",
40
42
  "TASKS_AND_ACTIVITIES",
41
43
  "ASSESSMENT_RESOURCES",
42
44
  "SUBJECT",
43
- "EXTERNAL_LEARNING_RESOURCES",
44
45
  "SOURCE_MATERIAL",
45
46
  "LEARNING_PATH",
46
47
  "TOPIC",
47
48
  "MULTIDISIPLINARY_TOPIC",
49
+ "CONCEPT",
50
+ "EXTERNAL",
48
51
  ];
49
52
 
50
53
  export const contentTypeMapping: Record<string, string> = {
@@ -52,8 +55,8 @@ export const contentTypeMapping: Record<string, string> = {
52
55
  [RESOURCE_TYPE_SUBJECT_MATERIAL]: SUBJECT_MATERIAL,
53
56
  [RESOURCE_TYPE_TASKS_AND_ACTIVITIES]: TASKS_AND_ACTIVITIES,
54
57
  [RESOURCE_TYPE_ASSESSMENT_RESOURCES]: ASSESSMENT_RESOURCES,
55
- [RESOURCE_TYPE_EXTERNAL_LEARNING_RESOURCES]: EXTERNAL_LEARNING_RESOURCES,
56
58
  [RESOURCE_TYPE_SOURCE_MATERIAL]: SOURCE_MATERIAL,
59
+ [RESOURCE_TYPE_CONCEPT]: CONCEPT,
57
60
  default: SUBJECT_MATERIAL,
58
61
  };
59
62
 
@@ -23,8 +23,8 @@ export const resourceTypeColor = (type: string) => {
23
23
  return colors.tasksAndActivities.light;
24
24
  case contentTypes.ASSESSMENT_RESOURCES:
25
25
  return colors.assessmentResource.light;
26
- case contentTypes.EXTERNAL_LEARNING_RESOURCES:
27
- return colors.externalLearningResource.light;
26
+ case contentTypes.CONCEPT:
27
+ return colors.concept.light;
28
28
  case contentTypes.SOURCE_MATERIAL:
29
29
  return colors.sourceMaterial.light;
30
30
  case contentTypes.LEARNING_PATH: