@ndla/image-search 6.0.123 → 6.0.125
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/ImageMeta.js +10 -8
- package/es/ImageSearch.js +133 -161
- package/es/ImageSearchResult.js +13 -13
- package/es/PreviewImage.js +26 -43
- package/es/util/imageUtil.js +2 -6
- package/lib/ImageMeta.js +17 -16
- package/lib/ImageSearch.js +140 -169
- package/lib/ImageSearchResult.js +19 -19
- package/lib/PreviewImage.js +35 -51
- package/lib/index.js +2 -3
- package/lib/util/imageUtil.js +2 -6
- package/package.json +12 -7
package/lib/PreviewImage.js
CHANGED
|
@@ -13,35 +13,30 @@ var _imageUtil = require("./util/imageUtil");
|
|
|
13
13
|
var _ImageMeta = _interopRequireDefault(require("./ImageMeta"));
|
|
14
14
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setSaveAsMetaImage = _useState2[1];
|
|
41
|
-
var tags = (_image$tags$tags = image.tags.tags) !== null && _image$tags$tags !== void 0 ? _image$tags$tags : [];
|
|
42
|
-
var title = (_image$title$title = image.title.title) !== null && _image$title$title !== void 0 ? _image$title$title : '';
|
|
43
|
-
var altText = (_image$alttext$alttex = image.alttext.alttext) !== null && _image$alttext$alttex !== void 0 ? _image$alttext$alttex : '';
|
|
44
|
-
var caption = (_image$caption$captio = image.caption.caption) !== null && _image$caption$captio !== void 0 ? _image$caption$captio : '';
|
|
16
|
+
/**
|
|
17
|
+
* Copyright (c) 2017-present, NDLA.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const PreviewImage = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
image,
|
|
27
|
+
onSelectImage,
|
|
28
|
+
useImageTitle,
|
|
29
|
+
showCheckbox,
|
|
30
|
+
checkboxLabel
|
|
31
|
+
} = _ref;
|
|
32
|
+
const {
|
|
33
|
+
t
|
|
34
|
+
} = (0, _reactI18next.useTranslation)();
|
|
35
|
+
const [saveAsMetaImage, setSaveAsMetaImage] = (0, _react.useState)(false);
|
|
36
|
+
const tags = image.tags.tags ?? [];
|
|
37
|
+
const title = image.title.title ?? '';
|
|
38
|
+
const altText = image.alttext.alttext ?? '';
|
|
39
|
+
const caption = image.caption.caption ?? '';
|
|
45
40
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
46
41
|
className: "image-preview",
|
|
47
42
|
children: [(0, _jsxRuntime.jsx)("div", {
|
|
@@ -63,9 +58,7 @@ var PreviewImage = function PreviewImage(_ref) {
|
|
|
63
58
|
className: "copyright-author",
|
|
64
59
|
children: (0, _jsxRuntime.jsx)("span", {
|
|
65
60
|
className: "text",
|
|
66
|
-
children: image.copyright.creators.map(
|
|
67
|
-
return creator.name;
|
|
68
|
-
}).join(', ')
|
|
61
|
+
children: image.copyright.creators.map(creator => creator.name).join(', ')
|
|
69
62
|
})
|
|
70
63
|
}) : null, (0, _jsxRuntime.jsx)("div", {
|
|
71
64
|
className: "info",
|
|
@@ -77,19 +70,19 @@ var PreviewImage = function PreviewImage(_ref) {
|
|
|
77
70
|
className: "info",
|
|
78
71
|
children: (0, _jsxRuntime.jsx)("span", {
|
|
79
72
|
className: "text",
|
|
80
|
-
children:
|
|
73
|
+
children: `${t('image.caption')}: ${caption}`
|
|
81
74
|
})
|
|
82
75
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
83
76
|
className: "info",
|
|
84
77
|
children: (0, _jsxRuntime.jsx)("span", {
|
|
85
78
|
className: "text",
|
|
86
|
-
children:
|
|
79
|
+
children: `${t('image.altText')}: ${altText}`
|
|
87
80
|
})
|
|
88
81
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
89
82
|
className: "info",
|
|
90
83
|
children: (0, _jsxRuntime.jsx)("span", {
|
|
91
84
|
className: "text",
|
|
92
|
-
children:
|
|
85
|
+
children: `${t('image.modelReleased.label')}: ${t('image.modelReleased.' + image.modelRelease)}`
|
|
93
86
|
})
|
|
94
87
|
}), (0, _jsxRuntime.jsx)(_ImageMeta.default, {
|
|
95
88
|
contentType: image.image.contentType,
|
|
@@ -97,27 +90,19 @@ var PreviewImage = function PreviewImage(_ref) {
|
|
|
97
90
|
imageDimensions: image.image.dimensions
|
|
98
91
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
99
92
|
className: "tags",
|
|
100
|
-
children: tags.map(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, (0, _util.uuid)());
|
|
105
|
-
})
|
|
93
|
+
children: tags.map(tag => (0, _jsxRuntime.jsx)("span", {
|
|
94
|
+
className: "tag_item",
|
|
95
|
+
children: `#${tag}`
|
|
96
|
+
}, (0, _util.uuid)()))
|
|
106
97
|
}), (0, _jsxRuntime.jsx)(_button.ButtonV2, {
|
|
107
98
|
"data-testid": "use-image",
|
|
108
|
-
onClick:
|
|
109
|
-
return onSelectImage(image, saveAsMetaImage);
|
|
110
|
-
},
|
|
99
|
+
onClick: () => onSelectImage(image, saveAsMetaImage),
|
|
111
100
|
children: useImageTitle
|
|
112
101
|
}), showCheckbox && (0, _jsxRuntime.jsx)("div", {
|
|
113
102
|
children: (0, _jsxRuntime.jsx)(_forms.CheckboxItem, {
|
|
114
103
|
label: checkboxLabel,
|
|
115
104
|
checked: saveAsMetaImage,
|
|
116
|
-
onChange:
|
|
117
|
-
return setSaveAsMetaImage(function (prev) {
|
|
118
|
-
return !prev;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
105
|
+
onChange: () => setSaveAsMetaImage(prev => !prev)
|
|
121
106
|
})
|
|
122
107
|
})]
|
|
123
108
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
@@ -125,5 +110,4 @@ var PreviewImage = function PreviewImage(_ref) {
|
|
|
125
110
|
})]
|
|
126
111
|
});
|
|
127
112
|
};
|
|
128
|
-
var _default = PreviewImage;
|
|
129
|
-
exports.default = _default;
|
|
113
|
+
var _default = exports.default = PreviewImage;
|
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "ImageMeta", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _ImageMeta.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -13,5 +13,4 @@ exports.default = void 0;
|
|
|
13
13
|
var _ImageSearch = _interopRequireDefault(require("./ImageSearch"));
|
|
14
14
|
var _ImageMeta = _interopRequireDefault(require("./ImageMeta"));
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
var _default = _ImageSearch.default;
|
|
17
|
-
exports.default = _default;
|
|
16
|
+
var _default = exports.default = _ImageSearch.default;
|
package/lib/util/imageUtil.js
CHANGED
|
@@ -15,11 +15,7 @@ exports.getSrcSets = exports.getPreviewSrcSets = void 0;
|
|
|
15
15
|
/* - Source sets for gallery search is retina-display optimized
|
|
16
16
|
- Based on: https://www.smashingmagazine.com/2014/05/responsive-images-done-right-guide-picture-srcset/ */
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return ["".concat(imageUrl, "?width=1440 1440w"), "".concat(imageUrl, "?width=1120 1120w"), "".concat(imageUrl, "?width=1000 1000w"), "".concat(imageUrl, "?width=960 960w"), "".concat(imageUrl, "?width=800 800w"), "".concat(imageUrl, "?width=640 640w"), "".concat(imageUrl, "?width=480 480w"), "".concat(imageUrl, "?width=320 320w")].join(', ');
|
|
20
|
-
};
|
|
18
|
+
const getSrcSets = imageUrl => [`${imageUrl}?width=1440 1440w`, `${imageUrl}?width=1120 1120w`, `${imageUrl}?width=1000 1000w`, `${imageUrl}?width=960 960w`, `${imageUrl}?width=800 800w`, `${imageUrl}?width=640 640w`, `${imageUrl}?width=480 480w`, `${imageUrl}?width=320 320w`].join(', ');
|
|
21
19
|
exports.getSrcSets = getSrcSets;
|
|
22
|
-
|
|
23
|
-
return ["".concat(imageUrl, "?width=480 3x"), "".concat(imageUrl, "?width=320 2x"), "".concat(imageUrl, "?width=160 1x")].join(', ');
|
|
24
|
-
};
|
|
20
|
+
const getPreviewSrcSets = imageUrl => [`${imageUrl}?width=480 3x`, `${imageUrl}?width=320 2x`, `${imageUrl}?width=160 1x`].join(', ');
|
|
25
21
|
exports.getPreviewSrcSets = getPreviewSrcSets;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/image-search",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.125",
|
|
4
4
|
"description": "A simple library for searching images from NDLA",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"es"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ndla/button": "^12.0.
|
|
29
|
+
"@ndla/button": "^12.0.15",
|
|
30
30
|
"@ndla/core": "^4.2.7",
|
|
31
|
-
"@ndla/forms": "^5.2.
|
|
31
|
+
"@ndla/forms": "^5.2.3",
|
|
32
32
|
"@ndla/icons": "^4.2.2",
|
|
33
|
-
"@ndla/pager": "^2.2.
|
|
34
|
-
"@ndla/ui": "^50.1.
|
|
33
|
+
"@ndla/pager": "^2.2.40",
|
|
34
|
+
"@ndla/ui": "^50.1.2",
|
|
35
35
|
"@ndla/util": "^4.0.1",
|
|
36
36
|
"pretty-bytes": "^5.6.0"
|
|
37
37
|
},
|
|
@@ -41,10 +41,15 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@emotion/react": "^11.10.4",
|
|
43
43
|
"@emotion/styled": "^11.10.4",
|
|
44
|
-
"
|
|
44
|
+
"i18next": ">= 23.0.0",
|
|
45
|
+
"lodash": ">= 4.0.0",
|
|
46
|
+
"react": ">= 16.8.0",
|
|
47
|
+
"react-dom": ">= 16.8.0",
|
|
48
|
+
"react-i18next": ">= 13.0.0",
|
|
49
|
+
"react-router-dom": ">= 6.0.0"
|
|
45
50
|
},
|
|
46
51
|
"publishConfig": {
|
|
47
52
|
"access": "public"
|
|
48
53
|
},
|
|
49
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "a3aad57d56edabe22d550adb5fda8af5ab6c8b6f"
|
|
50
55
|
}
|