@ndla/ui 23.0.0 → 24.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/ArticleAuthorContent.js +2 -4
- package/es/AuthorInfo/AuthorInfo.js +29 -16
- package/es/ContentCard/ContentCard.js +66 -25
- package/es/FileList/File.js +34 -8
- package/es/FileList/FileList.js +29 -3
- package/es/InfoBox/InfoBox.js +10 -3
- package/es/InfoWidget/InfoWidget.js +67 -22
- package/es/Portrait/Portrait.js +19 -13
- package/es/Search/ActiveFilterContent.js +4 -14
- package/es/Search/ActiveFilters.js +8 -19
- package/es/Search/SearchField.js +31 -52
- package/es/Search/SearchResult.js +113 -136
- package/es/Search/ToggleSearchButton.js +34 -43
- package/es/Search/index.js +2 -8
- package/es/all.css +1 -1
- package/es/index-javascript.js +0 -1
- package/es/index.js +2 -1
- package/lib/Article/ArticleAuthorContent.js +9 -4
- package/lib/AuthorInfo/AuthorInfo.d.ts +1 -11
- package/lib/AuthorInfo/AuthorInfo.js +36 -20
- package/lib/ContentCard/ContentCard.d.ts +1 -15
- package/lib/ContentCard/ContentCard.js +60 -28
- package/lib/FileList/File.js +36 -12
- package/lib/FileList/FileList.js +28 -5
- package/lib/InfoBox/InfoBox.js +11 -4
- package/lib/InfoWidget/InfoWidget.js +61 -25
- package/lib/Portrait/Portrait.js +19 -14
- package/lib/Search/ActiveFilterContent.d.ts +13 -0
- package/lib/Search/ActiveFilterContent.js +4 -15
- package/lib/Search/ActiveFilters.d.ts +13 -0
- package/lib/Search/ActiveFilters.js +8 -20
- package/lib/Search/SearchField.d.ts +19 -0
- package/lib/Search/SearchField.js +32 -56
- package/lib/Search/SearchResult.d.ts +36 -0
- package/lib/Search/SearchResult.js +116 -159
- package/lib/Search/ToggleSearchButton.d.ts +16 -0
- package/lib/Search/ToggleSearchButton.js +36 -46
- package/lib/Search/index.d.ts +12 -0
- package/lib/Search/index.js +0 -54
- package/lib/SearchTypeResult/SearchTypeHeader.d.ts +1 -1
- package/lib/all.css +1 -1
- package/lib/index-javascript.js +0 -74
- package/lib/index.d.ts +1 -0
- package/lib/index.js +38 -1
- package/package.json +5 -5
- package/src/Article/ArticleAuthorContent.tsx +1 -1
- package/src/AuthorInfo/AuthorInfo.tsx +53 -19
- package/src/ContentCard/ContentCard.tsx +127 -35
- package/src/FileList/File.tsx +47 -17
- package/src/FileList/FileList.tsx +37 -8
- package/src/InfoBox/InfoBox.tsx +24 -4
- package/src/InfoWidget/InfoWidget.tsx +83 -34
- package/src/Portrait/Portrait.tsx +25 -10
- package/src/Search/{ActiveFilterContent.jsx → ActiveFilterContent.tsx} +11 -12
- package/src/Search/{ActiveFilters.jsx → ActiveFilters.tsx} +20 -17
- package/src/Search/{SearchField.jsx → SearchField.tsx} +58 -68
- package/src/Search/SearchResult.tsx +360 -0
- package/src/Search/ToggleSearchButton.tsx +73 -0
- package/src/Search/component.search.scss +0 -4
- package/src/Search/index.ts +16 -0
- package/src/all.scss +0 -1
- package/src/index-javascript.js +0 -15
- package/src/index.ts +2 -0
- package/src/main.scss +0 -6
- package/es/Search/SearchFilter.js +0 -72
- package/es/Search/SearchFilterList.js +0 -115
- package/es/Search/SearchOverlay.js +0 -39
- package/es/Search/SearchPage.js +0 -178
- package/es/Search/SearchPopoverFilter.js +0 -152
- package/es/Search/SearchResultAuthor.js +0 -51
- package/lib/Search/SearchFilter.js +0 -88
- package/lib/Search/SearchFilterList.js +0 -137
- package/lib/Search/SearchOverlay.js +0 -62
- package/lib/Search/SearchPage.js +0 -207
- package/lib/Search/SearchPopoverFilter.js +0 -172
- package/lib/Search/SearchResultAuthor.js +0 -60
- package/src/AuthorInfo/component.author-info.scss +0 -54
- package/src/ContentCard/component.content-card.scss +0 -109
- package/src/FileList/component.file-list.scss +0 -102
- package/src/InfoBox/component.info-box.scss +0 -21
- package/src/InfoWidget/component.info-widget.scss +0 -52
- package/src/Portrait/component.portrait.scss +0 -29
- package/src/Search/SearchFilter.jsx +0 -82
- package/src/Search/SearchFilterList.jsx +0 -110
- package/src/Search/SearchOverlay.jsx +0 -38
- package/src/Search/SearchPage.jsx +0 -178
- package/src/Search/SearchPopoverFilter.jsx +0 -109
- package/src/Search/SearchResult.jsx +0 -239
- package/src/Search/SearchResultAuthor.jsx +0 -54
- package/src/Search/ToggleSearchButton.jsx +0 -64
- package/src/Search/component.search-filter.scss +0 -67
- package/src/Search/component.search-overlay.scss +0 -103
- package/src/Search/component.search-page.scss +0 -125
- package/src/Search/component.search-result-author.scss +0 -65
- package/src/Search/index.js +0 -34
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/no-multi-comp */
|
|
2
|
-
|
|
3
|
-
import React, { Fragment, Component } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import BEMHelper from 'react-bem-helper';
|
|
6
|
-
import { ChevronRight } from '@ndla/icons/common';
|
|
7
|
-
import Modal, { ModalCloseButton, ModalHeader, ModalBody } from '@ndla/modal';
|
|
8
|
-
import Button from '@ndla/button';
|
|
9
|
-
import { FilterList } from '../Filter';
|
|
10
|
-
|
|
11
|
-
const filterClasses = new BEMHelper({
|
|
12
|
-
name: 'filter',
|
|
13
|
-
prefix: 'c-',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const messagesShape = PropTypes.shape({
|
|
17
|
-
backButton: PropTypes.string.isRequired,
|
|
18
|
-
closeButton: PropTypes.string.isRequired,
|
|
19
|
-
confirmButton: PropTypes.string.isRequired,
|
|
20
|
-
filterLabel: PropTypes.string.isRequired,
|
|
21
|
-
hasValuesButtonText: PropTypes.string.isRequired,
|
|
22
|
-
noValuesButtonText: PropTypes.string.isRequired,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
class Popover extends Component {
|
|
26
|
-
constructor(props) {
|
|
27
|
-
super(props);
|
|
28
|
-
this.state = {
|
|
29
|
-
values: props.values,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
const { messages, close, options, onChange } = this.props;
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Fragment>
|
|
38
|
-
<FilterList
|
|
39
|
-
preid="search-popover"
|
|
40
|
-
options={options}
|
|
41
|
-
label={messages.filterLabel}
|
|
42
|
-
values={this.state.values}
|
|
43
|
-
modifiers="search-popover"
|
|
44
|
-
onChange={(values) => {
|
|
45
|
-
this.setState({
|
|
46
|
-
values,
|
|
47
|
-
});
|
|
48
|
-
}}
|
|
49
|
-
/>
|
|
50
|
-
<div {...filterClasses('usefilter-wrapper')}>
|
|
51
|
-
<Button
|
|
52
|
-
outline
|
|
53
|
-
onClick={() => {
|
|
54
|
-
close();
|
|
55
|
-
onChange(this.state.values);
|
|
56
|
-
}}>
|
|
57
|
-
{messages.confirmButton}
|
|
58
|
-
</Button>
|
|
59
|
-
</div>
|
|
60
|
-
</Fragment>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
Popover.propTypes = {
|
|
66
|
-
messages: messagesShape.isRequired,
|
|
67
|
-
close: PropTypes.func,
|
|
68
|
-
values: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
69
|
-
options: PropTypes.arrayOf(
|
|
70
|
-
PropTypes.shape({
|
|
71
|
-
title: PropTypes.string.isRequired,
|
|
72
|
-
value: PropTypes.string.isRequired,
|
|
73
|
-
}),
|
|
74
|
-
).isRequired,
|
|
75
|
-
onChange: PropTypes.func.isRequired,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const PopoverFilter = ({ messages, values, onChange, ...rest }) => {
|
|
79
|
-
const buttonText = values.length > 0 ? messages.hasValuesButtonText : messages.noValuesButtonText;
|
|
80
|
-
|
|
81
|
-
const buttonContent = (
|
|
82
|
-
<button type="button" {...filterClasses('expand')}>
|
|
83
|
-
<span>{buttonText}</span>
|
|
84
|
-
<ChevronRight />
|
|
85
|
-
</button>
|
|
86
|
-
);
|
|
87
|
-
return (
|
|
88
|
-
<Modal animation="slide-up" size="medium" activateButton={buttonContent}>
|
|
89
|
-
{(onClose) => (
|
|
90
|
-
<Fragment>
|
|
91
|
-
<ModalHeader modifiers="white">
|
|
92
|
-
<ModalCloseButton title="Lukk" onClick={onClose} />
|
|
93
|
-
</ModalHeader>
|
|
94
|
-
<ModalBody modifier="no-side-padding-mobile">
|
|
95
|
-
<Popover close={onClose} onChange={onChange} messages={messages} {...rest} values={values} />
|
|
96
|
-
</ModalBody>
|
|
97
|
-
</Fragment>
|
|
98
|
-
)}
|
|
99
|
-
</Modal>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
PopoverFilter.propTypes = {
|
|
104
|
-
values: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
105
|
-
messages: messagesShape.isRequired,
|
|
106
|
-
onChange: PropTypes.func.isRequired,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export default PopoverFilter;
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import BEMHelper from 'react-bem-helper';
|
|
4
|
-
import { ChevronRight } from '@ndla/icons/common';
|
|
5
|
-
import { Cross } from '@ndla/icons/action';
|
|
6
|
-
import { uuid } from '@ndla/util';
|
|
7
|
-
import { useTranslation } from 'react-i18next';
|
|
8
|
-
import Button from '@ndla/button';
|
|
9
|
-
import { FilterTabs } from '@ndla/tabs';
|
|
10
|
-
import Tooltip from '@ndla/tooltip';
|
|
11
|
-
import SafeLink from '@ndla/safelink';
|
|
12
|
-
import { Spinner } from '@ndla/icons';
|
|
13
|
-
|
|
14
|
-
const resultClasses = BEMHelper('c-search-result');
|
|
15
|
-
|
|
16
|
-
export const SearchResult = ({
|
|
17
|
-
tabOptions,
|
|
18
|
-
children,
|
|
19
|
-
messages,
|
|
20
|
-
searchString,
|
|
21
|
-
currentTab,
|
|
22
|
-
onTabChange,
|
|
23
|
-
author,
|
|
24
|
-
currentCompetenceGoal,
|
|
25
|
-
competenceGoalsOpen,
|
|
26
|
-
onToggleCompetenceGoals,
|
|
27
|
-
competenceGoals,
|
|
28
|
-
hideResultText,
|
|
29
|
-
}) => {
|
|
30
|
-
const { t } = useTranslation();
|
|
31
|
-
return (
|
|
32
|
-
<Fragment>
|
|
33
|
-
<h2 {...resultClasses('result-label')}>{!hideResultText ? messages.resultHeading : '\u00A0'}</h2>
|
|
34
|
-
|
|
35
|
-
<div {...resultClasses()}>
|
|
36
|
-
{author || (
|
|
37
|
-
<div {...resultClasses('heading-wrapper')}>
|
|
38
|
-
<h1 {...resultClasses('heading', currentCompetenceGoal ? 'competence-goal' : null)}>
|
|
39
|
-
{messages.searchStringLabel} <span>{searchString}</span>
|
|
40
|
-
</h1>
|
|
41
|
-
{competenceGoalsOpen && (
|
|
42
|
-
<Button link {...resultClasses('close-competencegoals-btn')} onClick={onToggleCompetenceGoals}>
|
|
43
|
-
{t('competenceGoals.closeCompetenceGoals')}
|
|
44
|
-
<Cross className="c-icon--22 u-margin-left-tiny" />
|
|
45
|
-
</Button>
|
|
46
|
-
)}
|
|
47
|
-
</div>
|
|
48
|
-
)}
|
|
49
|
-
<h2>{messages.subHeading}</h2>
|
|
50
|
-
{!competenceGoalsOpen && currentCompetenceGoal && (
|
|
51
|
-
<ul {...resultClasses('current-goal')}>
|
|
52
|
-
<li>{currentCompetenceGoal}</li>
|
|
53
|
-
</ul>
|
|
54
|
-
)}
|
|
55
|
-
{!competenceGoalsOpen && competenceGoals && (
|
|
56
|
-
<p {...resultClasses('current-goal-info')}>
|
|
57
|
-
{messages.openCompetenceGoalsButtonPrefix}{' '}
|
|
58
|
-
<Button link onClick={onToggleCompetenceGoals}>
|
|
59
|
-
{messages.openCompetenceGoalsButton}
|
|
60
|
-
</Button>
|
|
61
|
-
</p>
|
|
62
|
-
)}
|
|
63
|
-
{competenceGoalsOpen && <div {...resultClasses('competence-goals')}>{competenceGoals}</div>}
|
|
64
|
-
{!competenceGoalsOpen && (
|
|
65
|
-
<Fragment>
|
|
66
|
-
<FilterTabs
|
|
67
|
-
dropdownBtnLabel={t('searchPage.searchPageMessages.dropdownBtnLabel')}
|
|
68
|
-
value={currentTab}
|
|
69
|
-
options={tabOptions}
|
|
70
|
-
contentId="search-result-content"
|
|
71
|
-
onChange={onTabChange}>
|
|
72
|
-
{children}
|
|
73
|
-
</FilterTabs>
|
|
74
|
-
<div {...resultClasses('narrow-result')}>{children}</div>
|
|
75
|
-
</Fragment>
|
|
76
|
-
)}
|
|
77
|
-
</div>
|
|
78
|
-
</Fragment>
|
|
79
|
-
);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
SearchResult.propTypes = {
|
|
83
|
-
hideResultText: PropTypes.bool,
|
|
84
|
-
tabOptions: PropTypes.arrayOf(
|
|
85
|
-
PropTypes.shape({
|
|
86
|
-
title: PropTypes.string.isRequired,
|
|
87
|
-
value: PropTypes.string.isRequired,
|
|
88
|
-
}),
|
|
89
|
-
).isRequired,
|
|
90
|
-
currentTab: PropTypes.string,
|
|
91
|
-
children: PropTypes.node.isRequired,
|
|
92
|
-
messages: PropTypes.shape({
|
|
93
|
-
searchStringLabel: PropTypes.string.isRequired,
|
|
94
|
-
subHeading: PropTypes.string.isRequired,
|
|
95
|
-
openCompetenceGoalsButtonPrefix: PropTypes.string,
|
|
96
|
-
openCompetenceGoalsButton: PropTypes.string,
|
|
97
|
-
}).isRequired,
|
|
98
|
-
currentCompetenceGoal: PropTypes.string,
|
|
99
|
-
competenceGoalsOpen: PropTypes.bool,
|
|
100
|
-
onToggleCompetenceGoals: PropTypes.func,
|
|
101
|
-
competenceGoals: PropTypes.node,
|
|
102
|
-
searchString: (props, propName, componentName) => {
|
|
103
|
-
if (props.author === null && typeof props[propName] !== 'string') {
|
|
104
|
-
return new Error(
|
|
105
|
-
`Invalid prop 'searchString' in ${componentName}. Required unless props.author === PropTypes.node`,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
},
|
|
110
|
-
onTabChange: PropTypes.func.isRequired,
|
|
111
|
-
author: PropTypes.node,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
SearchResult.defaultProps = {
|
|
115
|
-
author: null,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const searchResultItemClasses = BEMHelper('c-search-result-item');
|
|
119
|
-
|
|
120
|
-
const searchResultItemShape = PropTypes.shape({
|
|
121
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
122
|
-
title: PropTypes.string.isRequired,
|
|
123
|
-
url: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
|
|
124
|
-
breadcrumb: PropTypes.arrayOf(PropTypes.string),
|
|
125
|
-
subjects: PropTypes.arrayOf(
|
|
126
|
-
PropTypes.shape({
|
|
127
|
-
title: PropTypes.string.isRequired,
|
|
128
|
-
url: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
|
|
129
|
-
}),
|
|
130
|
-
),
|
|
131
|
-
additional: PropTypes.bool,
|
|
132
|
-
image: PropTypes.node,
|
|
133
|
-
ingress: PropTypes.string.isRequired,
|
|
134
|
-
contentTypeIcon: PropTypes.node.isRequired,
|
|
135
|
-
contentTypeLabel: PropTypes.string.isRequired,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
export const SearchResultItem = ({ item, subjectsLabel, additionalContentToolip, children }) => {
|
|
139
|
-
const itemBreadcrumb = (item, cssClasses = {}) => {
|
|
140
|
-
if (item.breadcrumb?.length > 0) {
|
|
141
|
-
return (
|
|
142
|
-
<div {...cssClasses}>
|
|
143
|
-
{item.breadcrumb.map((breadcrumbItem, index) => {
|
|
144
|
-
let icon = null;
|
|
145
|
-
if (index !== item.breadcrumb.length - 1) {
|
|
146
|
-
icon = <ChevronRight />;
|
|
147
|
-
}
|
|
148
|
-
return (
|
|
149
|
-
<Fragment key={uuid()}>
|
|
150
|
-
<span>{breadcrumbItem}</span>
|
|
151
|
-
{icon}
|
|
152
|
-
</Fragment>
|
|
153
|
-
);
|
|
154
|
-
})}
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
return (
|
|
160
|
-
<li key={item.id} {...searchResultItemClasses()}>
|
|
161
|
-
<article>
|
|
162
|
-
<header {...searchResultItemClasses('header')}>
|
|
163
|
-
<h1>{item.url.href ? <a {...item.url}>{item.title}</a> : <SafeLink to={item.url}>{item.title}</SafeLink>}</h1>
|
|
164
|
-
<div {...searchResultItemClasses('content-type-wrapper')}>{item.contentTypeIcon}</div>
|
|
165
|
-
{item.contentTypeLabel && <div {...searchResultItemClasses('pills')}>{item.contentTypeLabel}</div>}
|
|
166
|
-
{item.type && <div {...searchResultItemClasses('pills')}>{item.type}</div>}
|
|
167
|
-
{item.additional && <div {...searchResultItemClasses('pills')}>{additionalContentToolip}</div>}
|
|
168
|
-
{children}
|
|
169
|
-
</header>
|
|
170
|
-
<div {...searchResultItemClasses('content')}>
|
|
171
|
-
<p {...searchResultItemClasses('ingress')} dangerouslySetInnerHTML={{ __html: item.ingress }} />
|
|
172
|
-
{item.image}
|
|
173
|
-
</div>
|
|
174
|
-
{(!item.subjects || item.subjects.length === 0) && itemBreadcrumb(item, searchResultItemClasses('breadcrumb'))}
|
|
175
|
-
{item.subjects && item.subjects.length !== 0 && (
|
|
176
|
-
<div {...searchResultItemClasses('subjects')}>
|
|
177
|
-
<span>{subjectsLabel}</span>
|
|
178
|
-
<ul>
|
|
179
|
-
{item.subjects.map((subject) => (
|
|
180
|
-
<li key={uuid()}>
|
|
181
|
-
<Tooltip tooltip={itemBreadcrumb(subject)}>
|
|
182
|
-
{subject.url.href ? (
|
|
183
|
-
<a {...subject.url}>{subject.title}</a>
|
|
184
|
-
) : (
|
|
185
|
-
<SafeLink to={subject.url}>{subject.title}</SafeLink>
|
|
186
|
-
)}
|
|
187
|
-
</Tooltip>
|
|
188
|
-
</li>
|
|
189
|
-
))}
|
|
190
|
-
</ul>
|
|
191
|
-
</div>
|
|
192
|
-
)}
|
|
193
|
-
</article>
|
|
194
|
-
</li>
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
SearchResultItem.propTypes = {
|
|
199
|
-
item: searchResultItemShape.isRequired,
|
|
200
|
-
additionalContentToolip: PropTypes.string.isRequired,
|
|
201
|
-
subjectsLabel: PropTypes.string.isRequired,
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export const SearchResultList = ({ results, component: Component, loading }) => {
|
|
205
|
-
const { t } = useTranslation();
|
|
206
|
-
if (loading) {
|
|
207
|
-
return <Spinner />;
|
|
208
|
-
}
|
|
209
|
-
if (!results) {
|
|
210
|
-
return <article className="c-search-result-list__empty" />;
|
|
211
|
-
}
|
|
212
|
-
return results.length === 0 ? (
|
|
213
|
-
<article className="c-search-result-list__empty">
|
|
214
|
-
<h1>{t('searchPage.searchResultListMessages.noResultHeading')}</h1>
|
|
215
|
-
<p>{t('searchPage.searchResultListMessages.noResultDescription')}</p>
|
|
216
|
-
</article>
|
|
217
|
-
) : (
|
|
218
|
-
<ul className="c-search-result-list">
|
|
219
|
-
{results.map((item) => (
|
|
220
|
-
<Component
|
|
221
|
-
key={`search_result_item_${typeof item.url === 'object' ? item.url.href : item.url}`}
|
|
222
|
-
item={item}
|
|
223
|
-
additionalContentToolip={t('resource.tooltipAdditionalTopic')}
|
|
224
|
-
subjectsLabel={t('searchPage.searchResultListMessages.subjectsLabel')}>
|
|
225
|
-
{item.children}
|
|
226
|
-
</Component>
|
|
227
|
-
))}
|
|
228
|
-
</ul>
|
|
229
|
-
);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
SearchResultList.defaultProps = {
|
|
233
|
-
component: SearchResultItem,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
SearchResultList.propTypes = {
|
|
237
|
-
results: PropTypes.arrayOf(searchResultItemShape),
|
|
238
|
-
loading: PropTypes.bool,
|
|
239
|
-
};
|
|
@@ -1,54 +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
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import BEMHelper from 'react-bem-helper';
|
|
12
|
-
import SafeLink from '@ndla/safelink';
|
|
13
|
-
import Portrait from '../Portrait';
|
|
14
|
-
|
|
15
|
-
const classes = new BEMHelper('c-search-result-author');
|
|
16
|
-
|
|
17
|
-
const SearchResultAuthor = ({ messages, url, image, modifier }) => (
|
|
18
|
-
<div {...classes('', modifier)}>
|
|
19
|
-
<div>
|
|
20
|
-
<h1 {...classes('heading')}>{messages.authorName}</h1>
|
|
21
|
-
<p>{messages.role}</p>
|
|
22
|
-
<p>{messages.phone}</p>
|
|
23
|
-
<div {...classes('links')}>
|
|
24
|
-
{messages.email && <SafeLink to={`mailto:${messages.email}`}>{messages.email}</SafeLink>}
|
|
25
|
-
{url && (
|
|
26
|
-
<SafeLink to={url} {...classes('url')}>
|
|
27
|
-
{messages.readmoreLabel}
|
|
28
|
-
</SafeLink>
|
|
29
|
-
)}
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
<Portrait src={image} alt={messages.authorName} {...classes('portrait-image')} />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
SearchResultAuthor.propTypes = {
|
|
37
|
-
messages: PropTypes.shape({
|
|
38
|
-
authorName: PropTypes.string.isRequired,
|
|
39
|
-
role: PropTypes.string.isRequired,
|
|
40
|
-
phone: PropTypes.string,
|
|
41
|
-
email: PropTypes.string,
|
|
42
|
-
readmoreLabel: (props, propName, componentName) => {
|
|
43
|
-
if (typeof props.url === 'string' && typeof props[propName] !== 'string') {
|
|
44
|
-
return new Error(`${componentName} messages.readmoreLabel is required when propTypes.url`);
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
image: PropTypes.string.isRequired,
|
|
50
|
-
url: PropTypes.string,
|
|
51
|
-
modifier: PropTypes.oneOf(['desktop', 'tablet']).isRequired,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default SearchResultAuthor;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2018-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
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import { css } from '@emotion/core';
|
|
12
|
-
import { spacing, spacingUnit, breakpoints, mq, misc, fonts, colors } from '@ndla/core';
|
|
13
|
-
import { Search } from '@ndla/icons/common';
|
|
14
|
-
import Button from '@ndla/button';
|
|
15
|
-
|
|
16
|
-
const style = (hideOnNarrowScreen, hideOnWideScreen, ndlaFilm) => css`
|
|
17
|
-
background: ${ndlaFilm ? colors.ndlaFilm.filmColorBright : colors.brand.greyLighter};
|
|
18
|
-
border-radius: ${misc.borderRadius};
|
|
19
|
-
border: 0;
|
|
20
|
-
display: flex;
|
|
21
|
-
color: ${ndlaFilm ? '#fff' : colors.brand.primary};
|
|
22
|
-
padding: ${spacing.small} ${spacingUnit * 0.75}px ${spacing.small} ${spacing.normal};
|
|
23
|
-
${hideOnNarrowScreen &&
|
|
24
|
-
css`
|
|
25
|
-
display: none;
|
|
26
|
-
`}
|
|
27
|
-
|
|
28
|
-
align-items: center;
|
|
29
|
-
margin-left: ${spacing.normal};
|
|
30
|
-
|
|
31
|
-
.c-icon {
|
|
32
|
-
height: 24px;
|
|
33
|
-
width: 24px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
${fonts.sizes('16px', '32px')};
|
|
37
|
-
|
|
38
|
-
${mq.range({ from: breakpoints.desktop })} {
|
|
39
|
-
display: ${hideOnWideScreen ? 'none' : 'flex'};
|
|
40
|
-
margin-right: ${spacing.medium};
|
|
41
|
-
padding: ${spacing.small} ${spacing.normal};
|
|
42
|
-
}
|
|
43
|
-
&:hover,
|
|
44
|
-
&:focus,
|
|
45
|
-
&:active {
|
|
46
|
-
border: 0;
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
const ToggleSearchButton = ({ children, ndlaFilm, hideOnNarrowScreen, hideOnWideScreen, ...rest }) => (
|
|
51
|
-
<Button type="button" css={style(hideOnNarrowScreen, hideOnWideScreen, ndlaFilm)} {...rest}>
|
|
52
|
-
<span css={{ marginRight: spacing.normal, fontWeight: fonts.weight.normal }}>{children}</span>
|
|
53
|
-
<Search />
|
|
54
|
-
</Button>
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
ToggleSearchButton.propTypes = {
|
|
58
|
-
children: PropTypes.node.isRequired,
|
|
59
|
-
hideOnNarrowScreen: PropTypes.bool,
|
|
60
|
-
hideOnWideScreen: PropTypes.bool,
|
|
61
|
-
ndlaFilm: PropTypes.bool,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default ToggleSearchButton;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
.c-search-filter {
|
|
2
|
-
@include mq(mobileWide) {
|
|
3
|
-
+ .c-search-filter {
|
|
4
|
-
margin-top: $spacing--medium;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
width: 100%;
|
|
9
|
-
text-align: left;
|
|
10
|
-
|
|
11
|
-
&--narrow-screen-only {
|
|
12
|
-
@include mq(desktop) {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@include mq(desktop) {
|
|
18
|
-
padding: $spacing;
|
|
19
|
-
background: $white;
|
|
20
|
-
border: none;
|
|
21
|
-
margin-bottom: $spacing--small;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&--context-filter {
|
|
25
|
-
background: $brand-color--light;
|
|
26
|
-
padding: $spacing--medium;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&:first-child {
|
|
30
|
-
.c-filter__list {
|
|
31
|
-
border-top: 0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@include mq($until: mobileWide) {
|
|
36
|
-
margin-bottom: $spacing;
|
|
37
|
-
|
|
38
|
-
.c-search-filter {
|
|
39
|
-
label {
|
|
40
|
-
padding-left: $spacing--large;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.c-filter__item {
|
|
45
|
-
width: 100%;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@include mq($from: mobileWide, $until: desktop) {
|
|
50
|
-
.c-search-filter {
|
|
51
|
-
+ .c-filter__item {
|
|
52
|
-
margin-top: $spacing;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.c-filter__item-wrapper {
|
|
56
|
-
padding-left: $spacing;
|
|
57
|
-
padding-top: $spacing--small;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@include mq(568px) {
|
|
63
|
-
.c-search-filter .c-filter__item {
|
|
64
|
-
width: 235px - $spacing;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
$overlay-height: 150px;
|
|
2
|
-
|
|
3
|
-
@keyframes searchAnimation {
|
|
4
|
-
0% {
|
|
5
|
-
display: none;
|
|
6
|
-
opacity: 0;
|
|
7
|
-
}
|
|
8
|
-
1% {
|
|
9
|
-
opacity: 0.3;
|
|
10
|
-
display: block;
|
|
11
|
-
top: 13px;
|
|
12
|
-
height: 58px;
|
|
13
|
-
left: calc(100% - 302px);
|
|
14
|
-
right: 302px;
|
|
15
|
-
}
|
|
16
|
-
100% {
|
|
17
|
-
opacity: 1;
|
|
18
|
-
height: $overlay-height;
|
|
19
|
-
top: 0;
|
|
20
|
-
left: 0;
|
|
21
|
-
right: 0;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@keyframes closeButton {
|
|
26
|
-
0% {
|
|
27
|
-
opacity: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
70% {
|
|
31
|
-
opacity: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
100% {
|
|
35
|
-
opacity: 1;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.c-search-overlay {
|
|
40
|
-
z-index: 1000;
|
|
41
|
-
height: $overlay-height;
|
|
42
|
-
background: $brand-grey--lighter;
|
|
43
|
-
position: fixed;
|
|
44
|
-
top: 0;
|
|
45
|
-
left: 0;
|
|
46
|
-
right: 0;
|
|
47
|
-
|
|
48
|
-
display: flex;
|
|
49
|
-
justify-content: space-between;
|
|
50
|
-
align-items: center;
|
|
51
|
-
|
|
52
|
-
&-enter {
|
|
53
|
-
opacity: 0.3;
|
|
54
|
-
top: 13px;
|
|
55
|
-
height: 58px;
|
|
56
|
-
left: calc(100% - 302px);
|
|
57
|
-
right: 302px;
|
|
58
|
-
|
|
59
|
-
transition: all 0.3s ease;
|
|
60
|
-
|
|
61
|
-
&-active {
|
|
62
|
-
opacity: 1;
|
|
63
|
-
height: $overlay-height;
|
|
64
|
-
top: 0;
|
|
65
|
-
left: 0;
|
|
66
|
-
right: 0;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&-exit {
|
|
71
|
-
transition: all 0.3s ease;
|
|
72
|
-
|
|
73
|
-
&-active {
|
|
74
|
-
@extend .c-search-overlay-enter;
|
|
75
|
-
opacity: 0;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&__container {
|
|
80
|
-
padding: 0;
|
|
81
|
-
position: relative;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&__close-button {
|
|
85
|
-
position: absolute;
|
|
86
|
-
top: $spacing--small;
|
|
87
|
-
right: -($spacing--large + 36px);
|
|
88
|
-
width: 36px;
|
|
89
|
-
height: 36px;
|
|
90
|
-
color: $brand-color--dark;
|
|
91
|
-
background: none;
|
|
92
|
-
border: 0;
|
|
93
|
-
padding: 0;
|
|
94
|
-
cursor: pointer;
|
|
95
|
-
|
|
96
|
-
animation: closeButton 0.7s;
|
|
97
|
-
|
|
98
|
-
.c-icon {
|
|
99
|
-
width: 100%;
|
|
100
|
-
height: 100%;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|