@ndla/ui 44.0.4 → 44.0.5
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/Embed/ImageEmbed.js
CHANGED
|
@@ -89,7 +89,8 @@ var ImageEmbed = function ImageEmbed(_ref) {
|
|
|
89
89
|
var embed = _ref.embed,
|
|
90
90
|
previewAlt = _ref.previewAlt,
|
|
91
91
|
HeartButton = _ref.heartButton,
|
|
92
|
-
inGrid = _ref.inGrid
|
|
92
|
+
inGrid = _ref.inGrid,
|
|
93
|
+
path = _ref.path;
|
|
93
94
|
var _useState = useState(hideByline(embed.embedData.size)),
|
|
94
95
|
_useState2 = _slicedToArray(_useState, 2),
|
|
95
96
|
isBylineHidden = _useState2[0],
|
|
@@ -126,6 +127,7 @@ var ImageEmbed = function ImageEmbed(_ref) {
|
|
|
126
127
|
src: !isCopyrighted ? embedData.pageUrl || data.image.imageUrl : undefined,
|
|
127
128
|
crop: crop,
|
|
128
129
|
size: embedData.size,
|
|
130
|
+
pagePath: path,
|
|
129
131
|
children: _jsx(Image, {
|
|
130
132
|
focalPoint: focalPoint,
|
|
131
133
|
contentType: data.image.contentType,
|
|
@@ -170,10 +172,11 @@ var ImageWrapper = function ImageWrapper(_ref2) {
|
|
|
170
172
|
var src = _ref2.src,
|
|
171
173
|
crop = _ref2.crop,
|
|
172
174
|
size = _ref2.size,
|
|
173
|
-
children = _ref2.children
|
|
175
|
+
children = _ref2.children,
|
|
176
|
+
pagePath = _ref2.pagePath;
|
|
174
177
|
var _useTranslation = useTranslation(),
|
|
175
178
|
t = _useTranslation.t;
|
|
176
|
-
if (isSmall(size) || hideByline(size) || !src) {
|
|
179
|
+
if (isSmall(size) || hideByline(size) || !src || pagePath && src.endsWith(pagePath)) {
|
|
177
180
|
return _jsx(_Fragment, {
|
|
178
181
|
children: children
|
|
179
182
|
});
|
|
@@ -10,6 +10,7 @@ import { HeartButtonType } from './types';
|
|
|
10
10
|
interface Props {
|
|
11
11
|
embed: ImageMetaData;
|
|
12
12
|
previewAlt?: boolean;
|
|
13
|
+
path?: string;
|
|
13
14
|
heartButton?: HeartButtonType;
|
|
14
15
|
inGrid?: boolean;
|
|
15
16
|
}
|
|
@@ -37,5 +38,5 @@ export declare const getCrop: (data: ImageEmbedData) => {
|
|
|
37
38
|
endX: never;
|
|
38
39
|
endY: never;
|
|
39
40
|
} | undefined;
|
|
40
|
-
declare const ImageEmbed: ({ embed, previewAlt, heartButton: HeartButton, inGrid }: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
|
+
declare const ImageEmbed: ({ embed, previewAlt, heartButton: HeartButton, inGrid, path }: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
42
|
export default ImageEmbed;
|
package/lib/Embed/ImageEmbed.js
CHANGED
|
@@ -99,7 +99,8 @@ var ImageEmbed = function ImageEmbed(_ref) {
|
|
|
99
99
|
var embed = _ref.embed,
|
|
100
100
|
previewAlt = _ref.previewAlt,
|
|
101
101
|
HeartButton = _ref.heartButton,
|
|
102
|
-
inGrid = _ref.inGrid
|
|
102
|
+
inGrid = _ref.inGrid,
|
|
103
|
+
path = _ref.path;
|
|
103
104
|
var _useState = (0, _react.useState)(hideByline(embed.embedData.size)),
|
|
104
105
|
_useState2 = _slicedToArray(_useState, 2),
|
|
105
106
|
isBylineHidden = _useState2[0],
|
|
@@ -136,6 +137,7 @@ var ImageEmbed = function ImageEmbed(_ref) {
|
|
|
136
137
|
src: !isCopyrighted ? embedData.pageUrl || data.image.imageUrl : undefined,
|
|
137
138
|
crop: crop,
|
|
138
139
|
size: embedData.size,
|
|
140
|
+
pagePath: path,
|
|
139
141
|
children: (0, _jsxRuntime.jsx)(_Image.default, {
|
|
140
142
|
focalPoint: focalPoint,
|
|
141
143
|
contentType: data.image.contentType,
|
|
@@ -180,10 +182,11 @@ var ImageWrapper = function ImageWrapper(_ref2) {
|
|
|
180
182
|
var src = _ref2.src,
|
|
181
183
|
crop = _ref2.crop,
|
|
182
184
|
size = _ref2.size,
|
|
183
|
-
children = _ref2.children
|
|
185
|
+
children = _ref2.children,
|
|
186
|
+
pagePath = _ref2.pagePath;
|
|
184
187
|
var _useTranslation = (0, _reactI18next.useTranslation)(),
|
|
185
188
|
t = _useTranslation.t;
|
|
186
|
-
if (isSmall(size) || hideByline(size) || !src) {
|
|
189
|
+
if (isSmall(size) || hideByline(size) || !src || pagePath && src.endsWith(pagePath)) {
|
|
187
190
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
188
191
|
children: children
|
|
189
192
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/ui",
|
|
3
|
-
"version": "44.0.
|
|
3
|
+
"version": "44.0.5",
|
|
4
4
|
"description": "UI component library for NDLA.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "9e4590018d33aad8ae6bfe3502ec2d351b7c3234"
|
|
87
87
|
}
|
package/src/Embed/ImageEmbed.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import { HeartButtonType } from './types';
|
|
|
21
21
|
interface Props {
|
|
22
22
|
embed: ImageMetaData;
|
|
23
23
|
previewAlt?: boolean;
|
|
24
|
+
path?: string;
|
|
24
25
|
heartButton?: HeartButtonType;
|
|
25
26
|
inGrid?: boolean;
|
|
26
27
|
}
|
|
@@ -99,7 +100,7 @@ export const getCrop = (data: ImageEmbedData) => {
|
|
|
99
100
|
|
|
100
101
|
const expandedSizes = '(min-width: 1024px) 1024px, 100vw';
|
|
101
102
|
|
|
102
|
-
const ImageEmbed = ({ embed, previewAlt, heartButton: HeartButton, inGrid }: Props) => {
|
|
103
|
+
const ImageEmbed = ({ embed, previewAlt, heartButton: HeartButton, inGrid, path }: Props) => {
|
|
103
104
|
const [isBylineHidden, setIsBylineHidden] = useState(hideByline(embed.embedData.size));
|
|
104
105
|
const [imageSizes, setImageSizes] = useState<string | undefined>(undefined);
|
|
105
106
|
if (embed.status === 'error') {
|
|
@@ -132,6 +133,7 @@ const ImageEmbed = ({ embed, previewAlt, heartButton: HeartButton, inGrid }: Pro
|
|
|
132
133
|
src={!isCopyrighted ? embedData.pageUrl || data.image.imageUrl : undefined}
|
|
133
134
|
crop={crop}
|
|
134
135
|
size={embedData.size}
|
|
136
|
+
pagePath={path}
|
|
135
137
|
>
|
|
136
138
|
<Image
|
|
137
139
|
focalPoint={focalPoint}
|
|
@@ -171,6 +173,7 @@ const ImageEmbed = ({ embed, previewAlt, heartButton: HeartButton, inGrid }: Pro
|
|
|
171
173
|
interface ImageWrapperProps {
|
|
172
174
|
src?: string;
|
|
173
175
|
children: React.ReactNode;
|
|
176
|
+
pagePath?: string;
|
|
174
177
|
crop?: {
|
|
175
178
|
startX: number;
|
|
176
179
|
startY: number;
|
|
@@ -183,9 +186,9 @@ const hideByline = (size?: string): boolean => {
|
|
|
183
186
|
return !!size && size.endsWith('-hide-byline');
|
|
184
187
|
};
|
|
185
188
|
|
|
186
|
-
const ImageWrapper = ({ src, crop, size, children }: ImageWrapperProps) => {
|
|
189
|
+
const ImageWrapper = ({ src, crop, size, children, pagePath }: ImageWrapperProps) => {
|
|
187
190
|
const { t } = useTranslation();
|
|
188
|
-
if (isSmall(size) || hideByline(size) || !src) {
|
|
191
|
+
if (isSmall(size) || hideByline(size) || !src || (pagePath && src.endsWith(pagePath))) {
|
|
189
192
|
return <>{children}</>;
|
|
190
193
|
}
|
|
191
194
|
|