@ndla/ui 24.2.2 → 25.0.2
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/CompetenceGoals/CompetenceGoalsDialog.js +15 -23
- package/es/CompetenceGoals/index.js +1 -4
- package/es/Filter/FilterButtons.js +10 -11
- package/es/Filter/FilterList.js +82 -152
- package/es/Filter/FilterListPhone.js +180 -271
- package/es/Filter/ToggleItem.js +6 -25
- package/es/Frontpage/FrontpageAllSubjects.js +8 -9
- package/es/Frontpage/FrontpageSearch.js +3 -4
- package/es/Masthead/Masthead.js +65 -41
- package/es/Masthead/MastheadSearchModal.js +4 -5
- package/es/Masthead/SkipToMainContent.js +24 -0
- package/es/Masthead/index.js +2 -1
- package/es/SearchTypeResult/PopupFilter.js +8 -9
- package/es/SearchTypeResult/SearchFilterContent.js +3 -4
- package/es/SectionHeading/SectionHeading.js +24 -17
- package/es/Subject/index.js +0 -1
- package/es/all.css +1 -1
- package/es/index-javascript.js +1 -4
- package/es/index.js +6 -2
- package/lib/CompetenceGoals/CompetenceGoalsDialog.d.ts +19 -0
- package/lib/CompetenceGoals/CompetenceGoalsDialog.js +13 -24
- package/lib/CompetenceGoals/index.d.ts +1 -0
- package/lib/CompetenceGoals/index.js +1 -33
- package/lib/Filter/FilterButtons.js +9 -9
- package/lib/Filter/FilterList.d.ts +25 -0
- package/lib/Filter/FilterList.js +85 -155
- package/lib/Filter/FilterListPhone.d.ts +32 -0
- package/lib/Filter/FilterListPhone.js +176 -269
- package/lib/Filter/ToggleItem.d.ts +15 -0
- package/lib/Filter/ToggleItem.js +6 -32
- package/lib/Filter/filterClasses.d.ts +2 -0
- package/lib/Filter/index.d.ts +12 -0
- package/lib/Frontpage/FrontpageAllSubjects.js +7 -7
- package/lib/Frontpage/FrontpageMultidisciplinarySubject.d.ts +5 -5
- package/lib/Frontpage/FrontpageSearch.js +2 -3
- package/lib/Frontpage/illustrations/FrontpageIllustrations.d.ts +2 -2
- package/lib/Masthead/Masthead.d.ts +4 -8
- package/lib/Masthead/Masthead.js +65 -49
- package/lib/Masthead/MastheadSearchModal.js +3 -4
- package/lib/Masthead/SkipToMainContent.d.ts +6 -0
- package/lib/Masthead/SkipToMainContent.js +38 -0
- package/lib/Masthead/index.d.ts +2 -1
- package/lib/Masthead/index.js +10 -0
- package/lib/MultidisciplinarySubject/Illustrations.d.ts +7 -7
- package/lib/Resource/resourceComponents.d.ts +2 -2
- package/lib/Search/ActiveFilterContent.d.ts +1 -1
- package/lib/Search/ContentTypeResultStyles.d.ts +3 -3
- package/lib/SearchTypeResult/ActiveFilterContent.d.ts +1 -1
- package/lib/SearchTypeResult/PopupFilter.js +7 -7
- package/lib/SearchTypeResult/SearchFilterContent.js +2 -2
- package/lib/SectionHeading/SectionHeading.d.ts +1 -13
- package/lib/SectionHeading/SectionHeading.js +23 -19
- package/lib/Subject/index.d.ts +0 -1
- package/lib/Subject/index.js +0 -8
- package/lib/all.css +1 -1
- package/lib/index-javascript.js +1 -63
- package/lib/index.d.ts +6 -2
- package/lib/index.js +60 -10
- package/package.json +11 -11
- package/src/CompetenceGoals/{CompetenceGoalsDialog.jsx → CompetenceGoalsDialog.tsx} +34 -26
- package/src/CompetenceGoals/index.ts +1 -0
- package/src/Filter/FilterButtons.tsx +0 -1
- package/src/Filter/FilterList.tsx +135 -0
- package/src/Filter/FilterListPhone.tsx +275 -0
- package/src/Filter/ToggleItem.tsx +58 -0
- package/src/Filter/{filterClasses.js → filterClasses.ts} +0 -0
- package/src/Filter/{index.js → index.ts} +0 -0
- package/src/Frontpage/FrontpageAllSubjects.tsx +0 -1
- package/src/Frontpage/FrontpageSearch.tsx +0 -1
- package/src/Masthead/Masthead.tsx +85 -45
- package/src/Masthead/MastheadSearchModal.tsx +0 -1
- package/src/Masthead/SkipToMainContent.tsx +48 -0
- package/src/Masthead/index.ts +2 -1
- package/src/SearchTypeResult/PopupFilter.tsx +0 -1
- package/src/SearchTypeResult/SearchFilterContent.tsx +0 -1
- package/src/SectionHeading/SectionHeading.tsx +29 -16
- package/src/Subject/index.ts +0 -1
- package/src/index-javascript.js +0 -10
- package/src/index.ts +9 -2
- package/src/main.scss +0 -3
- package/es/CompetenceGoals/CompetenceGoalList.js +0 -58
- package/es/CompetenceGoals/CompetenceGoals.js +0 -159
- package/es/Subject/SubjectFilter.js +0 -42
- package/lib/CompetenceGoals/CompetenceGoalList.js +0 -78
- package/lib/CompetenceGoals/CompetenceGoals.js +0 -184
- package/lib/Subject/SubjectFilter.d.ts +0 -27
- package/lib/Subject/SubjectFilter.js +0 -58
- package/src/CompetenceGoals/CompetenceGoalList.jsx +0 -51
- package/src/CompetenceGoals/CompetenceGoals.jsx +0 -152
- package/src/CompetenceGoals/component.competence-goals.scss +0 -161
- package/src/CompetenceGoals/index.js +0 -6
- package/src/Filter/FilterList.jsx +0 -167
- package/src/Filter/FilterListPhone.jsx +0 -328
- package/src/Filter/ToggleItem.jsx +0 -71
- package/src/Masthead/component.masthead.scss +0 -146
- package/src/SectionHeading/component.section-heading.scss +0 -17
- package/src/Subject/SubjectFilter.tsx +0 -48
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactBemHelper = _interopRequireDefault(require("react-bem-helper"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _FilterList = _interopRequireDefault(require("../Filter/FilterList"));
|
|
15
|
-
|
|
16
|
-
var _core = require("@emotion/core");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
var searchFilterClasses = (0, _reactBemHelper["default"])({
|
|
22
|
-
prefix: 'c-',
|
|
23
|
-
name: 'filter',
|
|
24
|
-
outputIsString: true
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
var valueShape = _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]);
|
|
28
|
-
|
|
29
|
-
var SubjectFilter = function SubjectFilter(_ref) {
|
|
30
|
-
var label = _ref.label,
|
|
31
|
-
options = _ref.options,
|
|
32
|
-
values = _ref.values,
|
|
33
|
-
onChange = _ref.onChange;
|
|
34
|
-
return (0, _core.jsx)("div", {
|
|
35
|
-
className: searchFilterClasses('', ['subject', 'background'])
|
|
36
|
-
}, (0, _core.jsx)(_FilterList["default"], {
|
|
37
|
-
onChange: onChange,
|
|
38
|
-
labelNotVisible: true,
|
|
39
|
-
options: options,
|
|
40
|
-
label: label,
|
|
41
|
-
values: values
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
SubjectFilter.propTypes = {
|
|
46
|
-
label: _propTypes["default"].string.isRequired,
|
|
47
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
48
|
-
options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
49
|
-
value: valueShape.isRequired,
|
|
50
|
-
title: _propTypes["default"].string.isRequired
|
|
51
|
-
})).isRequired,
|
|
52
|
-
values: _propTypes["default"].arrayOf(valueShape)
|
|
53
|
-
};
|
|
54
|
-
SubjectFilter.defaultProps = {
|
|
55
|
-
values: []
|
|
56
|
-
};
|
|
57
|
-
var _default = SubjectFilter;
|
|
58
|
-
exports["default"] = _default;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from '@emotion/styled';
|
|
4
|
-
import { mq, breakpoints, fonts, spacing } from '@ndla/core';
|
|
5
|
-
import SafeLink from '@ndla/safelink';
|
|
6
|
-
import { classes } from './CompetenceGoals';
|
|
7
|
-
import { CompetenceGoalShape } from '../shapes';
|
|
8
|
-
|
|
9
|
-
export const CompetenceGoalListHeading = styled('p')`
|
|
10
|
-
font-weight: ${fonts.weight.semibold};
|
|
11
|
-
margin-bottom: ${spacing.small};
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
const StyledListItem = styled('li')`
|
|
15
|
-
line-height: ${spacing.normal};
|
|
16
|
-
${mq.range({ until: breakpoints.tablet })} {
|
|
17
|
-
${fonts.sizes(16, 1.5)};
|
|
18
|
-
}
|
|
19
|
-
&:last-child {
|
|
20
|
-
margin-bottom: 0;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
export const CompetenceGoal = ({ goal }) => {
|
|
25
|
-
const content = goal.url ? <SafeLink to={goal.url}>{goal.name}</SafeLink> : goal.name;
|
|
26
|
-
|
|
27
|
-
return <StyledListItem {...classes('topic-item')}>{content}</StyledListItem>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
CompetenceGoal.propTypes = {
|
|
31
|
-
goal: CompetenceGoalShape,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const StyledList = styled('ul')`
|
|
35
|
-
margin: 0 0 ${spacing.large} ${spacing.normal};
|
|
36
|
-
padding: 0;
|
|
37
|
-
max-width: 650px;
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
export const CompetenceGoalList = ({ goals, ...rest }) => (
|
|
41
|
-
<StyledList {...classes('topic-list')} {...rest}>
|
|
42
|
-
{goals.map((goal) => (
|
|
43
|
-
<CompetenceGoal key={goal.id} goal={goal} />
|
|
44
|
-
))}
|
|
45
|
-
</StyledList>
|
|
46
|
-
);
|
|
47
|
-
CompetenceGoalList.propTypes = {
|
|
48
|
-
goals: PropTypes.arrayOf(CompetenceGoalShape).isRequired,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default CompetenceGoalList;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import React, { Component, Fragment } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import BEMHelper from 'react-bem-helper';
|
|
4
|
-
import { ChevronRight, ChevronDown } from '@ndla/icons/common';
|
|
5
|
-
import { withTranslation } from 'react-i18next';
|
|
6
|
-
import { FilterListPhone } from '../Filter';
|
|
7
|
-
import CompetenceGoalList from './CompetenceGoalList';
|
|
8
|
-
|
|
9
|
-
export const classes = new BEMHelper({
|
|
10
|
-
name: 'competence-goals',
|
|
11
|
-
prefix: 'c-',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
class CompetenceGoals extends Component {
|
|
15
|
-
constructor(props) {
|
|
16
|
-
super(props);
|
|
17
|
-
this.state = {
|
|
18
|
-
expanded: null,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
render() {
|
|
23
|
-
const {
|
|
24
|
-
messages,
|
|
25
|
-
headingId,
|
|
26
|
-
topics,
|
|
27
|
-
id,
|
|
28
|
-
menu,
|
|
29
|
-
search,
|
|
30
|
-
subjectName,
|
|
31
|
-
filterOptions,
|
|
32
|
-
filterValues,
|
|
33
|
-
onFilterClick,
|
|
34
|
-
description,
|
|
35
|
-
t,
|
|
36
|
-
} = this.props;
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div {...classes('', { menu, search })}>
|
|
40
|
-
{!menu && !search ? (
|
|
41
|
-
<Fragment>
|
|
42
|
-
<h1 id={headingId}>{messages.heading}</h1>
|
|
43
|
-
<hr />
|
|
44
|
-
<p>{description}</p>
|
|
45
|
-
<p>{messages.listDescription}</p>
|
|
46
|
-
<div {...classes('topic')}>
|
|
47
|
-
<CompetenceGoalList goals={topics[0].items} />
|
|
48
|
-
</div>
|
|
49
|
-
</Fragment>
|
|
50
|
-
) : (
|
|
51
|
-
<Fragment>
|
|
52
|
-
<h1 {...classes('subject-heading')}>{subjectName}</h1>
|
|
53
|
-
<h2 id={headingId} {...classes('heading')}>
|
|
54
|
-
{messages.heading}
|
|
55
|
-
</h2>
|
|
56
|
-
<p {...classes('description')}>{messages.listDescription}</p>
|
|
57
|
-
{filterOptions && filterOptions.length > 0 && (
|
|
58
|
-
<Fragment>
|
|
59
|
-
<FilterListPhone
|
|
60
|
-
preid="competence"
|
|
61
|
-
label="Filtrer kompetansemål"
|
|
62
|
-
options={filterOptions}
|
|
63
|
-
alignedGroup
|
|
64
|
-
values={filterValues}
|
|
65
|
-
onChange={onFilterClick}
|
|
66
|
-
messages={{
|
|
67
|
-
openFilter: t('competenceGoals.openCompentenceGoalsFilter'),
|
|
68
|
-
useFilter: t('competenceGoals.useCompentenceGoalsFilter'),
|
|
69
|
-
closeFilter: t('competenceGoals.closeCompentenceGoalsFilter'),
|
|
70
|
-
}}
|
|
71
|
-
/>
|
|
72
|
-
</Fragment>
|
|
73
|
-
)}
|
|
74
|
-
{topics.map((topic) => (
|
|
75
|
-
<div
|
|
76
|
-
{...classes('topic', {
|
|
77
|
-
expandable: true,
|
|
78
|
-
expanded: this.state.expanded === topic.heading,
|
|
79
|
-
})}
|
|
80
|
-
key={topic.heading}>
|
|
81
|
-
<h3 {...classes('topic-heading')}>
|
|
82
|
-
<button
|
|
83
|
-
{...classes('topic-heading-button')}
|
|
84
|
-
type="button"
|
|
85
|
-
aria-expanded={this.state.expanded === topic.heading}
|
|
86
|
-
aria-controls={id}
|
|
87
|
-
onClick={() => {
|
|
88
|
-
this.setState((prevState) => {
|
|
89
|
-
let expanded = null;
|
|
90
|
-
if (prevState.expanded !== topic.heading) {
|
|
91
|
-
expanded = topic.heading;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
expanded,
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
}}>
|
|
99
|
-
{this.state.expanded === topic.heading ? <ChevronDown /> : <ChevronRight />}
|
|
100
|
-
{topic.heading}
|
|
101
|
-
</button>
|
|
102
|
-
</h3>
|
|
103
|
-
|
|
104
|
-
<CompetenceGoalList id={id} aria-hidden={this.state.expanded !== topic.heading} goals={topic.items} />
|
|
105
|
-
</div>
|
|
106
|
-
))}
|
|
107
|
-
</Fragment>
|
|
108
|
-
)}
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
CompetenceGoals.propTypes = {
|
|
115
|
-
id: PropTypes.string,
|
|
116
|
-
headingId: PropTypes.string,
|
|
117
|
-
menu: PropTypes.bool,
|
|
118
|
-
search: PropTypes.bool,
|
|
119
|
-
description: PropTypes.string.isRequired,
|
|
120
|
-
messages: PropTypes.shape({
|
|
121
|
-
heading: PropTypes.string.isRequired,
|
|
122
|
-
listDescription: PropTypes.string.isRequired,
|
|
123
|
-
}).isRequired,
|
|
124
|
-
subjectName: PropTypes.string,
|
|
125
|
-
filterOptions: PropTypes.arrayOf(
|
|
126
|
-
PropTypes.shape({
|
|
127
|
-
title: PropTypes.string.isRequired,
|
|
128
|
-
value: PropTypes.string.isRequired,
|
|
129
|
-
}),
|
|
130
|
-
),
|
|
131
|
-
filterValues: PropTypes.arrayOf(PropTypes.string),
|
|
132
|
-
onFilterClick: PropTypes.func.isRequired,
|
|
133
|
-
topics: PropTypes.arrayOf(
|
|
134
|
-
PropTypes.shape({
|
|
135
|
-
heading: PropTypes.string,
|
|
136
|
-
items: PropTypes.arrayOf(
|
|
137
|
-
PropTypes.shape({
|
|
138
|
-
text: PropTypes.string.isRequired,
|
|
139
|
-
url: PropTypes.string,
|
|
140
|
-
}),
|
|
141
|
-
),
|
|
142
|
-
}),
|
|
143
|
-
),
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
CompetenceGoals.defaultProps = {
|
|
147
|
-
headingId: null,
|
|
148
|
-
menu: false,
|
|
149
|
-
search: false,
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export default withTranslation()(CompetenceGoals);
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
.c-competence-goals {
|
|
2
|
-
height: 100%;
|
|
3
|
-
max-width: 960px;
|
|
4
|
-
width: 100%;
|
|
5
|
-
margin: 0 auto;
|
|
6
|
-
padding: 32px;
|
|
7
|
-
|
|
8
|
-
@include mq(mobile) {
|
|
9
|
-
padding: 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
&__dialog-wrapper {
|
|
13
|
-
@include mq(tablet) {
|
|
14
|
-
padding-left: $spacing;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
&__heading {
|
|
19
|
-
margin-top: 0;
|
|
20
|
-
@include font-size(20px, 32px);
|
|
21
|
-
|
|
22
|
-
@include mq(tablet) {
|
|
23
|
-
@include font-size(22px, 32px);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&__subject-heading {
|
|
28
|
-
@include font-size(20px, 32px);
|
|
29
|
-
margin: 0 0 $spacing 0;
|
|
30
|
-
color: $brand-color;
|
|
31
|
-
|
|
32
|
-
@include mq(desktop) {
|
|
33
|
-
display: none;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&__description {
|
|
38
|
-
margin-bottom: $spacing;
|
|
39
|
-
@include mq($until: tablet) {
|
|
40
|
-
@include font-size(16px, 20px);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.c-filter {
|
|
45
|
-
position: relative;
|
|
46
|
-
|
|
47
|
-
&__list {
|
|
48
|
-
padding-top: $spacing--small;
|
|
49
|
-
border-top: 0;
|
|
50
|
-
margin-bottom: $spacing--small;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&__item {
|
|
54
|
-
margin-bottom: $spacing--small;
|
|
55
|
-
margin-left: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&__label {
|
|
59
|
-
@include visually-hidden();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&__topic {
|
|
64
|
-
margin-bottom: $spacing;
|
|
65
|
-
padding-top: $spacing;
|
|
66
|
-
|
|
67
|
-
@include mq(tabletWide) {
|
|
68
|
-
padding-top: $spacing--small;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&--expandable {
|
|
72
|
-
margin-bottom: $spacing--small;
|
|
73
|
-
max-height: 35px;
|
|
74
|
-
transition: max-height 0.3s ease-in-out;
|
|
75
|
-
|
|
76
|
-
.c-competence-goals {
|
|
77
|
-
&__topic-list {
|
|
78
|
-
opacity: 0;
|
|
79
|
-
transition: opacity 0.1s ease-in-out 0.1s;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&--expanded {
|
|
85
|
-
max-height: 4000px;
|
|
86
|
-
.c-competence-goals {
|
|
87
|
-
&__topic-list {
|
|
88
|
-
opacity: 1;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&__topic-heading {
|
|
95
|
-
margin: 0 0 $spacing 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&__topic-heading-button,
|
|
99
|
-
&__topic-heading {
|
|
100
|
-
color: $brand-color;
|
|
101
|
-
@include inuit-font-size(18px, 23px);
|
|
102
|
-
font-weight: $font-weight-semibold;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
&__topic-heading-button {
|
|
106
|
-
background: none;
|
|
107
|
-
border: none;
|
|
108
|
-
margin: 0 0 0 -4px;
|
|
109
|
-
position: relative;
|
|
110
|
-
padding: $spacing--small/2 $spacing--small/2 0;
|
|
111
|
-
cursor: pointer;
|
|
112
|
-
display: flex;
|
|
113
|
-
align-items: center;
|
|
114
|
-
|
|
115
|
-
@include mq(desktop) {
|
|
116
|
-
margin: 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.c-icon {
|
|
120
|
-
@include mq(desktop) {
|
|
121
|
-
position: absolute;
|
|
122
|
-
left: -21px;
|
|
123
|
-
top: 9px;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&--menu,
|
|
129
|
-
&--search {
|
|
130
|
-
padding: $spacing--small $spacing $spacing--small $spacing--small;
|
|
131
|
-
@include mq($until: mobileWide) {
|
|
132
|
-
padding: 0;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
.c-competence-goals {
|
|
136
|
-
&__heading {
|
|
137
|
-
text-transform: uppercase;
|
|
138
|
-
color: $primary-color;
|
|
139
|
-
font-weight: $font-weight-semibold;
|
|
140
|
-
@include font-size(16px, 20px);
|
|
141
|
-
}
|
|
142
|
-
&__topic--expandable {
|
|
143
|
-
padding-left: ($spacing--small + 10px);
|
|
144
|
-
.c-competence-goals__topic-list {
|
|
145
|
-
font-weight: $font-weight-normal;
|
|
146
|
-
padding-left: ($spacing--small + 12px);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
@include mq($until: desktop) {
|
|
151
|
-
&--menu,
|
|
152
|
-
&--search {
|
|
153
|
-
.c-competence-goals {
|
|
154
|
-
&__topic--expandable {
|
|
155
|
-
padding-left: 0;
|
|
156
|
-
margin-left: -4px;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import CompetenceGoals from './CompetenceGoals';
|
|
2
|
-
|
|
3
|
-
export { default as CompetenceGoalsDialog } from './CompetenceGoalsDialog';
|
|
4
|
-
export { default as CompetenceGoalList, CompetenceGoal, CompetenceGoalListHeading } from './CompetenceGoalList';
|
|
5
|
-
|
|
6
|
-
export default CompetenceGoals;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present, NDLA.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
* FRI OG BEGRENSET
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React, { Component, Fragment } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { ChevronDown, ChevronUp } from '@ndla/icons/common';
|
|
12
|
-
|
|
13
|
-
import { classes } from './filterClasses';
|
|
14
|
-
import ToggleItem from './ToggleItem';
|
|
15
|
-
|
|
16
|
-
class FilterList extends Component {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this.state = {
|
|
20
|
-
visibleCount: props.defaultVisibleCount,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
render() {
|
|
25
|
-
const {
|
|
26
|
-
modifiers,
|
|
27
|
-
preid,
|
|
28
|
-
label,
|
|
29
|
-
labelNotVisible,
|
|
30
|
-
options,
|
|
31
|
-
values,
|
|
32
|
-
onChange,
|
|
33
|
-
defaultVisibleCount,
|
|
34
|
-
showLabel,
|
|
35
|
-
hideLabel,
|
|
36
|
-
alignedGroup,
|
|
37
|
-
collapseMobile,
|
|
38
|
-
} = this.props;
|
|
39
|
-
|
|
40
|
-
const showAll = defaultVisibleCount === null || options.length <= defaultVisibleCount;
|
|
41
|
-
const labelModifiers = [];
|
|
42
|
-
|
|
43
|
-
if (labelNotVisible) {
|
|
44
|
-
labelModifiers.push('hidden');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<section {...classes('list', modifiers)}>
|
|
49
|
-
{label && <h1 {...classes('label', labelModifiers)}>{label}</h1>}
|
|
50
|
-
{this.props.noFilterSelectedLabel && options.length === 0 && (
|
|
51
|
-
<span {...classes('no-filter-selected')}>{this.props.noFilterSelectedLabel}</span>
|
|
52
|
-
)}
|
|
53
|
-
<ul
|
|
54
|
-
{...classes('item-wrapper', {
|
|
55
|
-
'aligned-grouping': alignedGroup,
|
|
56
|
-
'collapse-mobile': collapseMobile,
|
|
57
|
-
})}>
|
|
58
|
-
{options.map((option, index) => {
|
|
59
|
-
const itemModifiers = [];
|
|
60
|
-
|
|
61
|
-
const checked = values.some((value) => value === option.value);
|
|
62
|
-
|
|
63
|
-
if (!showAll && !checked && index + 1 > this.state.visibleCount) {
|
|
64
|
-
itemModifiers.push('hidden');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const disabled = option.noResults || option.hits === 0;
|
|
68
|
-
|
|
69
|
-
if (disabled) {
|
|
70
|
-
itemModifiers.push('no-results');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<ToggleItem
|
|
75
|
-
modifiers={itemModifiers}
|
|
76
|
-
id={preid + option.value}
|
|
77
|
-
key={option.value}
|
|
78
|
-
value={option.value}
|
|
79
|
-
disabled={disabled}
|
|
80
|
-
tabIndex={disabled ? -1 : 0}
|
|
81
|
-
checked={checked}
|
|
82
|
-
icon={option.icon}
|
|
83
|
-
label={option.title}
|
|
84
|
-
onChange={(event) => {
|
|
85
|
-
let newValues = null;
|
|
86
|
-
if (event.currentTarget.checked) {
|
|
87
|
-
newValues = [...values, option.value];
|
|
88
|
-
} else {
|
|
89
|
-
newValues = values.filter((value) => value !== option.value);
|
|
90
|
-
}
|
|
91
|
-
if (onChange) {
|
|
92
|
-
onChange(newValues, option.value);
|
|
93
|
-
}
|
|
94
|
-
}}
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
97
|
-
})}
|
|
98
|
-
</ul>
|
|
99
|
-
{!showAll && (
|
|
100
|
-
<button
|
|
101
|
-
{...classes('expand')}
|
|
102
|
-
type="button"
|
|
103
|
-
onClick={() => {
|
|
104
|
-
this.setState((prevState) => {
|
|
105
|
-
if (prevState.visibleCount === defaultVisibleCount) {
|
|
106
|
-
return {
|
|
107
|
-
visibleCount: options.length,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
visibleCount: defaultVisibleCount,
|
|
113
|
-
};
|
|
114
|
-
});
|
|
115
|
-
}}>
|
|
116
|
-
{this.state.visibleCount === defaultVisibleCount ? (
|
|
117
|
-
<Fragment>
|
|
118
|
-
<span>{showLabel}</span> <ChevronDown />
|
|
119
|
-
</Fragment>
|
|
120
|
-
) : (
|
|
121
|
-
<Fragment>
|
|
122
|
-
<span>{hideLabel}</span> <ChevronUp />
|
|
123
|
-
</Fragment>
|
|
124
|
-
)}
|
|
125
|
-
</button>
|
|
126
|
-
)}
|
|
127
|
-
</section>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const valueShape = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
|
133
|
-
|
|
134
|
-
FilterList.propTypes = {
|
|
135
|
-
children: PropTypes.node,
|
|
136
|
-
label: PropTypes.string,
|
|
137
|
-
preid: PropTypes.string,
|
|
138
|
-
labelNotVisible: PropTypes.bool,
|
|
139
|
-
modifiers: PropTypes.string,
|
|
140
|
-
onChange: PropTypes.func, // isRequired
|
|
141
|
-
options: PropTypes.arrayOf(
|
|
142
|
-
PropTypes.shape({
|
|
143
|
-
title: PropTypes.string.isRequired,
|
|
144
|
-
value: valueShape.isRequired,
|
|
145
|
-
hits: PropTypes.number,
|
|
146
|
-
icon: PropTypes.func,
|
|
147
|
-
noResults: PropTypes.bool,
|
|
148
|
-
}),
|
|
149
|
-
).isRequired,
|
|
150
|
-
values: PropTypes.arrayOf(valueShape),
|
|
151
|
-
defaultVisibleCount: PropTypes.number,
|
|
152
|
-
showLabel: PropTypes.string,
|
|
153
|
-
noFilterSelectedLabel: PropTypes.string,
|
|
154
|
-
hideLabel: PropTypes.string,
|
|
155
|
-
alignedGroup: PropTypes.bool,
|
|
156
|
-
collapseMobile: PropTypes.bool,
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
FilterList.defaultProps = {
|
|
160
|
-
label: 'FILTER:',
|
|
161
|
-
preid: '',
|
|
162
|
-
modifiers: '',
|
|
163
|
-
values: [],
|
|
164
|
-
defaultVisibleCount: null,
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export default FilterList;
|