@ndla/ui 3.2.2 → 3.2.3
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/ArticleSideBar.js +42 -14
- package/es/Figure/Figure.js +5 -1
- package/es/Image/Image.js +1 -1
- package/es/Image/ImageLink.js +1 -1
- package/es/ResourcesWrapper/ResourcesTitle.js +0 -4
- package/es/ResourcesWrapper/ResourcesTopicTitle.js +12 -25
- package/es/ResourcesWrapper/ResourcesWrapper.js +2 -11
- package/es/Topic/Topic.js +21 -22
- package/es/index-javascript.js +0 -1
- package/es/index.js +1 -0
- package/lib/Article/ArticleSideBar.d.ts +2 -1
- package/lib/Article/ArticleSideBar.js +43 -14
- package/lib/Figure/Figure.d.ts +3 -4
- package/lib/Figure/Figure.js +5 -1
- package/lib/Hero/Hero.d.ts +2 -1
- package/lib/Hero/index.d.ts +1 -0
- package/lib/Image/Image.d.ts +10 -1
- package/lib/Image/Image.js +1 -1
- package/lib/Image/ImageLink.d.ts +1 -1
- package/lib/Image/ImageLink.js +1 -1
- package/lib/Image/index.d.ts +1 -0
- package/lib/ResourcesWrapper/ResourcesTitle.d.ts +13 -0
- package/lib/ResourcesWrapper/ResourcesTitle.js +0 -5
- package/lib/ResourcesWrapper/ResourcesTopicTitle.d.ts +13 -0
- package/lib/ResourcesWrapper/ResourcesTopicTitle.js +11 -26
- package/lib/ResourcesWrapper/ResourcesWrapper.d.ts +18 -0
- package/lib/ResourcesWrapper/ResourcesWrapper.js +2 -12
- package/lib/ResourcesWrapper/index.d.ts +11 -0
- package/lib/Topic/Topic.d.ts +1 -1
- package/lib/Topic/Topic.js +20 -20
- package/lib/index-javascript.js +0 -20
- package/lib/index.d.ts +1 -0
- package/lib/index.js +23 -0
- package/lib/types.d.ts +0 -10
- package/package.json +4 -4
- package/src/Article/ArticleSideBar.tsx +31 -3
- package/src/Figure/Figure.tsx +7 -4
- package/src/Hero/Hero.tsx +14 -12
- package/src/Hero/index.ts +2 -0
- package/src/Image/Image.tsx +11 -1
- package/src/Image/ImageLink.tsx +1 -1
- package/src/Image/index.ts +1 -0
- package/src/ResourcesWrapper/{ResourcesTitle.jsx → ResourcesTitle.tsx} +5 -7
- package/src/ResourcesWrapper/{ResourcesTopicTitle.jsx → ResourcesTopicTitle.tsx} +23 -22
- package/src/ResourcesWrapper/{ResourcesWrapper.jsx → ResourcesWrapper.tsx} +9 -14
- package/src/ResourcesWrapper/{index.js → index.ts} +0 -0
- package/src/Topic/Topic.tsx +1 -3
- package/src/index-javascript.js +0 -1
- package/src/index.ts +2 -0
- package/src/types.ts +0 -12
package/lib/index-javascript.js
CHANGED
|
@@ -197,24 +197,6 @@ Object.defineProperty(exports, "CompetenceGoalsDialog", {
|
|
|
197
197
|
return _CompetenceGoals.CompetenceGoalsDialog;
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
|
-
Object.defineProperty(exports, "ResourcesWrapper", {
|
|
201
|
-
enumerable: true,
|
|
202
|
-
get: function get() {
|
|
203
|
-
return _ResourcesWrapper["default"];
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
Object.defineProperty(exports, "ResourcesTitle", {
|
|
207
|
-
enumerable: true,
|
|
208
|
-
get: function get() {
|
|
209
|
-
return _ResourcesWrapper.ResourcesTitle;
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
Object.defineProperty(exports, "ResourcesTopicTitle", {
|
|
213
|
-
enumerable: true,
|
|
214
|
-
get: function get() {
|
|
215
|
-
return _ResourcesWrapper.ResourcesTopicTitle;
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
200
|
Object.defineProperty(exports, "MediaList", {
|
|
219
201
|
enumerable: true,
|
|
220
202
|
get: function get() {
|
|
@@ -326,8 +308,6 @@ var _TopicMenu = _interopRequireWildcard(require("./TopicMenu"));
|
|
|
326
308
|
|
|
327
309
|
var _CompetenceGoals = _interopRequireWildcard(require("./CompetenceGoals"));
|
|
328
310
|
|
|
329
|
-
var _ResourcesWrapper = _interopRequireWildcard(require("./ResourcesWrapper"));
|
|
330
|
-
|
|
331
311
|
var _MediaList = require("./MediaList");
|
|
332
312
|
|
|
333
313
|
var _Embedded = require("./Embedded");
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/** @ts-ignore */
|
|
9
9
|
export * from './index-javascript';
|
|
10
10
|
export { ArticleByline, ArticleContent, ArticleFootNotes, ArticleIntroduction, ArticleTitle, ArticleWrapper, ArticleHeaderWrapper, ArticleSideBar, default as Article, } from './Article';
|
|
11
|
+
export { default as ResourcesWrapper, ResourcesTitle, ResourcesTopicTitle } from './ResourcesWrapper';
|
|
11
12
|
export { createUniversalPortal } from './utils/createUniversalPortal';
|
|
12
13
|
export { default as NoContentBox } from './NoContentBox';
|
|
13
14
|
export { default as Masthead, MastheadItem } from './Masthead';
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,9 @@ var _exportNames = {
|
|
|
15
15
|
ArticleHeaderWrapper: true,
|
|
16
16
|
ArticleSideBar: true,
|
|
17
17
|
Article: true,
|
|
18
|
+
ResourcesWrapper: true,
|
|
19
|
+
ResourcesTitle: true,
|
|
20
|
+
ResourcesTopicTitle: true,
|
|
18
21
|
createUniversalPortal: true,
|
|
19
22
|
NoContentBox: true,
|
|
20
23
|
Masthead: true,
|
|
@@ -193,6 +196,24 @@ Object.defineProperty(exports, "Article", {
|
|
|
193
196
|
return _Article["default"];
|
|
194
197
|
}
|
|
195
198
|
});
|
|
199
|
+
Object.defineProperty(exports, "ResourcesWrapper", {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function get() {
|
|
202
|
+
return _ResourcesWrapper["default"];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(exports, "ResourcesTitle", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function get() {
|
|
208
|
+
return _ResourcesWrapper.ResourcesTitle;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(exports, "ResourcesTopicTitle", {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function get() {
|
|
214
|
+
return _ResourcesWrapper.ResourcesTopicTitle;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
196
217
|
Object.defineProperty(exports, "createUniversalPortal", {
|
|
197
218
|
enumerable: true,
|
|
198
219
|
get: function get() {
|
|
@@ -947,6 +968,8 @@ Object.keys(_indexJavascript).forEach(function (key) {
|
|
|
947
968
|
|
|
948
969
|
var _Article = _interopRequireWildcard(require("./Article"));
|
|
949
970
|
|
|
971
|
+
var _ResourcesWrapper = _interopRequireWildcard(require("./ResourcesWrapper"));
|
|
972
|
+
|
|
950
973
|
var _createUniversalPortal = require("./utils/createUniversalPortal");
|
|
951
974
|
|
|
952
975
|
var _NoContentBox = _interopRequireDefault(require("./NoContentBox"));
|
package/lib/types.d.ts
CHANGED
|
@@ -37,16 +37,6 @@ export interface Contributor {
|
|
|
37
37
|
export interface License {
|
|
38
38
|
license: string;
|
|
39
39
|
}
|
|
40
|
-
export interface ImageCrop {
|
|
41
|
-
startX: number;
|
|
42
|
-
startY: number;
|
|
43
|
-
endX: number;
|
|
44
|
-
endY: number;
|
|
45
|
-
}
|
|
46
|
-
export interface ImageFocalPoint {
|
|
47
|
-
x: number;
|
|
48
|
-
y: number;
|
|
49
|
-
}
|
|
50
40
|
export interface Copyright {
|
|
51
41
|
license: License;
|
|
52
42
|
creators: Array<Contributor>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@ndla/modal": "^1.1.13",
|
|
41
41
|
"@ndla/safelink": "^1.0.5",
|
|
42
42
|
"@ndla/switch": "^0.0.32",
|
|
43
|
-
"@ndla/tabs": "^1.0.
|
|
44
|
-
"@ndla/tooltip": "^0.2.
|
|
43
|
+
"@ndla/tabs": "^1.0.10",
|
|
44
|
+
"@ndla/tooltip": "^0.2.49",
|
|
45
45
|
"@ndla/util": "^2.0.0",
|
|
46
46
|
"@reach/menu-button": "^0.12.1",
|
|
47
47
|
"@reach/slider": "^0.12.1",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "bc3f20206c0a057260deef5eb887db3ed15b648b"
|
|
96
96
|
}
|
|
@@ -22,7 +22,10 @@ const ButtonWrapper = styled.div`
|
|
|
22
22
|
width: 100%;
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
type CursorWrapperProps = {
|
|
26
|
+
hide: boolean;
|
|
27
|
+
};
|
|
28
|
+
const CursorWrapper = styled.div<CursorWrapperProps>`
|
|
26
29
|
@import url('https://fonts.googleapis.com/css2?family=Shadows+Into+Light+Two&display=swap');
|
|
27
30
|
width: 120px;
|
|
28
31
|
font-family: 'Shadows Into Light Two', cursive;
|
|
@@ -30,12 +33,15 @@ const CursorWrapper = styled.div`
|
|
|
30
33
|
background-image: url("data:image/svg+xml,%3Csvg width='10' height='46' viewBox='0 0 10 46' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.7626 0.887965L4.52762 0.446621L3.64494 0.91658L3.87992 1.35792L4.7626 0.887965ZM8.03372 45.2321L8.46374 39.4747L3.26262 41.981L8.03372 45.2321ZM4.32126 1.12294C3.87992 1.35792 3.8798 1.3577 3.87969 1.3575C3.87968 1.35748 3.87959 1.35731 3.87956 1.35726C3.87951 1.35716 3.87952 1.35717 3.87959 1.35731C3.87973 1.35758 3.88012 1.35832 3.88076 1.35954C3.88203 1.36199 3.88428 1.36633 3.88747 1.3726C3.89384 1.38513 3.90397 1.40533 3.91755 1.43329C3.9447 1.48921 3.98562 1.57616 4.0378 1.69484C4.14215 1.9322 4.29157 2.29653 4.46596 2.79343C4.8147 3.78714 5.2635 5.31159 5.65136 7.41155C6.42699 11.611 6.95965 18.1161 5.95809 27.2851L6.95217 27.3937C7.96354 18.1349 7.42926 11.5317 6.63473 7.22992C6.2375 5.07924 5.77541 3.5048 5.40953 2.46228C5.22661 1.94106 5.06779 1.55294 4.95323 1.29237C4.89595 1.16209 4.84974 1.06371 4.81713 0.996535C4.80082 0.96295 4.78791 0.937167 4.77872 0.9191C4.77413 0.910067 4.77046 0.902963 4.76776 0.897778C4.76641 0.895185 4.7653 0.893072 4.76444 0.891437C4.76401 0.890619 4.76364 0.889921 4.76333 0.889343C4.76318 0.889054 4.763 0.888709 4.76292 0.888565C4.76276 0.88825 4.7626 0.887965 4.32126 1.12294ZM5.95809 27.2851C5.19358 34.284 5.23105 38.5891 5.58488 41.2448L6.57612 41.1128C6.23761 38.5721 6.19146 34.3579 6.95217 27.3937L5.95809 27.2851Z' fill='%2320588F'/%3E%3C/svg%3E%0A");
|
|
31
34
|
background-position: bottom center;
|
|
32
35
|
background-repeat: no-repeat;
|
|
36
|
+
${(p) => p.hide && 'opacity:0;'}
|
|
37
|
+
transition-duration: 0.5s;
|
|
33
38
|
padding-bottom: 60px;
|
|
34
39
|
`;
|
|
35
40
|
|
|
36
41
|
const LinkText = styled.div`
|
|
37
42
|
transform: rotate(-4.15deg);
|
|
38
43
|
text-align: center;
|
|
44
|
+
|
|
39
45
|
${fonts.sizes('18px', '26px')};
|
|
40
46
|
`;
|
|
41
47
|
|
|
@@ -44,8 +50,15 @@ type Props = {
|
|
|
44
50
|
onLinkToResourcesClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
45
51
|
copyPageUrlLink?: string;
|
|
46
52
|
licenseBox?: React.ReactNode;
|
|
53
|
+
resourcesRef?: React.RefObject<HTMLElement>;
|
|
47
54
|
};
|
|
48
|
-
const ArticleSideBar = ({
|
|
55
|
+
const ArticleSideBar = ({
|
|
56
|
+
linkToResources,
|
|
57
|
+
onLinkToResourcesClick,
|
|
58
|
+
copyPageUrlLink,
|
|
59
|
+
licenseBox,
|
|
60
|
+
resourcesRef,
|
|
61
|
+
}: Props) => {
|
|
49
62
|
const { t } = useTranslation();
|
|
50
63
|
const copyLinkHandler = () => {
|
|
51
64
|
if (copyPageUrlLink) {
|
|
@@ -53,6 +66,21 @@ const ArticleSideBar = ({ linkToResources, onLinkToResourcesClick, copyPageUrlLi
|
|
|
53
66
|
}
|
|
54
67
|
};
|
|
55
68
|
|
|
69
|
+
const [hide, setHide] = React.useState(Boolean(false));
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
window.onscroll = function () {
|
|
72
|
+
if (!resourcesRef?.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
//TOP
|
|
76
|
+
if (resourcesRef.current.getBoundingClientRect().top <= 0) {
|
|
77
|
+
setHide(true);
|
|
78
|
+
} else if (resourcesRef.current.getBoundingClientRect().top <= 0) {
|
|
79
|
+
setHide(false);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
56
84
|
return (
|
|
57
85
|
<Wrapper>
|
|
58
86
|
{copyPageUrlLink && (
|
|
@@ -87,7 +115,7 @@ const ArticleSideBar = ({ linkToResources, onLinkToResourcesClick, copyPageUrlLi
|
|
|
87
115
|
</Modal>
|
|
88
116
|
)}
|
|
89
117
|
{linkToResources && (
|
|
90
|
-
<CursorWrapper>
|
|
118
|
+
<CursorWrapper hide={hide}>
|
|
91
119
|
<LinkText>
|
|
92
120
|
<SafeLink
|
|
93
121
|
to={linkToResources}
|
package/src/Figure/Figure.tsx
CHANGED
|
@@ -11,14 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
import React, { ReactNode } from 'react';
|
|
13
13
|
import BEMHelper from 'react-bem-helper';
|
|
14
|
-
import { isFunction, parseMarkdown } from '@ndla/util';
|
|
14
|
+
import { isFunction as isFunctionHelper, parseMarkdown } from '@ndla/util';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import { Link as LinkIcon } from '@ndla/icons/common';
|
|
17
17
|
import { LicenseByline } from '@ndla/licenses';
|
|
18
18
|
import SafeLink from '@ndla/safelink';
|
|
19
19
|
//@ts-ignore
|
|
20
20
|
import Button from '@ndla/button';
|
|
21
|
-
import { License } from '../types';
|
|
22
21
|
|
|
23
22
|
const classes = new BEMHelper({
|
|
24
23
|
name: 'figure',
|
|
@@ -91,7 +90,7 @@ export const FigureCaption = ({
|
|
|
91
90
|
);
|
|
92
91
|
};
|
|
93
92
|
|
|
94
|
-
export interface FigureLicense
|
|
93
|
+
export interface FigureLicense {
|
|
95
94
|
short: string;
|
|
96
95
|
title: string;
|
|
97
96
|
userFriendlyTitle: string;
|
|
@@ -129,9 +128,13 @@ const Figure = ({ children, type = 'full', resizeIframe, ...rest }: Props) => {
|
|
|
129
128
|
);
|
|
130
129
|
};
|
|
131
130
|
|
|
131
|
+
const isFunction = (children: Function | ReactNode): children is Function => {
|
|
132
|
+
return isFunctionHelper(children);
|
|
133
|
+
};
|
|
134
|
+
|
|
132
135
|
interface Props {
|
|
133
136
|
id: string;
|
|
134
|
-
children: (params: { typeClass: string }) => ReactNode
|
|
137
|
+
children: ReactNode | ((params: { typeClass: string }) => ReactNode);
|
|
135
138
|
type: 'full' | 'full-column' | 'left' | 'small-left' | 'right' | 'small-right' | 'xsmall-right' | 'xsmall-left';
|
|
136
139
|
resizeIframe?: boolean;
|
|
137
140
|
noFigcaption?: boolean;
|
package/src/Hero/Hero.tsx
CHANGED
|
@@ -16,20 +16,22 @@ const classes = new BEMHelper({
|
|
|
16
16
|
prefix: 'c-',
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
export type HeroContentType =
|
|
20
|
+
| 'subject-material'
|
|
21
|
+
| 'tasks-and-activities'
|
|
22
|
+
| 'assessment-resources'
|
|
23
|
+
| 'subject'
|
|
24
|
+
| 'external-learning-resources'
|
|
25
|
+
| 'source-material'
|
|
26
|
+
| 'learning-path'
|
|
27
|
+
| 'topic'
|
|
28
|
+
| 'beta'
|
|
29
|
+
| 'ndla-film'
|
|
30
|
+
| 'ndla-film has-image';
|
|
31
|
+
|
|
19
32
|
interface HeroProps {
|
|
20
33
|
children?: ReactNode;
|
|
21
|
-
contentType:
|
|
22
|
-
| 'subject-material'
|
|
23
|
-
| 'tasks-and-activities'
|
|
24
|
-
| 'assessment-resources'
|
|
25
|
-
| 'subject'
|
|
26
|
-
| 'external-learning-resources'
|
|
27
|
-
| 'source-material'
|
|
28
|
-
| 'learning-path'
|
|
29
|
-
| 'topic'
|
|
30
|
-
| 'beta'
|
|
31
|
-
| 'ndla-film'
|
|
32
|
-
| 'ndla-film has-image';
|
|
34
|
+
contentType: HeroContentType;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
export const Hero = ({ children, contentType }: HeroProps) => (
|
package/src/Hero/index.ts
CHANGED
package/src/Image/Image.tsx
CHANGED
|
@@ -10,7 +10,17 @@ import React, { ReactNode } from 'react';
|
|
|
10
10
|
import defined from 'defined';
|
|
11
11
|
import styled from '@emotion/styled';
|
|
12
12
|
import LazyLoadImage from './LazyLoadImage';
|
|
13
|
-
|
|
13
|
+
export interface ImageCrop {
|
|
14
|
+
startX: number;
|
|
15
|
+
startY: number;
|
|
16
|
+
endX: number;
|
|
17
|
+
endY: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ImageFocalPoint {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
14
24
|
|
|
15
25
|
export const makeSrcQueryString = (width: number | undefined, crop?: ImageCrop, focalPoint?: ImageFocalPoint) => {
|
|
16
26
|
const widthParams = width && `width=${width}`;
|
package/src/Image/ImageLink.tsx
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import React, { ReactNode } from 'react';
|
|
10
10
|
import styled from '@emotion/styled';
|
|
11
11
|
import { makeSrcQueryString } from './Image';
|
|
12
|
-
import { ImageCrop, ImageFocalPoint } from '
|
|
12
|
+
import { ImageCrop, ImageFocalPoint } from '.';
|
|
13
13
|
|
|
14
14
|
const StyledLink = styled.a`
|
|
15
15
|
box-shadow: inset 0 0;
|
package/src/Image/index.ts
CHANGED
|
@@ -6,20 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
9
|
+
import React, { ReactNode } from 'react';
|
|
11
10
|
import { classes } from './ResourcesWrapper';
|
|
12
11
|
import { SubjectBadge } from '../ContentTypeBadge';
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
interface Props {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
const ResourceTitle = ({ children }: Props) => (
|
|
15
17
|
<div {...classes('title-wrapper')}>
|
|
16
18
|
<SubjectBadge size="large" background />
|
|
17
19
|
<h1 {...classes('title')}>{children}</h1>
|
|
18
20
|
</div>
|
|
19
21
|
);
|
|
20
22
|
|
|
21
|
-
ResourceTitle.propTypes = {
|
|
22
|
-
children: PropTypes.node.isRequired,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
23
|
export default ResourceTitle;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
1
|
+
import React, { Fragment, ReactNode } from 'react';
|
|
3
2
|
import { css } from '@emotion/core';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { spacing } from '@ndla/core';
|
|
6
5
|
import { HelpCircleDual } from '@ndla/icons/common';
|
|
6
|
+
//@ts-ignore
|
|
7
7
|
import Modal, { ModalBody, ModalHeader, ModalCloseButton } from '@ndla/modal';
|
|
8
8
|
import Tooltip from '@ndla/tooltip';
|
|
9
9
|
import { Switch } from '@ndla/switch';
|
|
@@ -11,7 +11,10 @@ import { useTranslation } from 'react-i18next';
|
|
|
11
11
|
|
|
12
12
|
import { classes } from './ResourcesWrapper';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface HelpIconProps {
|
|
15
|
+
invertedStyle: boolean;
|
|
16
|
+
}
|
|
17
|
+
const HelpIcon = ({ invertedStyle }: HelpIconProps) => (
|
|
15
18
|
<div {...classes('topic-title-icon', { invertedStyle })}>
|
|
16
19
|
<HelpCircleDual className={`c-icon--22 u-margin-left-tiny ${classes('icon').className}`} />
|
|
17
20
|
</div>
|
|
@@ -37,14 +40,25 @@ const TooltipButton = styled.button`
|
|
|
37
40
|
cursor: pointer;
|
|
38
41
|
`;
|
|
39
42
|
|
|
43
|
+
interface Props {
|
|
44
|
+
title?: string;
|
|
45
|
+
toggleAdditionalResources: () => void;
|
|
46
|
+
hasAdditionalResources: boolean;
|
|
47
|
+
showAdditionalResources: boolean;
|
|
48
|
+
invertedStyle?: boolean;
|
|
49
|
+
messages: {
|
|
50
|
+
label: string;
|
|
51
|
+
additionalFilterLabel: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
40
54
|
const ResourcesTopicTitle = ({
|
|
41
55
|
title,
|
|
42
56
|
hasAdditionalResources,
|
|
43
57
|
toggleAdditionalResources,
|
|
44
58
|
showAdditionalResources,
|
|
45
59
|
messages,
|
|
46
|
-
invertedStyle,
|
|
47
|
-
}) => {
|
|
60
|
+
invertedStyle = false,
|
|
61
|
+
}: Props) => {
|
|
48
62
|
const { t } = useTranslation();
|
|
49
63
|
// Fix for heading while title not required when ready.
|
|
50
64
|
let heading;
|
|
@@ -70,7 +84,7 @@ const ResourcesTopicTitle = ({
|
|
|
70
84
|
/>
|
|
71
85
|
<Modal
|
|
72
86
|
narrow
|
|
73
|
-
wrapperFunctionForButton={(activateButton) => (
|
|
87
|
+
wrapperFunctionForButton={(activateButton: ReactNode) => (
|
|
74
88
|
<TooltipWrapper>
|
|
75
89
|
<Tooltip tooltip={t('resource.dialogTooltip')}>{activateButton}</Tooltip>
|
|
76
90
|
</TooltipWrapper>
|
|
@@ -80,8 +94,8 @@ const ResourcesTopicTitle = ({
|
|
|
80
94
|
<HelpIcon invertedStyle={invertedStyle} />
|
|
81
95
|
</TooltipButton>
|
|
82
96
|
}>
|
|
83
|
-
{(onClose) => (
|
|
84
|
-
|
|
97
|
+
{(onClose: () => void) => (
|
|
98
|
+
<>
|
|
85
99
|
<ModalHeader>
|
|
86
100
|
<ModalCloseButton title={t('modal.closeModal')} onClick={onClose} />
|
|
87
101
|
</ModalHeader>
|
|
@@ -91,7 +105,7 @@ const ResourcesTopicTitle = ({
|
|
|
91
105
|
<p>{t('resource.dialogText1')}</p>
|
|
92
106
|
<p>{t('resource.dialogText2')}</p>
|
|
93
107
|
</ModalBody>
|
|
94
|
-
|
|
108
|
+
</>
|
|
95
109
|
)}
|
|
96
110
|
</Modal>
|
|
97
111
|
</div>
|
|
@@ -100,17 +114,4 @@ const ResourcesTopicTitle = ({
|
|
|
100
114
|
);
|
|
101
115
|
};
|
|
102
116
|
|
|
103
|
-
/* eslint-disable no-console */
|
|
104
|
-
ResourcesTopicTitle.propTypes = {
|
|
105
|
-
title: PropTypes.string, // Should be required
|
|
106
|
-
toggleAdditionalResources: PropTypes.func.isRequired,
|
|
107
|
-
hasAdditionalResources: PropTypes.bool.isRequired,
|
|
108
|
-
showAdditionalResources: PropTypes.bool.isRequired,
|
|
109
|
-
invertedStyle: PropTypes.bool,
|
|
110
|
-
messages: PropTypes.shape({
|
|
111
|
-
label: PropTypes.string.isRequired,
|
|
112
|
-
additionalFilterLabel: PropTypes.string.isRequired,
|
|
113
|
-
}).isRequired,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
117
|
export default ResourcesTopicTitle;
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
9
|
+
import React, { ReactNode } from 'react';
|
|
11
10
|
import BEMHelper from 'react-bem-helper';
|
|
12
11
|
|
|
13
12
|
export const classes = new BEMHelper({
|
|
@@ -15,22 +14,18 @@ export const classes = new BEMHelper({
|
|
|
15
14
|
prefix: 'c-',
|
|
16
15
|
});
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
interface Props {
|
|
18
|
+
header?: ReactNode;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
subjectPage?: boolean;
|
|
21
|
+
id?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ResourcesWrapper = ({ children, header, subjectPage = false, id }: Props) => (
|
|
19
25
|
<section {...classes('', { subjectPage })} id={id}>
|
|
20
26
|
{header}
|
|
21
27
|
<div {...classes('content')}>{children}</div>
|
|
22
28
|
</section>
|
|
23
29
|
);
|
|
24
30
|
|
|
25
|
-
ResourcesWrapper.propTypes = {
|
|
26
|
-
header: PropTypes.node,
|
|
27
|
-
children: PropTypes.node.isRequired,
|
|
28
|
-
subjectPage: PropTypes.bool,
|
|
29
|
-
id: PropTypes.string,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
ResourcesWrapper.defaultProps = {
|
|
33
|
-
subjectPage: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
31
|
export default ResourcesWrapper;
|
|
File without changes
|
package/src/Topic/Topic.tsx
CHANGED
|
@@ -22,9 +22,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
22
22
|
import Loader from './Loader';
|
|
23
23
|
import { ItemProps } from '../Navigation/NavigationBox';
|
|
24
24
|
import { NavigationBox } from '../Navigation';
|
|
25
|
-
|
|
26
|
-
import { makeSrcQueryString } from '../Image';
|
|
27
|
-
import { ImageCrop, ImageFocalPoint } from '../types';
|
|
25
|
+
import { makeSrcQueryString, ImageCrop, ImageFocalPoint } from '../Image';
|
|
28
26
|
|
|
29
27
|
type InvertItProps = {
|
|
30
28
|
invertedStyle?: boolean;
|
package/src/index-javascript.js
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ export {
|
|
|
24
24
|
default as Article,
|
|
25
25
|
} from './Article';
|
|
26
26
|
|
|
27
|
+
export { default as ResourcesWrapper, ResourcesTitle, ResourcesTopicTitle } from './ResourcesWrapper';
|
|
28
|
+
|
|
27
29
|
export { createUniversalPortal } from './utils/createUniversalPortal';
|
|
28
30
|
|
|
29
31
|
export { default as NoContentBox } from './NoContentBox';
|
package/src/types.ts
CHANGED
|
@@ -45,18 +45,6 @@ export interface License {
|
|
|
45
45
|
license: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export interface ImageCrop {
|
|
49
|
-
startX: number;
|
|
50
|
-
startY: number;
|
|
51
|
-
endX: number;
|
|
52
|
-
endY: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface ImageFocalPoint {
|
|
56
|
-
x: number;
|
|
57
|
-
y: number;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
48
|
export interface Copyright {
|
|
61
49
|
license: License;
|
|
62
50
|
creators: Array<Contributor>;
|