@ndla/ui 8.0.1 → 8.1.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/BannerCard/BannerCard.js +75 -0
- package/es/BannerCard/index.js +9 -0
- package/es/ResourceBox/ResourceBox.js +154 -0
- package/es/ResourceBox/index.js +9 -0
- package/es/TopicMenu/TopicMenu.js +5 -2
- package/es/index.js +3 -1
- package/lib/BannerCard/BannerCard.d.ts +13 -0
- package/lib/BannerCard/BannerCard.js +85 -0
- package/lib/BannerCard/index.d.ts +9 -0
- package/lib/BannerCard/index.js +15 -0
- package/lib/ResourceBox/ResourceBox.d.ts +13 -0
- package/lib/ResourceBox/ResourceBox.js +154 -0
- package/lib/ResourceBox/index.d.ts +9 -0
- package/lib/ResourceBox/index.js +15 -0
- package/lib/TopicMenu/TopicMenu.js +5 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +19 -1
- package/package.json +3 -3
- package/src/BannerCard/BannerCard.tsx +99 -0
- package/src/BannerCard/index.ts +11 -0
- package/src/ResourceBox/ResourceBox.tsx +190 -0
- package/src/ResourceBox/index.ts +11 -0
- package/src/TopicMenu/TopicMenu.jsx +4 -1
- package/src/index.ts +3 -0
package/lib/index.js
CHANGED
|
@@ -92,6 +92,7 @@ var _exportNames = {
|
|
|
92
92
|
MessageBox: true,
|
|
93
93
|
MessageBoxTag: true,
|
|
94
94
|
MessageBoxType: true,
|
|
95
|
+
ResourceBox: true,
|
|
95
96
|
CloseButton: true,
|
|
96
97
|
AudioPlayer: true,
|
|
97
98
|
initAudioPlayers: true,
|
|
@@ -171,7 +172,8 @@ var _exportNames = {
|
|
|
171
172
|
CopyParagraphButton: true,
|
|
172
173
|
ContentPlaceholder: true,
|
|
173
174
|
Notion: true,
|
|
174
|
-
ConceptNotion: true
|
|
175
|
+
ConceptNotion: true,
|
|
176
|
+
BannerCard: true
|
|
175
177
|
};
|
|
176
178
|
Object.defineProperty(exports, "ArticleByline", {
|
|
177
179
|
enumerable: true,
|
|
@@ -689,6 +691,12 @@ Object.defineProperty(exports, "MessageBoxType", {
|
|
|
689
691
|
return _MessageBox.MessageBoxType;
|
|
690
692
|
}
|
|
691
693
|
});
|
|
694
|
+
Object.defineProperty(exports, "ResourceBox", {
|
|
695
|
+
enumerable: true,
|
|
696
|
+
get: function get() {
|
|
697
|
+
return _ResourceBox.ResourceBox;
|
|
698
|
+
}
|
|
699
|
+
});
|
|
692
700
|
Object.defineProperty(exports, "CloseButton", {
|
|
693
701
|
enumerable: true,
|
|
694
702
|
get: function get() {
|
|
@@ -1169,6 +1177,12 @@ Object.defineProperty(exports, "ConceptNotion", {
|
|
|
1169
1177
|
return _Notion.ConceptNotion;
|
|
1170
1178
|
}
|
|
1171
1179
|
});
|
|
1180
|
+
Object.defineProperty(exports, "BannerCard", {
|
|
1181
|
+
enumerable: true,
|
|
1182
|
+
get: function get() {
|
|
1183
|
+
return _BannerCard.BannerCard;
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1172
1186
|
|
|
1173
1187
|
var _indexJavascript = require("./index-javascript");
|
|
1174
1188
|
|
|
@@ -1251,6 +1265,8 @@ var _Breadcrumblist = _interopRequireDefault(require("./Breadcrumblist"));
|
|
|
1251
1265
|
|
|
1252
1266
|
var _MessageBox = require("./MessageBox");
|
|
1253
1267
|
|
|
1268
|
+
var _ResourceBox = require("./ResourceBox");
|
|
1269
|
+
|
|
1254
1270
|
var _CloseButton = _interopRequireDefault(require("./CloseButton"));
|
|
1255
1271
|
|
|
1256
1272
|
var _AudioPlayer = _interopRequireWildcard(require("./AudioPlayer"));
|
|
@@ -1309,6 +1325,8 @@ var _ContentPlaceholder = _interopRequireDefault(require("./ContentPlaceholder")
|
|
|
1309
1325
|
|
|
1310
1326
|
var _Notion = require("./Notion");
|
|
1311
1327
|
|
|
1328
|
+
var _BannerCard = require("./BannerCard");
|
|
1329
|
+
|
|
1312
1330
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
1313
1331
|
|
|
1314
1332
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@ndla/core": "^2.0.1",
|
|
37
37
|
"@ndla/hooks": "^1.1.2",
|
|
38
38
|
"@ndla/icons": "^1.6.1",
|
|
39
|
-
"@ndla/licenses": "^4.0.
|
|
39
|
+
"@ndla/licenses": "^4.0.3",
|
|
40
40
|
"@ndla/modal": "^1.2.3",
|
|
41
41
|
"@ndla/safelink": "^1.1.4",
|
|
42
42
|
"@ndla/switch": "^0.1.3",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "46dc3d930947a1a3102ce6b005d9aaffab2e2aa2"
|
|
86
86
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022-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
|
+
import React from 'react';
|
|
9
|
+
import { colors, fonts, breakpoints, mq } from '@ndla/core';
|
|
10
|
+
import SafeLink from '@ndla/safelink';
|
|
11
|
+
import styled from '@emotion/styled';
|
|
12
|
+
import { Image } from '..';
|
|
13
|
+
|
|
14
|
+
const BannerWrapper = styled.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: flex-start;
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
max-width: 669px;
|
|
19
|
+
border-radius: 8px;
|
|
20
|
+
border: 1px solid ${colors.brand.greyLight};
|
|
21
|
+
font-family: ${fonts.sans};
|
|
22
|
+
padding: 30px;
|
|
23
|
+
gap: 30px;
|
|
24
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const ImageWrapper = styled.div`
|
|
30
|
+
display: flex;
|
|
31
|
+
flex: 0 0 40%;
|
|
32
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
33
|
+
display: block;
|
|
34
|
+
text-align: center;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const StyledImage = styled(Image)`
|
|
40
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
41
|
+
max-height: 150px;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const TextWrapper = styled.div`
|
|
46
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
47
|
+
margin-left: 0;
|
|
48
|
+
margin-top: 10px;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const ContentText = styled.p`
|
|
53
|
+
font-size: ${fonts.sizes(16)};
|
|
54
|
+
color: ${colors.brand.grey};
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding-top: 10px;
|
|
57
|
+
padding-bottom: 10px;
|
|
58
|
+
`;
|
|
59
|
+
const LinkText = styled(SafeLink)`
|
|
60
|
+
font-size: ${fonts.sizes(16)};
|
|
61
|
+
color: ${colors.brand.grey};
|
|
62
|
+
`;
|
|
63
|
+
const TitleText = styled.h2`
|
|
64
|
+
margin-top: 7px;
|
|
65
|
+
font-size: ${fonts.sizes(22)};
|
|
66
|
+
${mq.range({ until: breakpoints.tabletWide })} {
|
|
67
|
+
margin-top: 0;
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
type ImageProps = {
|
|
72
|
+
altText: string;
|
|
73
|
+
imageSrc: string;
|
|
74
|
+
};
|
|
75
|
+
type BannerProps = {
|
|
76
|
+
link: string;
|
|
77
|
+
image: ImageProps;
|
|
78
|
+
title: string;
|
|
79
|
+
content: string;
|
|
80
|
+
linkText: string;
|
|
81
|
+
};
|
|
82
|
+
export const BannerCard = ({ link, title, content, linkText, image }: BannerProps) => {
|
|
83
|
+
return (
|
|
84
|
+
<BannerWrapper>
|
|
85
|
+
<ImageWrapper>
|
|
86
|
+
<StyledImage alt={image.altText} src={image.imageSrc} />
|
|
87
|
+
</ImageWrapper>
|
|
88
|
+
<TextWrapper>
|
|
89
|
+
<TitleText>{title}</TitleText>
|
|
90
|
+
<ContentText>{content}</ContentText>
|
|
91
|
+
<LinkText target="_self" to={link}>
|
|
92
|
+
{linkText}
|
|
93
|
+
</LinkText>
|
|
94
|
+
</TextWrapper>
|
|
95
|
+
</BannerWrapper>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default BannerCard;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2022-present, NDLA.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { breakpoints, fonts, mq, colors } from '@ndla/core';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { Launch } from '@ndla/icons/common';
|
|
13
|
+
import { LicenseByline } from '@ndla/licenses';
|
|
14
|
+
import { SafeLinkButton } from '@ndla/safelink';
|
|
15
|
+
import styled from '@emotion/styled';
|
|
16
|
+
import Image from '../Image';
|
|
17
|
+
|
|
18
|
+
const BoxWrapper = styled.div`
|
|
19
|
+
display: flex;
|
|
20
|
+
padding-top: 20px;
|
|
21
|
+
padding-bottom: 20px;
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
border: 1px solid ${colors.brand.light};
|
|
24
|
+
position: relative;
|
|
25
|
+
left: -16.6666666667%;
|
|
26
|
+
width: 133.3333333333%;
|
|
27
|
+
align-items: stretch;
|
|
28
|
+
margin-bottom: 24px;
|
|
29
|
+
font-family: ${fonts.sans};
|
|
30
|
+
box-shadow: 0px 20px 35px -15px rgba(32, 88, 143, 0.15);
|
|
31
|
+
gap: 40px;
|
|
32
|
+
|
|
33
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
34
|
+
gap: 1px;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
margin: 0 auto;
|
|
37
|
+
width: 80%;
|
|
38
|
+
left: 0;
|
|
39
|
+
padding-left: 24px;
|
|
40
|
+
padding-right: 24px;
|
|
41
|
+
padding-bottom: 0;
|
|
42
|
+
margin-bottom: 24px;
|
|
43
|
+
height: auto;
|
|
44
|
+
text-align: center;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const Boxtitle = styled.h3`
|
|
49
|
+
font-weight: ${fonts.weight.bold};
|
|
50
|
+
font-size: ${fonts.sizes(18)};
|
|
51
|
+
margin-top: 0;
|
|
52
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
53
|
+
text-align: center;
|
|
54
|
+
width: 100%;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
const Boxcaption = styled.p`
|
|
59
|
+
font-size: ${fonts.sizes(14)};
|
|
60
|
+
|
|
61
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
62
|
+
line-height: 22px;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
const StyledButtonDiv = styled.div`
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
69
|
+
padding-bottom: 10px;
|
|
70
|
+
margin: 0 auto;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
const ResourceBoxStyledButton = styled(SafeLinkButton)`
|
|
74
|
+
border: 1px solid ${colors.brand.tertiary};
|
|
75
|
+
:hover {
|
|
76
|
+
background-color: ${colors.brand.primary};
|
|
77
|
+
color: white;
|
|
78
|
+
}
|
|
79
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
80
|
+
width: 210px;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
const ResourceBoxLaunchIcon = styled(Launch)`
|
|
84
|
+
margin-left: 8px;
|
|
85
|
+
height: 15px;
|
|
86
|
+
width: 15px;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const BoxImage = styled(Image)`
|
|
90
|
+
object-fit: cover;
|
|
91
|
+
width: 134px;
|
|
92
|
+
height: 134px;
|
|
93
|
+
border-radius: 5px;
|
|
94
|
+
|
|
95
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
96
|
+
width: 200px;
|
|
97
|
+
height: 200px;
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
const ImageSectionWrapper = styled.div`
|
|
101
|
+
align-items: flex-start;
|
|
102
|
+
display: flex;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
margin-left: 20px;
|
|
105
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
106
|
+
margin: 0 auto;
|
|
107
|
+
padding-top: 10px;
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
const CaptionSectionWrapper = styled.div`
|
|
112
|
+
max-width: 600px;
|
|
113
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
114
|
+
margin: 0 auto;
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
const CenterItems = styled.div`
|
|
119
|
+
display: flex;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
align-items: flex-start;
|
|
122
|
+
flex-flow: column;
|
|
123
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
124
|
+
width: 100%;
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
const TitleAndLicence = styled.div`
|
|
129
|
+
display: flex;
|
|
130
|
+
justify-content: space-between;
|
|
131
|
+
${mq.range({ until: breakpoints.desktop })} {
|
|
132
|
+
text-align: center;
|
|
133
|
+
padding-top: 10px;
|
|
134
|
+
max-width: 200px;
|
|
135
|
+
margin: 0 auto;
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
const LincenseWrapper = styled.div`
|
|
140
|
+
top: 9px;
|
|
141
|
+
position: absolute;
|
|
142
|
+
right: 1px;
|
|
143
|
+
ul {
|
|
144
|
+
margin-right: 0;
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
type Props = {
|
|
149
|
+
image: string;
|
|
150
|
+
title: string;
|
|
151
|
+
caption: string;
|
|
152
|
+
licenseRights: string[];
|
|
153
|
+
authors?: { name: string }[];
|
|
154
|
+
locale?: string;
|
|
155
|
+
url: string;
|
|
156
|
+
};
|
|
157
|
+
export const ResourceBox = ({ image, title, caption, licenseRights, locale, authors, url }: Props) => {
|
|
158
|
+
const { t } = useTranslation();
|
|
159
|
+
return (
|
|
160
|
+
<BoxWrapper>
|
|
161
|
+
<ImageSectionWrapper>
|
|
162
|
+
<BoxImage alt={title} src={image} sizes="25, 25" />
|
|
163
|
+
</ImageSectionWrapper>
|
|
164
|
+
<CenterItems>
|
|
165
|
+
<CaptionSectionWrapper>
|
|
166
|
+
<TitleAndLicence>
|
|
167
|
+
<Boxtitle>{title}</Boxtitle>
|
|
168
|
+
<LincenseWrapper>
|
|
169
|
+
<LicenseByline licenseRights={licenseRights} locale={locale} marginRight color={colors.brand.tertiary}>
|
|
170
|
+
<div className="c-figure__byline-author-buttons">
|
|
171
|
+
<span className="c-figure__byline-authors">{authors?.map((author) => author.name).join(' ')}</span>
|
|
172
|
+
</div>
|
|
173
|
+
</LicenseByline>
|
|
174
|
+
</LincenseWrapper>
|
|
175
|
+
</TitleAndLicence>
|
|
176
|
+
<Boxcaption>{caption}</Boxcaption>
|
|
177
|
+
</CaptionSectionWrapper>
|
|
178
|
+
|
|
179
|
+
<StyledButtonDiv>
|
|
180
|
+
<ResourceBoxStyledButton to={url} target="_blank" outline borderShape="rounded">
|
|
181
|
+
{t('license.other.itemImage.ariaLabel')}
|
|
182
|
+
<ResourceBoxLaunchIcon aria-hidden />
|
|
183
|
+
</ResourceBoxStyledButton>
|
|
184
|
+
</StyledButtonDiv>
|
|
185
|
+
</CenterItems>
|
|
186
|
+
</BoxWrapper>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export default ResourceBox;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022-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 ResourceBox from './ResourceBox';
|
|
10
|
+
|
|
11
|
+
export { ResourceBox };
|
|
@@ -74,6 +74,8 @@ export const TopicMenu = ({
|
|
|
74
74
|
currentProgramme,
|
|
75
75
|
initialSelectedMenu,
|
|
76
76
|
messages,
|
|
77
|
+
selectedGrade,
|
|
78
|
+
onGradeChange,
|
|
77
79
|
}) => {
|
|
78
80
|
const { t } = useTranslation();
|
|
79
81
|
const [isNarrowScreen, setIsNarrowScreen] = useState(false);
|
|
@@ -242,7 +244,8 @@ export const TopicMenu = ({
|
|
|
242
244
|
<div {...classes('all-subjects')}>
|
|
243
245
|
<ProgrammeSubjects
|
|
244
246
|
grades={currentProgramme.grades}
|
|
245
|
-
|
|
247
|
+
selectedGrade={selectedGrade}
|
|
248
|
+
onChangeGrade={onGradeChange}
|
|
246
249
|
onNavigate={closeMenu}
|
|
247
250
|
/>
|
|
248
251
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -117,6 +117,8 @@ export { default as Breadcrumblist } from './Breadcrumblist';
|
|
|
117
117
|
|
|
118
118
|
export { MessageBox, MessageBoxTag, MessageBoxType } from './MessageBox';
|
|
119
119
|
|
|
120
|
+
export { ResourceBox } from './ResourceBox';
|
|
121
|
+
|
|
120
122
|
export { default as CloseButton } from './CloseButton';
|
|
121
123
|
export { default as AudioPlayer, initAudioPlayers } from './AudioPlayer';
|
|
122
124
|
|
|
@@ -218,3 +220,4 @@ export { default as CopyParagraphButton } from './CopyParagraphButton';
|
|
|
218
220
|
|
|
219
221
|
export { default as ContentPlaceholder } from './ContentPlaceholder';
|
|
220
222
|
export { Notion, ConceptNotion } from './Notion';
|
|
223
|
+
export { BannerCard } from './BannerCard';
|