@ndla/ui 17.0.0 → 19.0.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/Article/ArticleFavoritesButton.js +4 -3
- package/es/Masthead/MastheadAuthModal.js +8 -3
- package/es/MyNdla/Resource/Folder.js +11 -10
- package/es/MyNdla/index.js +1 -2
- package/es/Resource/BlockResource.js +14 -8
- package/es/Resource/ListResource.js +15 -9
- package/es/Resource/resourceComponents.js +12 -11
- package/es/TagSelector/SuggestionInput.js +111 -56
- package/es/TagSelector/Suggestions.js +19 -15
- package/es/TagSelector/TagSelector.js +8 -7
- package/es/TreeStructure/FolderItem.js +5 -5
- package/es/TreeStructure/FolderItems.js +8 -7
- package/es/TreeStructure/TreeStructure.js +65 -80
- package/es/TreeStructure/keyboardNavigation/keyboardNavigation.js +23 -11
- package/es/index.js +1 -1
- package/es/locale/messages-en.js +10 -1
- package/es/locale/messages-nb.js +11 -2
- package/es/locale/messages-nn.js +12 -3
- package/es/locale/messages-se.js +11 -2
- package/es/locale/messages-sma.js +11 -2
- package/lib/Article/ArticleFavoritesButton.js +4 -3
- package/lib/Masthead/MastheadAuthModal.js +14 -7
- package/lib/MyNdla/Resource/Folder.d.ts +4 -3
- package/lib/MyNdla/Resource/Folder.js +11 -10
- package/lib/MyNdla/index.d.ts +1 -2
- package/lib/MyNdla/index.js +0 -8
- package/lib/Resource/BlockResource.d.ts +4 -3
- package/lib/Resource/BlockResource.js +14 -7
- package/lib/Resource/ListResource.d.ts +4 -3
- package/lib/Resource/ListResource.js +15 -8
- package/lib/Resource/resourceComponents.d.ts +4 -1
- package/lib/Resource/resourceComponents.js +14 -13
- package/lib/TagSelector/SuggestionInput.js +111 -57
- package/lib/TagSelector/Suggestions.js +26 -23
- package/lib/TagSelector/TagSelector.js +8 -7
- package/lib/TreeStructure/FolderItem.js +5 -5
- package/lib/TreeStructure/FolderItems.d.ts +1 -1
- package/lib/TreeStructure/FolderItems.js +8 -8
- package/lib/TreeStructure/TreeStructure.d.ts +6 -1
- package/lib/TreeStructure/TreeStructure.js +66 -80
- package/lib/TreeStructure/TreeStructure.types.d.ts +5 -3
- package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.js +23 -11
- package/lib/TreeStructure/keyboardNavigation/keyboardNavigation.types.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -7
- package/lib/locale/messages-en.d.ts +9 -0
- package/lib/locale/messages-en.js +10 -1
- package/lib/locale/messages-nb.d.ts +9 -0
- package/lib/locale/messages-nb.js +11 -2
- package/lib/locale/messages-nn.d.ts +9 -0
- package/lib/locale/messages-nn.js +12 -3
- package/lib/locale/messages-se.d.ts +9 -0
- package/lib/locale/messages-se.js +11 -2
- package/lib/locale/messages-sma.d.ts +9 -0
- package/lib/locale/messages-sma.js +11 -2
- package/package.json +5 -5
- package/src/Article/ArticleFavoritesButton.tsx +4 -3
- package/src/Masthead/MastheadAuthModal.tsx +9 -0
- package/src/MyNdla/Resource/Folder.tsx +7 -7
- package/src/MyNdla/index.ts +1 -2
- package/src/Resource/BlockResource.tsx +7 -6
- package/src/Resource/ListResource.tsx +8 -7
- package/src/Resource/resourceComponents.tsx +8 -1
- package/src/TagSelector/SuggestionInput.tsx +90 -24
- package/src/TagSelector/Suggestions.tsx +14 -0
- package/src/TagSelector/TagSelector.tsx +6 -4
- package/src/TreeStructure/FolderItem.tsx +5 -2
- package/src/TreeStructure/FolderItems.tsx +4 -3
- package/src/TreeStructure/TreeStructure.tsx +54 -42
- package/src/TreeStructure/TreeStructure.types.ts +5 -3
- package/src/TreeStructure/keyboardNavigation/keyboardNavigation.ts +7 -7
- package/src/TreeStructure/keyboardNavigation/keyboardNavigation.types.ts +1 -1
- package/src/index.ts +1 -1
- package/src/locale/messages-en.ts +11 -1
- package/src/locale/messages-nb.ts +11 -2
- package/src/locale/messages-nn.ts +12 -3
- package/src/locale/messages-se.ts +11 -2
- package/src/locale/messages-sma.ts +11 -2
- package/es/MyNdla/Navigation/VerticalNavigation.js +0 -51
- package/es/MyNdla/Navigation/index.js +0 -2
- package/lib/MyNdla/Navigation/VerticalNavigation.d.ts +0 -10
- package/lib/MyNdla/Navigation/VerticalNavigation.js +0 -61
- package/lib/MyNdla/Navigation/index.d.ts +0 -2
- package/lib/MyNdla/Navigation/index.js +0 -15
- package/src/MyNdla/Navigation/VerticalNavigation.tsx +0 -93
- package/src/MyNdla/Navigation/index.ts +0 -2
|
@@ -53,6 +53,7 @@ declare const messages: {
|
|
|
53
53
|
close: string;
|
|
54
54
|
};
|
|
55
55
|
myNdla: {
|
|
56
|
+
myNDLA: string;
|
|
56
57
|
resources: string;
|
|
57
58
|
resources_plural: string;
|
|
58
59
|
folders: string;
|
|
@@ -64,6 +65,8 @@ declare const messages: {
|
|
|
64
65
|
newFolderUnder: string;
|
|
65
66
|
myAccount: string;
|
|
66
67
|
favourites: string;
|
|
68
|
+
addToFavourites: string;
|
|
69
|
+
alreadyFavourited: string;
|
|
67
70
|
help: string;
|
|
68
71
|
more: string;
|
|
69
72
|
listView: string;
|
|
@@ -124,13 +127,19 @@ declare const messages: {
|
|
|
124
127
|
help: string;
|
|
125
128
|
};
|
|
126
129
|
treeStructure: {
|
|
130
|
+
folderChildOptions: {
|
|
131
|
+
edit: string;
|
|
132
|
+
delete: string;
|
|
133
|
+
};
|
|
127
134
|
createFolder: string;
|
|
135
|
+
maxFoldersAlreadyAdded: string;
|
|
128
136
|
newFolder: {
|
|
129
137
|
placeholder: string;
|
|
130
138
|
defaultName: string;
|
|
131
139
|
};
|
|
132
140
|
};
|
|
133
141
|
tagSelector: {
|
|
142
|
+
label: string;
|
|
134
143
|
placeholder: string;
|
|
135
144
|
removeTag: string;
|
|
136
145
|
hideAllTags: string;
|
|
@@ -29,15 +29,21 @@ var titleTemplate = ' - NDLA';
|
|
|
29
29
|
|
|
30
30
|
var messages = _objectSpread(_objectSpread({
|
|
31
31
|
treeStructure: {
|
|
32
|
+
folderChildOptions: {
|
|
33
|
+
edit: 'Endre mappenamn',
|
|
34
|
+
"delete": 'Slett'
|
|
35
|
+
},
|
|
32
36
|
createFolder: 'Lag mappe',
|
|
37
|
+
maxFoldersAlreadyAdded: 'Maks nivå av undermapper nådd',
|
|
33
38
|
newFolder: {
|
|
34
|
-
placeholder: 'Skriv
|
|
39
|
+
placeholder: 'Skriv namn på mappe',
|
|
35
40
|
defaultName: 'Ny mappe'
|
|
36
41
|
}
|
|
37
42
|
},
|
|
38
43
|
tagSelector: {
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
label: 'Legg til tag',
|
|
45
|
+
placeholder: 'Skriv tag namn',
|
|
46
|
+
removeTag: 'Ta vekk {{name}}',
|
|
41
47
|
hideAllTags: 'Skjul alle tagger',
|
|
42
48
|
showAllTags: 'Vis alle tagger'
|
|
43
49
|
},
|
|
@@ -940,6 +946,7 @@ var messages = _objectSpread(_objectSpread({
|
|
|
940
946
|
close: 'Lukk faktaboks'
|
|
941
947
|
},
|
|
942
948
|
myNdla: {
|
|
949
|
+
myNDLA: 'Min NDLA',
|
|
943
950
|
resources: '{{count}} ressurs',
|
|
944
951
|
resources_plural: '{{count}} ressursar',
|
|
945
952
|
folders: '{{count}} mappe',
|
|
@@ -951,6 +958,8 @@ var messages = _objectSpread(_objectSpread({
|
|
|
951
958
|
newFolderUnder: 'Lag ny mappe under {{folderName}}',
|
|
952
959
|
myAccount: 'Min konto',
|
|
953
960
|
favourites: 'Favorittar',
|
|
961
|
+
addToFavourites: 'Legg til i mine favorittar',
|
|
962
|
+
alreadyFavourited: 'Allereie lagt til i mine favorittar',
|
|
954
963
|
help: 'Hjelp',
|
|
955
964
|
more: 'Fleire val',
|
|
956
965
|
listView: 'Listevisning',
|
|
@@ -53,6 +53,7 @@ declare const messages: {
|
|
|
53
53
|
close: string;
|
|
54
54
|
};
|
|
55
55
|
myNdla: {
|
|
56
|
+
myNDLA: string;
|
|
56
57
|
resources: string;
|
|
57
58
|
resources_plural: string;
|
|
58
59
|
folders: string;
|
|
@@ -64,6 +65,8 @@ declare const messages: {
|
|
|
64
65
|
newFolderUnder: string;
|
|
65
66
|
myAccount: string;
|
|
66
67
|
favourites: string;
|
|
68
|
+
addToFavourites: string;
|
|
69
|
+
alreadyFavourited: string;
|
|
67
70
|
help: string;
|
|
68
71
|
more: string;
|
|
69
72
|
listView: string;
|
|
@@ -124,13 +127,19 @@ declare const messages: {
|
|
|
124
127
|
help: string;
|
|
125
128
|
};
|
|
126
129
|
treeStructure: {
|
|
130
|
+
folderChildOptions: {
|
|
131
|
+
edit: string;
|
|
132
|
+
delete: string;
|
|
133
|
+
};
|
|
127
134
|
createFolder: string;
|
|
135
|
+
maxFoldersAlreadyAdded: string;
|
|
128
136
|
newFolder: {
|
|
129
137
|
placeholder: string;
|
|
130
138
|
defaultName: string;
|
|
131
139
|
};
|
|
132
140
|
};
|
|
133
141
|
tagSelector: {
|
|
142
|
+
label: string;
|
|
134
143
|
placeholder: string;
|
|
135
144
|
removeTag: string;
|
|
136
145
|
hideAllTags: string;
|
|
@@ -29,15 +29,21 @@ var titleTemplate = ' - NDLA';
|
|
|
29
29
|
|
|
30
30
|
var messages = _objectSpread(_objectSpread({
|
|
31
31
|
treeStructure: {
|
|
32
|
+
folderChildOptions: {
|
|
33
|
+
edit: 'Endre mappenavn',
|
|
34
|
+
"delete": 'Slett'
|
|
35
|
+
},
|
|
32
36
|
createFolder: 'Lag mappe',
|
|
37
|
+
maxFoldersAlreadyAdded: 'Maks nivå av undermapper nådd',
|
|
33
38
|
newFolder: {
|
|
34
39
|
placeholder: 'Skriv navn på mappe',
|
|
35
40
|
defaultName: 'Ny mappe'
|
|
36
41
|
}
|
|
37
42
|
},
|
|
38
43
|
tagSelector: {
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
label: 'Legg til tag',
|
|
45
|
+
placeholder: 'Skriv tag navn',
|
|
46
|
+
removeTag: 'Ta vekk {{name}}',
|
|
41
47
|
hideAllTags: 'Skjul alla tags',
|
|
42
48
|
showAllTags: 'Vis alla tags'
|
|
43
49
|
},
|
|
@@ -940,6 +946,7 @@ var messages = _objectSpread(_objectSpread({
|
|
|
940
946
|
close: 'Lukk faktaboks'
|
|
941
947
|
},
|
|
942
948
|
myNdla: {
|
|
949
|
+
myNDLA: 'Min NDLA',
|
|
943
950
|
resources: '{{count}} ressurs',
|
|
944
951
|
resources_plural: '{{count}} ressurser',
|
|
945
952
|
folders: '{{count}} mappe',
|
|
@@ -951,6 +958,8 @@ var messages = _objectSpread(_objectSpread({
|
|
|
951
958
|
newFolderUnder: 'Lag ny mappe under {{folderName}}',
|
|
952
959
|
myAccount: 'Min konto',
|
|
953
960
|
favourites: 'Favoritter',
|
|
961
|
+
addToFavourites: 'Legg til i mine favoritter',
|
|
962
|
+
alreadyFavourited: 'Allerede lagt til i mine favoritter',
|
|
954
963
|
help: 'Hjelp',
|
|
955
964
|
more: 'Flere valg',
|
|
956
965
|
listView: 'Listevisning',
|
|
@@ -53,6 +53,7 @@ declare const messages: {
|
|
|
53
53
|
close: string;
|
|
54
54
|
};
|
|
55
55
|
myNdla: {
|
|
56
|
+
myNDLA: string;
|
|
56
57
|
resources: string;
|
|
57
58
|
resources_plural: string;
|
|
58
59
|
folders: string;
|
|
@@ -64,6 +65,8 @@ declare const messages: {
|
|
|
64
65
|
newFolderUnder: string;
|
|
65
66
|
myAccount: string;
|
|
66
67
|
favourites: string;
|
|
68
|
+
addToFavourites: string;
|
|
69
|
+
alreadyFavourited: string;
|
|
67
70
|
help: string;
|
|
68
71
|
more: string;
|
|
69
72
|
listView: string;
|
|
@@ -124,13 +127,19 @@ declare const messages: {
|
|
|
124
127
|
help: string;
|
|
125
128
|
};
|
|
126
129
|
treeStructure: {
|
|
130
|
+
folderChildOptions: {
|
|
131
|
+
edit: string;
|
|
132
|
+
delete: string;
|
|
133
|
+
};
|
|
127
134
|
createFolder: string;
|
|
135
|
+
maxFoldersAlreadyAdded: string;
|
|
128
136
|
newFolder: {
|
|
129
137
|
placeholder: string;
|
|
130
138
|
defaultName: string;
|
|
131
139
|
};
|
|
132
140
|
};
|
|
133
141
|
tagSelector: {
|
|
142
|
+
label: string;
|
|
134
143
|
placeholder: string;
|
|
135
144
|
removeTag: string;
|
|
136
145
|
hideAllTags: string;
|
|
@@ -29,15 +29,21 @@ var titleTemplate = ' - NDLA';
|
|
|
29
29
|
|
|
30
30
|
var messages = _objectSpread(_objectSpread({
|
|
31
31
|
treeStructure: {
|
|
32
|
+
folderChildOptions: {
|
|
33
|
+
edit: 'Endre mappenavn',
|
|
34
|
+
"delete": 'Slett'
|
|
35
|
+
},
|
|
32
36
|
createFolder: 'Lag mappe',
|
|
37
|
+
maxFoldersAlreadyAdded: 'Maks nivå av undermapper nådd',
|
|
33
38
|
newFolder: {
|
|
34
39
|
placeholder: 'Skriv navn på mappe',
|
|
35
40
|
defaultName: 'Ny mappe'
|
|
36
41
|
}
|
|
37
42
|
},
|
|
38
43
|
tagSelector: {
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
label: 'Legg til tag',
|
|
45
|
+
placeholder: 'Skriv tag navn',
|
|
46
|
+
removeTag: 'Ta vekk {{name}}',
|
|
41
47
|
hideAllTags: 'Skjul alle tagger',
|
|
42
48
|
showAllTags: 'Vis alle tagger'
|
|
43
49
|
},
|
|
@@ -940,6 +946,7 @@ var messages = _objectSpread(_objectSpread({
|
|
|
940
946
|
close: 'Lukk faktaboks'
|
|
941
947
|
},
|
|
942
948
|
myNdla: {
|
|
949
|
+
myNDLA: 'Min NDLA',
|
|
943
950
|
resources: '{{count}} ressurs',
|
|
944
951
|
resources_plural: '{{count}} ressurser',
|
|
945
952
|
folders: '{{count}} mappe',
|
|
@@ -951,6 +958,8 @@ var messages = _objectSpread(_objectSpread({
|
|
|
951
958
|
newFolderUnder: 'Lag ny mappe under {{folderName}}',
|
|
952
959
|
myAccount: 'Min konto',
|
|
953
960
|
favourites: 'Favoritter',
|
|
961
|
+
addToFavourites: 'Legg til i mine favoritter',
|
|
962
|
+
alreadyFavourited: 'Allerede lagt til i mine favoritter',
|
|
954
963
|
help: 'Hjelp',
|
|
955
964
|
more: 'Flere valg',
|
|
956
965
|
listView: 'Listevisning',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/button": "^
|
|
34
|
+
"@ndla/button": "^3.0.0",
|
|
35
35
|
"@ndla/carousel": "^1.2.11",
|
|
36
36
|
"@ndla/core": "^2.3.0",
|
|
37
37
|
"@ndla/hooks": "^1.1.4",
|
|
38
38
|
"@ndla/icons": "^1.10.0",
|
|
39
39
|
"@ndla/licenses": "^5.0.2",
|
|
40
40
|
"@ndla/modal": "^1.2.12",
|
|
41
|
-
"@ndla/notion": "^3.1.
|
|
42
|
-
"@ndla/safelink": "^2.0.
|
|
41
|
+
"@ndla/notion": "^3.1.18",
|
|
42
|
+
"@ndla/safelink": "^2.0.9",
|
|
43
43
|
"@ndla/switch": "^0.1.7",
|
|
44
44
|
"@ndla/tabs": "^1.1.10",
|
|
45
45
|
"@ndla/tooltip": "^2.1.2",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "ae09299c27fc3f48f1b8f77ebe37c7aac511b2ad"
|
|
85
85
|
}
|
|
@@ -23,14 +23,15 @@ export const ArticleFavoritesButton = ({ isFavorite, onToggleAddToFavorites, art
|
|
|
23
23
|
const removeFromFavoritesLabel = t('myNdla.resource.addToMyNdla');
|
|
24
24
|
const addToFavoritesLabel = t('myNdla.resource.addedToMyNdla');
|
|
25
25
|
return (
|
|
26
|
-
<Tooltip tooltip={isFavorite ?
|
|
26
|
+
<Tooltip tooltip={isFavorite ? addToFavoritesLabel : removeFromFavoritesLabel}>
|
|
27
27
|
<IconButtonDualStates
|
|
28
|
-
ariaLabelActive={
|
|
29
|
-
ariaLabelInActive={
|
|
28
|
+
ariaLabelActive={t('myNdla.addToFavourites')}
|
|
29
|
+
ariaLabelInActive={t('myNdla.alreadyFavourited')}
|
|
30
30
|
activeIcon={<Heart />}
|
|
31
31
|
inactiveIcon={<HeartOutline />}
|
|
32
32
|
active={isFavorite}
|
|
33
33
|
size="small"
|
|
34
|
+
ghostPill
|
|
34
35
|
onClick={() => onToggleAddToFavorites(articleId, !isFavorite)}
|
|
35
36
|
/>
|
|
36
37
|
</Tooltip>
|
|
@@ -10,6 +10,8 @@ import React from 'react';
|
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
import Button from '@ndla/button';
|
|
12
12
|
import { Feide } from '@ndla/icons/common';
|
|
13
|
+
import { colors, fonts, spacing } from '@ndla/core';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
13
15
|
|
|
14
16
|
import AuthModal, { AuthModalProps } from '../User/AuthModal';
|
|
15
17
|
|
|
@@ -18,7 +20,12 @@ type FeideWrapperProps = {
|
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
const StyledButton = styled(Button)<FeideWrapperProps>`
|
|
23
|
+
font-weight: ${fonts.weight.semibold};
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
21
26
|
.feide-icon svg {
|
|
27
|
+
margin-left: ${spacing.xsmall};
|
|
28
|
+
fill: ${colors.brand.primary};
|
|
22
29
|
color: ${(props) => (props.inverted ? `#ffffff` : `#000000`)};
|
|
23
30
|
width: 22px;
|
|
24
31
|
height: 22px;
|
|
@@ -35,11 +42,13 @@ interface Props extends AuthModalProps {
|
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
const MastheadAuthModal = ({ inverted, ...rest }: Props) => {
|
|
45
|
+
const { t } = useTranslation();
|
|
38
46
|
return (
|
|
39
47
|
<AuthModal
|
|
40
48
|
{...rest}
|
|
41
49
|
activateButton={
|
|
42
50
|
<StyledButton inverted={inverted} ghostPill={!inverted} ghostPillInverted={inverted} aria-label="Feide">
|
|
51
|
+
{t('myNdla.myNDLA')}
|
|
43
52
|
<span className="feide-icon">
|
|
44
53
|
<Feide />
|
|
45
54
|
</span>
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
|
-
import React
|
|
10
|
+
import React from 'react';
|
|
11
11
|
import { FolderOutlined } from '@ndla/icons/contentType';
|
|
12
12
|
import { FileDocumentOutline } from '@ndla/icons/common';
|
|
13
13
|
import { fonts, spacing, colors, mq, breakpoints } from '@ndla/core';
|
|
14
14
|
import { css } from '@emotion/core';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import SafeLink from '@ndla/safelink';
|
|
17
|
-
import { MenuButton } from '@ndla/button';
|
|
17
|
+
import { MenuButton, MenuItemProps } from '@ndla/button';
|
|
18
18
|
|
|
19
19
|
interface FolderIconWrapperProps {
|
|
20
20
|
type?: LayoutType;
|
|
@@ -59,7 +59,7 @@ const FolderWrapper = styled(SafeLink)`
|
|
|
59
59
|
display: flex;
|
|
60
60
|
align-items: center;
|
|
61
61
|
padding: ${spacing.small};
|
|
62
|
-
border: 1px solid ${colors.brand.
|
|
62
|
+
border: 1px solid ${colors.brand.neutral7};
|
|
63
63
|
border-radius: 2px;
|
|
64
64
|
box-shadow: none;
|
|
65
65
|
text-decoration: none;
|
|
@@ -84,7 +84,7 @@ interface Props {
|
|
|
84
84
|
description?: string;
|
|
85
85
|
link: string;
|
|
86
86
|
type: LayoutType;
|
|
87
|
-
|
|
87
|
+
menuItems?: MenuItemProps[];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
interface IconCountProps {
|
|
@@ -124,14 +124,14 @@ const IconCount = ({ type, count, layoutType }: IconCountProps) => {
|
|
|
124
124
|
return (
|
|
125
125
|
<IconCountWrapper type={layoutType}>
|
|
126
126
|
<Icon aria-label={t(`myNdla.${type}s`)} />
|
|
127
|
-
<span>{layoutType === 'block' ? count : t(`myNdla.${type}s`, { count
|
|
127
|
+
<span>{layoutType === 'block' ? count : t(`myNdla.${type}s`, { count })}</span>
|
|
128
128
|
</IconCountWrapper>
|
|
129
129
|
);
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
type LayoutType = 'list' | 'block';
|
|
133
133
|
|
|
134
|
-
const Folder = ({ link, title, subFolders, subResources, type = 'list',
|
|
134
|
+
const Folder = ({ link, title, subFolders, subResources, type = 'list', menuItems }: Props) => {
|
|
135
135
|
const { t } = useTranslation();
|
|
136
136
|
return (
|
|
137
137
|
<FolderWrapper to={link}>
|
|
@@ -141,7 +141,7 @@ const Folder = ({ link, title, subFolders, subResources, type = 'list', actionMe
|
|
|
141
141
|
<FolderTitle>{title}</FolderTitle>
|
|
142
142
|
<IconCount layoutType={type} type={'folder'} count={subFolders} />
|
|
143
143
|
<IconCount layoutType={type} type={'resource'} count={subResources} />
|
|
144
|
-
<MenuButton size="small" />
|
|
144
|
+
{menuItems && menuItems.length > 0 && <MenuButton size="small" menuItems={menuItems} />}
|
|
145
145
|
</FolderWrapper>
|
|
146
146
|
);
|
|
147
147
|
};
|
package/src/MyNdla/index.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
|
-
import React
|
|
10
|
+
import React from 'react';
|
|
11
11
|
import SafeLink from '@ndla/safelink';
|
|
12
12
|
import { colors, fonts, spacing } from '@ndla/core';
|
|
13
|
+
import { MenuButton, MenuItemProps } from '@ndla/button';
|
|
13
14
|
import Image from '../Image';
|
|
14
|
-
import {
|
|
15
|
+
import { CompressedTagList, ResourceImageProps, ResourceTitle, Row, TopicList } from './resourceComponents';
|
|
15
16
|
|
|
16
17
|
interface BlockResourceProps {
|
|
17
18
|
link: string;
|
|
@@ -20,7 +21,7 @@ interface BlockResourceProps {
|
|
|
20
21
|
topics: string[];
|
|
21
22
|
tags?: string[];
|
|
22
23
|
description?: string;
|
|
23
|
-
|
|
24
|
+
menuItems?: MenuItemProps[];
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const BlockElementWrapper = styled(SafeLink)`
|
|
@@ -77,7 +78,7 @@ const ImageWrapper = styled.div`
|
|
|
77
78
|
}
|
|
78
79
|
`;
|
|
79
80
|
|
|
80
|
-
const BlockResource = ({ link, title, tags, resourceImage, topics, description,
|
|
81
|
+
const BlockResource = ({ link, title, tags, resourceImage, topics, description, menuItems }: BlockResourceProps) => {
|
|
81
82
|
return (
|
|
82
83
|
<BlockElementWrapper to={link}>
|
|
83
84
|
<ImageWrapper>
|
|
@@ -90,8 +91,8 @@ const BlockResource = ({ link, title, tags, resourceImage, topics, description,
|
|
|
90
91
|
<TopicList topics={topics} />
|
|
91
92
|
<BlockDescription>{description}</BlockDescription>
|
|
92
93
|
<RightRow>
|
|
93
|
-
{tags &&
|
|
94
|
-
{
|
|
94
|
+
{tags && <CompressedTagList tags={tags} />}
|
|
95
|
+
{menuItems && menuItems.length > 0 && <MenuButton size="small" menuItems={menuItems} />}
|
|
95
96
|
</RightRow>
|
|
96
97
|
</BlockInfoWrapper>
|
|
97
98
|
</BlockElementWrapper>
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
|
-
import React
|
|
10
|
+
import React from 'react';
|
|
11
11
|
import SafeLink from '@ndla/safelink';
|
|
12
12
|
import { fonts, spacing, colors, breakpoints, mq } from '@ndla/core';
|
|
13
|
+
import { MenuButton, MenuItemProps } from '@ndla/button';
|
|
13
14
|
import Image from '../Image';
|
|
14
|
-
import {
|
|
15
|
+
import { CompressedTagList, ResourceImageProps, ResourceTitle, TopicList } from './resourceComponents';
|
|
15
16
|
|
|
16
17
|
const ResourceDescription = styled.p`
|
|
17
18
|
grid-area: description;
|
|
@@ -47,7 +48,7 @@ const ResourceWrapper = styled(SafeLink)`
|
|
|
47
48
|
text-decoration: none;
|
|
48
49
|
box-shadow: none;
|
|
49
50
|
padding: ${spacing.small};
|
|
50
|
-
border: 1px solid ${colors.brand.
|
|
51
|
+
border: 1px solid ${colors.brand.neutral7};
|
|
51
52
|
border-radius: 2px;
|
|
52
53
|
color: ${colors.brand.greyDark};
|
|
53
54
|
gap: 0 ${spacing.small};
|
|
@@ -109,10 +110,10 @@ export interface ListResourceProps {
|
|
|
109
110
|
topics: string[];
|
|
110
111
|
tags?: string[];
|
|
111
112
|
description?: string;
|
|
112
|
-
|
|
113
|
+
menuItems?: MenuItemProps[];
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
const ListResource = ({ link, title, tags, resourceImage, topics, description,
|
|
116
|
+
const ListResource = ({ link, title, tags, resourceImage, topics, description, menuItems }: ListResourceProps) => {
|
|
116
117
|
const showDescription = description !== undefined;
|
|
117
118
|
|
|
118
119
|
return (
|
|
@@ -126,8 +127,8 @@ const ListResource = ({ link, title, tags, resourceImage, topics, description, a
|
|
|
126
127
|
</TopicAndTitle>
|
|
127
128
|
{showDescription && <ResourceDescription>{description}</ResourceDescription>}
|
|
128
129
|
<TagsandActionMenu>
|
|
129
|
-
{tags &&
|
|
130
|
-
{
|
|
130
|
+
{tags && <CompressedTagList tags={tags} />}
|
|
131
|
+
{menuItems && menuItems.length > 0 && <MenuButton size="small" menuItems={menuItems} />}
|
|
131
132
|
</TagsandActionMenu>
|
|
132
133
|
</ResourceWrapper>
|
|
133
134
|
);
|
|
@@ -48,6 +48,9 @@ const StyledTagListElement = styled.li`
|
|
|
48
48
|
::before {
|
|
49
49
|
content: '#';
|
|
50
50
|
}
|
|
51
|
+
&:hover {
|
|
52
|
+
color: ${colors.brand.primary};
|
|
53
|
+
}
|
|
51
54
|
`;
|
|
52
55
|
|
|
53
56
|
const StyledTopicList = styled.ul`
|
|
@@ -100,7 +103,11 @@ export const TagList = ({ tags }: TagListProps) => {
|
|
|
100
103
|
);
|
|
101
104
|
};
|
|
102
105
|
|
|
103
|
-
|
|
106
|
+
interface CompressedTagListProps {
|
|
107
|
+
tags: string[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const CompressedTagList = ({ tags }: CompressedTagListProps) => {
|
|
104
111
|
const visibleTags = tags.slice(0, 3);
|
|
105
112
|
const remainingTags = tags.slice(3, tags.length).map((tag) => {
|
|
106
113
|
return {
|