@ndla/ui 3.3.6 → 3.3.7
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/AudioPlayer/Controls.js +30 -30
- package/es/ContentTypeBadge/ContentTypeBadge.js +30 -10
- package/es/Programme/Programme.js +11 -36
- package/es/Programme/ProgrammeSubjects.js +15 -42
- package/es/SearchTypeResult/SearchTypeHeader.js +7 -6
- package/lib/AudioPlayer/Controls.js +30 -30
- package/lib/ContentTypeBadge/ContentTypeBadge.d.ts +3 -1
- package/lib/ContentTypeBadge/ContentTypeBadge.js +30 -10
- package/lib/Programme/Programme.d.ts +1 -1
- package/lib/Programme/Programme.js +11 -36
- package/lib/Programme/ProgrammeSubjects.d.ts +3 -2
- package/lib/Programme/ProgrammeSubjects.js +23 -48
- package/lib/SearchTypeResult/SearchTypeHeader.js +7 -6
- package/package.json +9 -9
- package/src/AudioPlayer/Controls.tsx +2 -2
- package/src/ContentTypeBadge/ContentTypeBadge.tsx +11 -9
- package/src/Programme/Programme.tsx +3 -15
- package/src/Programme/ProgrammeSubjects.tsx +10 -28
- package/src/SearchTypeResult/SearchTypeHeader.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/button": "^1.1.
|
|
35
|
-
"@ndla/carousel": "^1.0.
|
|
34
|
+
"@ndla/button": "^1.1.2",
|
|
35
|
+
"@ndla/carousel": "^1.0.7",
|
|
36
36
|
"@ndla/core": "^0.7.2",
|
|
37
37
|
"@ndla/hooks": "^1.0.7",
|
|
38
|
-
"@ndla/icons": "^1.3.
|
|
39
|
-
"@ndla/licenses": "^1.1.
|
|
40
|
-
"@ndla/modal": "^1.1.
|
|
41
|
-
"@ndla/safelink": "^1.0.
|
|
38
|
+
"@ndla/icons": "^1.3.2",
|
|
39
|
+
"@ndla/licenses": "^1.1.4",
|
|
40
|
+
"@ndla/modal": "^1.1.16",
|
|
41
|
+
"@ndla/safelink": "^1.0.7",
|
|
42
42
|
"@ndla/switch": "^0.0.32",
|
|
43
|
-
"@ndla/tabs": "^1.0.
|
|
43
|
+
"@ndla/tabs": "^1.0.13",
|
|
44
44
|
"@ndla/tooltip": "^0.2.49",
|
|
45
45
|
"@ndla/util": "^2.0.1",
|
|
46
46
|
"@reach/menu-button": "^0.12.1",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "442cac4c7229e4d8151b850ab4e8c4a6e0b7586c"
|
|
96
96
|
}
|
|
@@ -415,9 +415,9 @@ const Controls = ({ src, title }: Props) => {
|
|
|
415
415
|
<PlayButton type="button" onClick={togglePlay} title="play" aria-label="play">
|
|
416
416
|
<span aria-hidden>
|
|
417
417
|
{playing ? (
|
|
418
|
-
<Pause role="img" aria-label="
|
|
418
|
+
<Pause role="img" aria-label="Pause" title="Pause" />
|
|
419
419
|
) : (
|
|
420
|
-
<Play role="img" aria-label="
|
|
420
|
+
<Play role="img" aria-label="Play" title="Play" />
|
|
421
421
|
)}
|
|
422
422
|
</span>
|
|
423
423
|
</PlayButton>
|
|
@@ -26,11 +26,12 @@ const classes = new BEMHelper({
|
|
|
26
26
|
interface Props {
|
|
27
27
|
size: 'xx-small' | 'x-small' | 'small' | 'large';
|
|
28
28
|
type: string;
|
|
29
|
+
title?: string;
|
|
29
30
|
background?: boolean;
|
|
30
31
|
border?: boolean;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
34
|
+
export const ContentTypeBadge = ({ type, background, title, size = 'small', border = true }: Props) => {
|
|
34
35
|
const modifiers = [type, size];
|
|
35
36
|
|
|
36
37
|
if (background) {
|
|
@@ -43,28 +44,28 @@ export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
|
43
44
|
let icon = null;
|
|
44
45
|
switch (type) {
|
|
45
46
|
case contentTypes.SUBJECT_MATERIAL:
|
|
46
|
-
icon = <SubjectMaterial />;
|
|
47
|
+
icon = <SubjectMaterial title={title} />;
|
|
47
48
|
break;
|
|
48
49
|
case contentTypes.TASKS_AND_ACTIVITIES:
|
|
49
|
-
icon = <TasksAndActivities />;
|
|
50
|
+
icon = <TasksAndActivities title={title} />;
|
|
50
51
|
break;
|
|
51
52
|
case contentTypes.ASSESSMENT_RESOURCES:
|
|
52
|
-
icon = <AssessmentResource />;
|
|
53
|
+
icon = <AssessmentResource title={title} />;
|
|
53
54
|
break;
|
|
54
55
|
case contentTypes.SUBJECT:
|
|
55
|
-
icon = <MenuBook />;
|
|
56
|
+
icon = <MenuBook title={title} />;
|
|
56
57
|
break;
|
|
57
58
|
case contentTypes.EXTERNAL_LEARNING_RESOURCES:
|
|
58
|
-
icon = <ExternalLearningResource />;
|
|
59
|
+
icon = <ExternalLearningResource title={title} />;
|
|
59
60
|
break;
|
|
60
61
|
case contentTypes.SOURCE_MATERIAL:
|
|
61
|
-
icon = <SharedResource />;
|
|
62
|
+
icon = <SharedResource title={title} />;
|
|
62
63
|
break;
|
|
63
64
|
case contentTypes.LEARNING_PATH:
|
|
64
|
-
icon = <LearningPath />;
|
|
65
|
+
icon = <LearningPath title={title} />;
|
|
65
66
|
break;
|
|
66
67
|
case contentTypes.TOPIC:
|
|
67
|
-
icon = <Subject />;
|
|
68
|
+
icon = <Subject title={title} />;
|
|
68
69
|
break;
|
|
69
70
|
default:
|
|
70
71
|
break;
|
|
@@ -75,6 +76,7 @@ export const ContentTypeBadge = ({ type, background, size, border }: Props) => {
|
|
|
75
76
|
ContentTypeBadge.propTypes = {
|
|
76
77
|
size: PropTypes.oneOf(['xx-small', 'x-small', 'small', 'large']),
|
|
77
78
|
type: ContentTypeShape,
|
|
79
|
+
title: PropTypes.string,
|
|
78
80
|
background: PropTypes.bool,
|
|
79
81
|
border: PropTypes.bool,
|
|
80
82
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
3
|
import { breakpoints, mq, spacing } from '@ndla/core';
|
|
4
4
|
import LayoutItem, { OneColumn } from '../Layout';
|
|
@@ -65,19 +65,7 @@ type Props = GradesProps & {
|
|
|
65
65
|
image?: string;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export const Programme = ({ heading, image, grades }: Props) => {
|
|
69
|
-
const [showGradeIndex, setShowGradeIndex] = useState(0);
|
|
70
|
-
const isWindowContext = typeof window !== 'undefined';
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (isWindowContext) {
|
|
74
|
-
const rememberGradeIndex = window.localStorage.getItem('programmeShowGradeIndex') || '0';
|
|
75
|
-
if (grades.length > Number(rememberGradeIndex)) {
|
|
76
|
-
setShowGradeIndex(Number(rememberGradeIndex));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, [isWindowContext, grades]);
|
|
80
|
-
|
|
68
|
+
export const Programme = ({ heading, image, grades, selectedGrade, onChangeGrade }: Props) => {
|
|
81
69
|
return (
|
|
82
70
|
<StyledWrapper>
|
|
83
71
|
<StyledBackground image={image} />
|
|
@@ -87,7 +75,7 @@ export const Programme = ({ heading, image, grades }: Props) => {
|
|
|
87
75
|
<StyledContentWrapper>
|
|
88
76
|
<NavigationHeading>{heading}</NavigationHeading>
|
|
89
77
|
<SubjectsWrapper>
|
|
90
|
-
<ProgrammeSubjects grades={grades}
|
|
78
|
+
<ProgrammeSubjects grades={grades} selectedGrade={selectedGrade} onChangeGrade={onChangeGrade} />
|
|
91
79
|
</SubjectsWrapper>
|
|
92
80
|
</StyledContentWrapper>
|
|
93
81
|
</LayoutItem>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React
|
|
9
|
+
import React from 'react';
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
import Button from '@ndla/button';
|
|
@@ -27,6 +27,8 @@ const GradesMenu = styled.div`
|
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
29
|
export type GradesProps = {
|
|
30
|
+
selectedGrade?: string;
|
|
31
|
+
onChangeGrade: (newGrade: string) => void;
|
|
30
32
|
grades: {
|
|
31
33
|
name: string;
|
|
32
34
|
categories: {
|
|
@@ -40,47 +42,27 @@ export type GradesProps = {
|
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
type Props = GradesProps & {
|
|
43
|
-
preSelectedGradeIndex?: number;
|
|
44
45
|
onNavigate?: () => void;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
const ProgrammeSubjects = ({ grades, onNavigate,
|
|
48
|
-
const
|
|
49
|
-
const isWindowContext = typeof window !== 'undefined';
|
|
50
|
-
|
|
51
|
-
const toggleGradeIndex = (index: number) => {
|
|
52
|
-
setShowGradeIndex(index);
|
|
53
|
-
if (isWindowContext) {
|
|
54
|
-
window.localStorage.setItem('programmeShowGradeIndex', `${index}`);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const selectedGrade = grades[showGradeIndex];
|
|
48
|
+
const ProgrammeSubjects = ({ grades, onNavigate, onChangeGrade, selectedGrade = 'vg1' }: Props) => {
|
|
49
|
+
const grade = grades.find((grade) => grade.name.toLowerCase() === selectedGrade) ?? grades[0];
|
|
59
50
|
return (
|
|
60
51
|
<>
|
|
61
52
|
<GradesMenu>
|
|
62
|
-
{grades.map((item
|
|
53
|
+
{grades.map((item) => (
|
|
63
54
|
<Button
|
|
64
55
|
key={item.name}
|
|
65
|
-
onClick={() =>
|
|
66
|
-
lighter={
|
|
56
|
+
onClick={() => onChangeGrade(item.name.toLowerCase())}
|
|
57
|
+
lighter={item !== grade}
|
|
67
58
|
size="normal"
|
|
68
59
|
borderShape="rounded">
|
|
69
60
|
{item.name}
|
|
70
61
|
</Button>
|
|
71
62
|
))}
|
|
72
63
|
</GradesMenu>
|
|
73
|
-
{
|
|
74
|
-
<NavigationBox
|
|
75
|
-
key={category.name}
|
|
76
|
-
heading={category.name}
|
|
77
|
-
items={category.subjects}
|
|
78
|
-
onClick={() => {
|
|
79
|
-
if (onNavigate) {
|
|
80
|
-
onNavigate();
|
|
81
|
-
}
|
|
82
|
-
}}
|
|
83
|
-
/>
|
|
64
|
+
{grade.categories.map((category) => (
|
|
65
|
+
<NavigationBox key={category.name} heading={category.name} items={category.subjects} onClick={onNavigate} />
|
|
84
66
|
))}
|
|
85
67
|
</>
|
|
86
68
|
);
|
|
@@ -85,7 +85,7 @@ type Props = {
|
|
|
85
85
|
const SearchTypeHeader = ({ filters, onFilterClick, totalCount, type, t }: Props & WithTranslation) => (
|
|
86
86
|
<HeaderWrapper>
|
|
87
87
|
<TypeWrapper>
|
|
88
|
-
{type && <ContentTypeBadge type={type} background size="large" />}
|
|
88
|
+
{type && <ContentTypeBadge type={type} title={t(`contentTypes.${type}`)} background size="large" />}
|
|
89
89
|
<SubjectName>
|
|
90
90
|
{type && <b>{t(`contentTypes.${type}`)}</b>}{' '}
|
|
91
91
|
{totalCount && <Count>{t(`searchPage.resultType.hits`, { count: totalCount })}</Count>}
|