@ndla/ui 30.0.9 → 30.2.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/MyNdla/Resource/Folder.js +118 -57
- package/es/Resource/BlockResource.js +45 -30
- package/es/Resource/ListResource.js +46 -41
- package/es/Resource/resourceComponents.js +29 -34
- package/es/TreeStructure/ComboboxButton.js +5 -3
- package/es/TreeStructure/TreeStructure.js +11 -9
- package/lib/MyNdla/Resource/Folder.d.ts +1 -1
- package/lib/MyNdla/Resource/Folder.js +115 -57
- package/lib/Resource/BlockResource.d.ts +2 -2
- package/lib/Resource/BlockResource.js +44 -30
- package/lib/Resource/ListResource.js +40 -36
- package/lib/Resource/resourceComponents.js +28 -31
- package/lib/TreeStructure/ComboboxButton.d.ts +1 -0
- package/lib/TreeStructure/ComboboxButton.js +5 -3
- package/lib/TreeStructure/TreeStructure.d.ts +2 -1
- package/lib/TreeStructure/TreeStructure.js +11 -9
- package/package.json +6 -6
- package/src/MyNdla/Resource/Folder.tsx +118 -84
- package/src/Resource/BlockResource.tsx +34 -28
- package/src/Resource/ListResource.tsx +76 -74
- package/src/Resource/resourceComponents.tsx +15 -20
- package/src/TreeStructure/ComboboxButton.tsx +3 -0
- package/src/TreeStructure/TreeStructure.tsx +3 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
|
-
import { colors, fonts,
|
|
10
|
+
import { colors, fonts, spacing } from '@ndla/core';
|
|
11
11
|
import React, { MouseEvent, ReactNode } from 'react';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import { MenuButton } from '@ndla/button';
|
|
@@ -38,7 +38,7 @@ export const ResourceTitle = styled.h2`
|
|
|
38
38
|
line-clamp: 1;
|
|
39
39
|
-webkit-box-orient: vertical;
|
|
40
40
|
grid-area: resourceTitle;
|
|
41
|
-
${fonts.sizes('
|
|
41
|
+
${fonts.sizes('16px', '20px')};
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
44
|
const StyledTagList = styled.ul`
|
|
@@ -48,6 +48,10 @@ const StyledTagList = styled.ul`
|
|
|
48
48
|
padding: 2px;
|
|
49
49
|
gap: ${spacing.xsmall};
|
|
50
50
|
overflow: hidden;
|
|
51
|
+
padding-right: 14px;
|
|
52
|
+
:only-child {
|
|
53
|
+
margin-right: ${spacing.small};
|
|
54
|
+
}
|
|
51
55
|
`;
|
|
52
56
|
|
|
53
57
|
const StyledTagListElement = styled.li`
|
|
@@ -60,6 +64,8 @@ const StyledSafeLink = styled(SafeLink)`
|
|
|
60
64
|
align-items: center;
|
|
61
65
|
box-shadow: none;
|
|
62
66
|
color: ${colors.brand.grey};
|
|
67
|
+
min-height: 44px;
|
|
68
|
+
min-width: 44px;
|
|
63
69
|
&:hover {
|
|
64
70
|
color: ${colors.brand.primary};
|
|
65
71
|
}
|
|
@@ -94,12 +100,9 @@ export const Row = styled.div`
|
|
|
94
100
|
`;
|
|
95
101
|
|
|
96
102
|
const TagCounterWrapper = styled.span`
|
|
97
|
-
|
|
98
|
-
box-shadow: none;
|
|
99
|
-
margin: 0;
|
|
103
|
+
display: flex;
|
|
100
104
|
font-weight: ${fonts.weight.semibold};
|
|
101
105
|
${fonts.sizes('14px', '14px')};
|
|
102
|
-
padding: 5px;
|
|
103
106
|
`;
|
|
104
107
|
|
|
105
108
|
export interface ContentIconProps {
|
|
@@ -149,15 +152,6 @@ interface CompressedTagListProps {
|
|
|
149
152
|
tagLinkPrefix?: string;
|
|
150
153
|
}
|
|
151
154
|
|
|
152
|
-
const TagMenuButton = styled(MenuButton)`
|
|
153
|
-
&:hover,
|
|
154
|
-
&:active,
|
|
155
|
-
&:focus {
|
|
156
|
-
transition: ${misc.transition.default};
|
|
157
|
-
border-radius: 100%;
|
|
158
|
-
background-color: ${colors.brand.light};
|
|
159
|
-
}
|
|
160
|
-
`;
|
|
161
155
|
export const CompressedTagList = ({ tags, tagLinkPrefix }: CompressedTagListProps) => {
|
|
162
156
|
const navigate = useNavigate();
|
|
163
157
|
const { t } = useTranslation();
|
|
@@ -175,12 +169,13 @@ export const CompressedTagList = ({ tags, tagLinkPrefix }: CompressedTagListProp
|
|
|
175
169
|
<>
|
|
176
170
|
<TagList tagLinkPrefix={tagLinkPrefix} tags={visibleTags} />
|
|
177
171
|
{remainingTags.length > 0 && (
|
|
178
|
-
<
|
|
179
|
-
|
|
172
|
+
<MenuButton
|
|
173
|
+
size="small"
|
|
174
|
+
menuIcon={<TagCounterWrapper>{`+${remainingTags.length}`}</TagCounterWrapper>}
|
|
180
175
|
menuItems={remainingTags}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
alignRight
|
|
177
|
+
aria-label={t('myNdla.moreTags', { count: remainingTags.length })}
|
|
178
|
+
/>
|
|
184
179
|
)}
|
|
185
180
|
</>
|
|
186
181
|
);
|
|
@@ -60,6 +60,7 @@ interface Props {
|
|
|
60
60
|
onOpenFolder: (id: string) => void;
|
|
61
61
|
onCloseFolder: (id: string) => void;
|
|
62
62
|
setFocusedFolder: (folder: FolderType) => void;
|
|
63
|
+
ariaDescribedby?: string;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const ComboboxButton = forwardRef<HTMLButtonElement, Props>(
|
|
@@ -76,6 +77,7 @@ const ComboboxButton = forwardRef<HTMLButtonElement, Props>(
|
|
|
76
77
|
setFocusedFolder,
|
|
77
78
|
onOpenFolder,
|
|
78
79
|
onCloseFolder,
|
|
80
|
+
ariaDescribedby,
|
|
79
81
|
},
|
|
80
82
|
ref,
|
|
81
83
|
) => {
|
|
@@ -124,6 +126,7 @@ const ComboboxButton = forwardRef<HTMLButtonElement, Props>(
|
|
|
124
126
|
aria-expanded={showTree}
|
|
125
127
|
aria-labelledby={label ? treestructureId(type, 'label') : undefined}
|
|
126
128
|
aria-activedescendant={focusedFolder ? treestructureId(type, focusedFolder.id) : undefined}
|
|
129
|
+
aria-describedby={ariaDescribedby}
|
|
127
130
|
variant="ghost"
|
|
128
131
|
colorTheme="light"
|
|
129
132
|
fontWeight="normal"
|
|
@@ -74,6 +74,7 @@ export interface TreeStructureProps extends CommonTreeStructureProps {
|
|
|
74
74
|
maxLevel?: number;
|
|
75
75
|
newFolderInput?: NewFolderInputFunc;
|
|
76
76
|
onSelectFolder?: (id: string) => void;
|
|
77
|
+
ariaDescribedby?: string;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
const TreeStructure = ({
|
|
@@ -86,6 +87,7 @@ const TreeStructure = ({
|
|
|
86
87
|
targetResource,
|
|
87
88
|
type,
|
|
88
89
|
newFolderInput,
|
|
90
|
+
ariaDescribedby,
|
|
89
91
|
}: TreeStructureProps) => {
|
|
90
92
|
const ref = useRef<HTMLButtonElement>(null);
|
|
91
93
|
|
|
@@ -209,6 +211,7 @@ const TreeStructure = ({
|
|
|
209
211
|
flattenedFolders={flattenedFolders}
|
|
210
212
|
onCloseFolder={onCloseFolder}
|
|
211
213
|
onOpenFolder={onOpenFolder}
|
|
214
|
+
ariaDescribedby={ariaDescribedby}
|
|
212
215
|
/>
|
|
213
216
|
)}
|
|
214
217
|
{showTree && (
|