@ndla/ui 4.1.3 → 4.2.1
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/Article.js +3 -9
- package/es/Article/ArticleByline.js +35 -32
- package/es/RelatedArticleList/RelatedArticleList.js +1 -1
- package/es/SearchTypeResult/SearchFieldHeader.js +14 -13
- package/es/SectionHeading/SectionHeading.js +3 -2
- package/es/locale/messages-en.js +2 -2
- package/lib/Article/Article.js +3 -9
- package/lib/Article/ArticleByline.js +35 -32
- package/lib/RelatedArticleList/RelatedArticleList.js +1 -1
- package/lib/SearchTypeResult/SearchFieldHeader.js +13 -13
- package/lib/SectionHeading/SectionHeading.js +3 -2
- package/lib/locale/messages-en.js +2 -2
- package/package.json +2 -2
- package/src/Article/Article.tsx +2 -6
- package/src/Article/ArticleByline.tsx +33 -26
- package/src/RelatedArticleList/RelatedArticleList.tsx +2 -2
- package/src/SearchTypeResult/SearchFieldHeader.tsx +7 -2
- package/src/SectionHeading/SectionHeading.tsx +5 -4
- package/src/locale/messages-en.ts +2 -2
|
@@ -15,6 +15,7 @@ import { copyTextToClipboard, printPage } from '@ndla/util';
|
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { LicenseByline } from '@ndla/licenses';
|
|
17
17
|
import { getLicenseByAbbreviation } from '@ndla/licenses';
|
|
18
|
+
import { TFunction } from 'i18next';
|
|
18
19
|
|
|
19
20
|
const Wrapper = styled.div`
|
|
20
21
|
margin-top: ${spacing.normal};
|
|
@@ -38,7 +39,7 @@ const ButtonWrapper = styled.div`
|
|
|
38
39
|
}
|
|
39
40
|
`;
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const PrimaryContributorsWrapper = styled.span`
|
|
42
43
|
margin-left: ${spacing.xxsmall};
|
|
43
44
|
`;
|
|
44
45
|
|
|
@@ -61,9 +62,27 @@ type Props = {
|
|
|
61
62
|
locale?: string;
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
const renderContributors = (contributors: SupplierProps[] | AuthorProps[], t: TFunction) => {
|
|
66
|
+
const contributorsArray = contributors.map((contributor, index) => {
|
|
67
|
+
if (index < 1) return contributor.name;
|
|
68
|
+
const sep = index === contributors.length - 1 ? ` ${t('article.conjunction')} ` : ', ';
|
|
69
|
+
return `${sep}${contributor.name}`;
|
|
70
|
+
});
|
|
71
|
+
return contributorsArray.join('');
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const getSuppliersText = (suppliers: SupplierProps[], t: TFunction) => {
|
|
75
|
+
if (suppliers.length === 0) {
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
return suppliers.length > 1
|
|
79
|
+
? t('article.multipleSuppliersLabel', { names: renderContributors(suppliers, t) })
|
|
80
|
+
: t('article.supplierLabel', { name: renderContributors(suppliers, t) });
|
|
81
|
+
};
|
|
82
|
+
|
|
64
83
|
const ArticleByline = ({
|
|
65
84
|
authors = [],
|
|
66
|
-
suppliers,
|
|
85
|
+
suppliers = [],
|
|
67
86
|
license,
|
|
68
87
|
licenseBox,
|
|
69
88
|
published,
|
|
@@ -78,42 +97,30 @@ const ArticleByline = ({
|
|
|
78
97
|
}
|
|
79
98
|
};
|
|
80
99
|
|
|
81
|
-
const renderContributors = (contributors: SupplierProps[] | AuthorProps[]) => {
|
|
82
|
-
const contributorsArray = contributors.map((contributor, index) => {
|
|
83
|
-
let separator = '';
|
|
84
|
-
if (index > 0) {
|
|
85
|
-
if (index === contributors.length - 1) {
|
|
86
|
-
separator = ` ${t('article.conjunction')} `;
|
|
87
|
-
} else {
|
|
88
|
-
separator = ', ';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return `${separator}${contributor.name}`;
|
|
92
|
-
});
|
|
93
|
-
return contributorsArray.join('');
|
|
94
|
-
};
|
|
95
100
|
const licenseRights = getLicenseByAbbreviation(license, locale).rights;
|
|
101
|
+
|
|
102
|
+
const showPrimaryContributors = suppliers.length > 0 || authors.length > 0;
|
|
103
|
+
const showSecondaryContributors = suppliers.length > 0 && authors.length > 0;
|
|
104
|
+
|
|
96
105
|
return (
|
|
97
106
|
<Wrapper>
|
|
98
107
|
<div>
|
|
99
108
|
{t('article.lastUpdated')} {published}
|
|
100
109
|
</div>
|
|
101
|
-
{(
|
|
110
|
+
{(showPrimaryContributors || licenseRights.length > 0) && (
|
|
102
111
|
<TextWrapper>
|
|
103
112
|
<LicenseByline licenseRights={licenseRights}>
|
|
104
|
-
{
|
|
105
|
-
<
|
|
113
|
+
{showPrimaryContributors && (
|
|
114
|
+
<PrimaryContributorsWrapper>
|
|
115
|
+
{authors.length > 0
|
|
116
|
+
? t('article.authorsLabel', { names: renderContributors(authors, t) })
|
|
117
|
+
: getSuppliersText(suppliers, t)}
|
|
118
|
+
</PrimaryContributorsWrapper>
|
|
106
119
|
)}
|
|
107
120
|
</LicenseByline>
|
|
108
121
|
</TextWrapper>
|
|
109
122
|
)}
|
|
110
|
-
{
|
|
111
|
-
<TextWrapper>
|
|
112
|
-
{suppliers.length > 1
|
|
113
|
-
? t('article.multipleSuppliersLabel', { names: renderContributors(suppliers) })
|
|
114
|
-
: t('article.supplierLabel', { name: renderContributors(suppliers) })}
|
|
115
|
-
</TextWrapper>
|
|
116
|
-
)}
|
|
123
|
+
{showSecondaryContributors && <TextWrapper>{getSuppliersText(suppliers, t)}</TextWrapper>}
|
|
117
124
|
<ButtonWrapper>
|
|
118
125
|
{licenseBox && (
|
|
119
126
|
<Modal
|
|
@@ -31,14 +31,14 @@ export const RelatedArticle = ({
|
|
|
31
31
|
const iconWithClass = cloneElement(icon, { className: 'c-icon--medium' });
|
|
32
32
|
return (
|
|
33
33
|
<article {...classes('item', modifier)}>
|
|
34
|
-
<
|
|
34
|
+
<h3 {...classes('title')}>
|
|
35
35
|
{iconWithClass}
|
|
36
36
|
<span {...classes('link-wrapper')}>
|
|
37
37
|
<SafeLink to={to} {...classes('link')} target={target} rel={linkInfo ? 'noopener noreferrer' : undefined}>
|
|
38
38
|
{title}
|
|
39
39
|
</SafeLink>
|
|
40
40
|
</span>
|
|
41
|
-
</
|
|
41
|
+
</h3>
|
|
42
42
|
<p {...classes('description')} dangerouslySetInnerHTML={{ __html: introduction }} />
|
|
43
43
|
{linkInfo && <p {...classes('link-info')}>{linkInfo}</p>}
|
|
44
44
|
</article>
|
|
@@ -73,6 +73,11 @@ const SearchInput = styled.input`
|
|
|
73
73
|
margin-left: 3px;
|
|
74
74
|
`;
|
|
75
75
|
|
|
76
|
+
const iconStyle = {
|
|
77
|
+
width: '24px',
|
|
78
|
+
height: '24px',
|
|
79
|
+
};
|
|
80
|
+
|
|
76
81
|
type Props = {
|
|
77
82
|
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
|
|
78
83
|
value?: string;
|
|
@@ -135,11 +140,11 @@ const SearchFieldHeader = ({ value, onSubmit, onChange, filters, activeFilters }
|
|
|
135
140
|
inputRef.current.focus();
|
|
136
141
|
}
|
|
137
142
|
}}>
|
|
138
|
-
<CrossIcon style={{
|
|
143
|
+
<CrossIcon style={iconStyle} title={t<string>('welcomePage.resetSearch')} />
|
|
139
144
|
</ClearButton>
|
|
140
145
|
)}
|
|
141
146
|
<SearchButton type="submit" value={t<string>('searchPage.search')}>
|
|
142
|
-
<SearchIcon style={{
|
|
147
|
+
<SearchIcon style={iconStyle} title={t<string>('searchPage.search')} />
|
|
143
148
|
</SearchButton>
|
|
144
149
|
</StyledForm>
|
|
145
150
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
1
|
+
import React, { ElementType, ReactNode } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import BEMHelper from 'react-bem-helper';
|
|
4
4
|
|
|
@@ -9,9 +9,10 @@ interface Props {
|
|
|
9
9
|
large?: boolean;
|
|
10
10
|
className?: string;
|
|
11
11
|
}
|
|
12
|
-
const SectionHeading = ({ children, large = false, className }: Props) =>
|
|
13
|
-
|
|
14
|
-
)
|
|
12
|
+
const SectionHeading = ({ children, large = false, className }: Props) => {
|
|
13
|
+
const Wrapper: ElementType = large ? 'h1' : 'h2';
|
|
14
|
+
return <Wrapper {...classes('', { large: !!large }, className)}>{children}</Wrapper>;
|
|
15
|
+
};
|
|
15
16
|
|
|
16
17
|
export default SectionHeading;
|
|
17
18
|
|
|
@@ -48,7 +48,7 @@ const messages = {
|
|
|
48
48
|
subjectCategories: {
|
|
49
49
|
[subjectCategories.ACTIVE_SUBJECTS]: 'Active',
|
|
50
50
|
[subjectCategories.ARCHIVE_SUBJECTS]: 'Expired',
|
|
51
|
-
[subjectCategories.BETA_SUBJECTS]: '
|
|
51
|
+
[subjectCategories.BETA_SUBJECTS]: 'Revised',
|
|
52
52
|
[subjectCategories.COMMON_SUBJECTS]: 'Common core subj.',
|
|
53
53
|
[subjectCategories.PROGRAMME_SUBJECTS]: 'Programme subj. SF',
|
|
54
54
|
[subjectCategories.SPECIALIZED_SUBJECTS]: 'Programme subj. YF',
|
|
@@ -328,7 +328,7 @@ const messages = {
|
|
|
328
328
|
newVersion:
|
|
329
329
|
'This learning resource is not updated to the current curriculum. You can find an updated version here: ',
|
|
330
330
|
frontPageBeta:
|
|
331
|
-
'
|
|
331
|
+
'Revised subjects have been revised in accordance with the new curriculum that will be put into effect from August 2022. Beta versions of subjects are subjects we are still working on. We hope, however, that the learning resources available by now may come in useful already.',
|
|
332
332
|
frontPageExpired:
|
|
333
333
|
'Expired subjects are not being taught any longer, but it may still be possible to take exams in these subjects.',
|
|
334
334
|
frontPageRevised:
|