@ndla/ui 22.0.3 → 22.1.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/es/CompetenceGoalTab/CompetenceGoalItem.js +12 -10
- package/es/CompetenceGoalTab/CompetenceGoalTab.js +11 -9
- package/es/CompetenceGoalTab/CompetenceItem.js +14 -12
- package/es/CompetenceGoalTab/SearchButton.js +7 -4
- package/es/Resource/BlockResource.js +9 -5
- package/es/Resource/ListResource.js +8 -6
- package/es/Resource/resourceComponents.js +36 -25
- package/es/locale/messages-en.js +3 -1
- package/es/locale/messages-nb.js +3 -1
- package/es/locale/messages-nn.js +3 -1
- package/es/locale/messages-se.js +3 -1
- package/es/locale/messages-sma.js +3 -1
- package/lib/CompetenceGoalTab/CompetenceGoalItem.d.ts +1 -1
- package/lib/CompetenceGoalTab/CompetenceGoalItem.js +12 -10
- package/lib/CompetenceGoalTab/CompetenceGoalTab.d.ts +2 -1
- package/lib/CompetenceGoalTab/CompetenceGoalTab.js +11 -9
- package/lib/CompetenceGoalTab/CompetenceItem.d.ts +2 -1
- package/lib/CompetenceGoalTab/CompetenceItem.js +14 -12
- package/lib/CompetenceGoalTab/SearchButton.d.ts +2 -1
- package/lib/CompetenceGoalTab/SearchButton.js +7 -4
- package/lib/Resource/BlockResource.d.ts +2 -1
- package/lib/Resource/BlockResource.js +9 -5
- package/lib/Resource/ListResource.d.ts +2 -1
- package/lib/Resource/ListResource.js +8 -6
- package/lib/Resource/resourceComponents.d.ts +4 -2
- package/lib/Resource/resourceComponents.js +38 -19
- package/lib/locale/messages-en.d.ts +2 -0
- package/lib/locale/messages-en.js +3 -1
- package/lib/locale/messages-nb.d.ts +2 -0
- package/lib/locale/messages-nb.js +3 -1
- package/lib/locale/messages-nn.d.ts +2 -0
- package/lib/locale/messages-nn.js +3 -1
- package/lib/locale/messages-se.d.ts +2 -0
- package/lib/locale/messages-se.js +3 -1
- package/lib/locale/messages-sma.d.ts +2 -0
- package/lib/locale/messages-sma.js +3 -1
- package/lib/types.d.ts +1 -0
- package/package.json +4 -3
- package/src/CompetenceGoalTab/CompetenceGoalItem.tsx +6 -2
- package/src/CompetenceGoalTab/CompetenceGoalTab.tsx +5 -4
- package/src/CompetenceGoalTab/CompetenceItem.tsx +9 -2
- package/src/CompetenceGoalTab/SearchButton.tsx +3 -2
- package/src/Resource/BlockResource.tsx +4 -2
- package/src/Resource/ListResource.tsx +3 -1
- package/src/Resource/resourceComponents.tsx +25 -9
- package/src/locale/messages-en.ts +2 -0
- package/src/locale/messages-nb.ts +2 -0
- package/src/locale/messages-nn.ts +2 -0
- package/src/locale/messages-se.ts +2 -0
- package/src/locale/messages-sma.ts +2 -0
- package/src/types.ts +1 -0
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
9
|
import styled from '@emotion/styled';
|
|
11
|
-
import {
|
|
10
|
+
import { colors, fonts, spacing } from '@ndla/core';
|
|
11
|
+
import React, { MouseEvent } from 'react';
|
|
12
12
|
|
|
13
13
|
import { MenuButton } from '@ndla/button';
|
|
14
|
+
import SafeLink from '@ndla/safelink';
|
|
15
|
+
import { useNavigate } from 'react-router-dom';
|
|
14
16
|
|
|
15
17
|
export interface ResourceImageProps {
|
|
16
18
|
alt: string;
|
|
@@ -42,9 +44,13 @@ const StyledTagList = styled.ul`
|
|
|
42
44
|
`;
|
|
43
45
|
|
|
44
46
|
const StyledTagListElement = styled.li`
|
|
45
|
-
color: ${colors.brand.grey};
|
|
46
47
|
margin: 0;
|
|
47
48
|
${fonts.sizes(14)};
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const StyledSafeLink = styled(SafeLink)`
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
color: ${colors.brand.grey};
|
|
48
54
|
::before {
|
|
49
55
|
content: '#';
|
|
50
56
|
}
|
|
@@ -90,14 +96,20 @@ const TagCounterWrapper = styled.p`
|
|
|
90
96
|
|
|
91
97
|
interface TagListProps {
|
|
92
98
|
tags?: string[];
|
|
99
|
+
tagLinkPrefix?: string;
|
|
93
100
|
}
|
|
94
|
-
|
|
95
|
-
export const TagList = ({ tags }: TagListProps) => {
|
|
101
|
+
export const TagList = ({ tags, tagLinkPrefix }: TagListProps) => {
|
|
96
102
|
if (!tags) return null;
|
|
97
103
|
return (
|
|
98
104
|
<StyledTagList>
|
|
99
105
|
{tags.map((tag, i) => (
|
|
100
|
-
<StyledTagListElement key={`tag-${i}`}>
|
|
106
|
+
<StyledTagListElement key={`tag-${i}`}>
|
|
107
|
+
<StyledSafeLink
|
|
108
|
+
onClick={(e: MouseEvent<HTMLAnchorElement | HTMLElement>) => e.stopPropagation()}
|
|
109
|
+
to={`${tagLinkPrefix ? tagLinkPrefix : ''}/${tag}`}>
|
|
110
|
+
{tag}
|
|
111
|
+
</StyledSafeLink>
|
|
112
|
+
</StyledTagListElement>
|
|
101
113
|
))}
|
|
102
114
|
</StyledTagList>
|
|
103
115
|
);
|
|
@@ -105,20 +117,24 @@ export const TagList = ({ tags }: TagListProps) => {
|
|
|
105
117
|
|
|
106
118
|
interface CompressedTagListProps {
|
|
107
119
|
tags: string[];
|
|
120
|
+
tagLinkPrefix?: string;
|
|
108
121
|
}
|
|
109
122
|
|
|
110
|
-
export const CompressedTagList = ({ tags }: CompressedTagListProps) => {
|
|
123
|
+
export const CompressedTagList = ({ tags, tagLinkPrefix }: CompressedTagListProps) => {
|
|
124
|
+
const navigate = useNavigate();
|
|
111
125
|
const visibleTags = tags.slice(0, 3);
|
|
112
126
|
const remainingTags = tags.slice(3, tags.length).map((tag) => {
|
|
113
127
|
return {
|
|
114
128
|
text: '#' + tag,
|
|
115
|
-
onClick: () => {
|
|
129
|
+
onClick: () => {
|
|
130
|
+
navigate(`${tagLinkPrefix ? tagLinkPrefix : ''}/${tag}`);
|
|
131
|
+
},
|
|
116
132
|
};
|
|
117
133
|
});
|
|
118
134
|
|
|
119
135
|
return (
|
|
120
136
|
<>
|
|
121
|
-
<TagList tags={visibleTags} />
|
|
137
|
+
<TagList tagLinkPrefix={tagLinkPrefix} tags={visibleTags} />
|
|
122
138
|
{remainingTags.length > 0 && (
|
|
123
139
|
<MenuButton hideMenuIcon={true} menuItems={remainingTags}>
|
|
124
140
|
<TagCounterWrapper>{`+${remainingTags.length}`}</TagCounterWrapper>
|