@ndla/video-search 8.0.20-alpha.0 → 8.0.22-alpha.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/README.md CHANGED
@@ -41,6 +41,7 @@ const translations = {
41
41
  duration: "Duration",
42
42
  interactioncount: "Views",
43
43
  is360Video: "360 video",
44
+ close: "Close",
44
45
  };
45
46
 
46
47
  <VideoSearch onVideoSelect={onVideoSelect} searchVideos={searchVideos} translations={translations} locale="nb" />;
@@ -0,0 +1,33 @@
1
+ {
2
+ "schemaVersion": "0.46.0",
3
+ "styles": {
4
+ "atomic": [
5
+ "display]___[value:flex",
6
+ "gap]___[value:small",
7
+ "minHeight]___[value:surface.xxsmall",
8
+ "display]___[value:grid",
9
+ "gap]___[value:xsmall",
10
+ "gridTemplateColumns]___[value:repeat(3,1fr)",
11
+ "padding]___[value:small",
12
+ "borderBlockEnd]___[value:1px solid",
13
+ "borderColor]___[value:stroke.subtle",
14
+ "minWidth]___[value:surface.xxsmall",
15
+ "height]___[value:surface.4xsmall",
16
+ "objectFit]___[value:cover",
17
+ "border]___[value:1px solid",
18
+ "flexDirection]___[value:column",
19
+ "gap]___[value:xxsmall",
20
+ "alignItems]___[value:flex-end",
21
+ "flexDirection]___[value:column]___[cond:tabletDown",
22
+ "alignItems]___[value:flex-start]___[cond:tabletDown",
23
+ "marginLeft]___[value:auto",
24
+ "paddingBlock]___[value:medium",
25
+ "listStyle]___[value:none",
26
+ "width]___[value:100%",
27
+ "justifyContent]___[value:center",
28
+ "gap]___[value:medium",
29
+ "alignItems]___[value:center"
30
+ ],
31
+ "recipes": {}
32
+ }
33
+ }
@@ -0,0 +1,102 @@
1
+ @layer utilities {
2
+ .d_flex {
3
+ display: flex;
4
+ }
5
+
6
+ .gap_small {
7
+ gap: var(--spacing-small);
8
+ }
9
+
10
+ .min-h_surface\.xxsmall {
11
+ min-height: var(--sizes-surface-xxsmall);
12
+ }
13
+
14
+ .d_grid {
15
+ display: grid;
16
+ }
17
+
18
+ .gap_xsmall {
19
+ gap: var(--spacing-xsmall);
20
+ }
21
+
22
+ .p_small {
23
+ padding: var(--spacing-small);
24
+ }
25
+
26
+ .bd-be_1px_solid {
27
+ border-block-end: 1px solid;
28
+ }
29
+
30
+ .min-w_surface\.xxsmall {
31
+ min-width: var(--sizes-surface-xxsmall);
32
+ }
33
+
34
+ .h_surface\.4xsmall {
35
+ height: var(--sizes-surface-4xsmall);
36
+ }
37
+
38
+ .obj-f_cover {
39
+ object-fit: cover;
40
+ }
41
+
42
+ .bd_1px_solid {
43
+ border: 1px solid;
44
+ }
45
+
46
+ .gap_xxsmall {
47
+ gap: var(--spacing-xxsmall);
48
+ }
49
+
50
+ .py_medium {
51
+ padding-block: var(--spacing-medium);
52
+ }
53
+
54
+ .li-s_none {
55
+ list-style: none;
56
+ }
57
+
58
+ .w_100\% {
59
+ width: 100%;
60
+ }
61
+
62
+ .gap_medium {
63
+ gap: var(--spacing-medium);
64
+ }
65
+
66
+ .grid-tc_repeat\(3\,1fr\) {
67
+ grid-template-columns: repeat(3,1fr);
68
+ }
69
+
70
+ .bd-c_stroke\.subtle {
71
+ border-color: var(--colors-stroke-subtle);
72
+ }
73
+
74
+ .flex-d_column {
75
+ flex-direction: column;
76
+ }
77
+
78
+ .ai_flex-end {
79
+ align-items: flex-end;
80
+ }
81
+
82
+ .ml_auto {
83
+ margin-left: auto;
84
+ }
85
+
86
+ .jc_center {
87
+ justify-content: center;
88
+ }
89
+
90
+ .ai_center {
91
+ align-items: center;
92
+ }
93
+
94
+ @media screen and (max-width: 37.56rem) {
95
+ .tabletDown\:flex-d_column {
96
+ flex-direction: column;
97
+ }
98
+ .tabletDown\:ai_flex-start {
99
+ align-items: flex-start;
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Copyright (c) 2024-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 { useState } from "react";
10
+ import { CloseLine } from "@ndla/icons/action";
11
+ import { PanoramaPhotosphere } from "@ndla/icons/common";
12
+ import { getLicenseByNBTitle } from "@ndla/licenses";
13
+ import { Image, Text, ListItemContent, ListItemRoot, Button, IconButton } from "@ndla/primitives";
14
+ import { styled } from "@ndla/styled-system/jsx";
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ const ButtonWrapper = styled("div", {
17
+ base: {
18
+ display: "flex",
19
+ gap: "small"
20
+ }
21
+ });
22
+ const PreviewIframe = styled("iframe", {
23
+ base: {
24
+ minHeight: "surface.xxsmall"
25
+ }
26
+ });
27
+ const PreviewWrapper = styled("div", {
28
+ base: {
29
+ display: "grid",
30
+ gap: "xsmall",
31
+ gridTemplateColumns: "repeat(3,1fr)",
32
+ padding: "small",
33
+ borderBlockEnd: "1px solid",
34
+ borderColor: "stroke.subtle"
35
+ }
36
+ });
37
+ const StyledImage = styled(Image, {
38
+ base: {
39
+ minWidth: "surface.xxsmall",
40
+ height: "surface.4xsmall",
41
+ objectFit: "cover",
42
+ border: "1px solid",
43
+ borderColor: "stroke.subtle"
44
+ }
45
+ });
46
+ const StyledVideoMeta = styled("div", {
47
+ base: {
48
+ display: "flex",
49
+ flexDirection: "column",
50
+ gap: "xxsmall"
51
+ }
52
+ });
53
+ const StyledListItemContent = styled(ListItemContent, {
54
+ base: {
55
+ alignItems: "flex-end",
56
+ tabletDown: {
57
+ flexDirection: "column",
58
+ alignItems: "flex-start"
59
+ }
60
+ }
61
+ });
62
+ const StyledIconButton = styled(IconButton, {
63
+ base: {
64
+ marginLeft: "auto"
65
+ }
66
+ });
67
+ const StyledListItemRoot = styled(ListItemRoot, {
68
+ base: {
69
+ paddingBlock: "medium",
70
+ tabletDown: {
71
+ flexDirection: "column",
72
+ alignItems: "flex-start"
73
+ }
74
+ }
75
+ });
76
+ const License = _ref => {
77
+ let {
78
+ license
79
+ } = _ref;
80
+ if (typeof license === "string") return /*#__PURE__*/_jsx(Text, {
81
+ children: license
82
+ });
83
+ if (license.url?.length) {
84
+ return /*#__PURE__*/_jsx("a", {
85
+ href: license.url,
86
+ rel: "license",
87
+ children: license.abbreviation
88
+ });
89
+ }
90
+ return /*#__PURE__*/_jsx(Text, {
91
+ children: license.abbreviation
92
+ });
93
+ };
94
+ export const VideoListItem = _ref2 => {
95
+ let {
96
+ video,
97
+ onVideoSelect,
98
+ translations,
99
+ locale
100
+ } = _ref2;
101
+ const [isPreviewing, setIsPreviewing] = useState(false);
102
+ const license = video.custom_fields?.license ? getLicenseByNBTitle(video.custom_fields.license, locale) : "";
103
+ return /*#__PURE__*/_jsxs("li", {
104
+ children: [/*#__PURE__*/_jsxs(StyledListItemRoot, {
105
+ variant: "list",
106
+ nonInteractive: true,
107
+ children: [/*#__PURE__*/_jsx(StyledImage, {
108
+ src: video.images?.thumbnail?.src ?? "",
109
+ alt: "",
110
+ variant: "rounded"
111
+ }), /*#__PURE__*/_jsxs(StyledListItemContent, {
112
+ children: [/*#__PURE__*/_jsxs(StyledVideoMeta, {
113
+ children: [/*#__PURE__*/_jsxs(Text, {
114
+ textStyle: "title.medium",
115
+ children: [video.name, video.projection === "equirectangular" && /*#__PURE__*/_jsx(PanoramaPhotosphere, {
116
+ "aria-hidden": false,
117
+ "aria-label": translations.is360Video,
118
+ title: translations.is360Video
119
+ })]
120
+ }), /*#__PURE__*/_jsx(Text, {
121
+ children: video.custom_fields?.licenseinfo ?? ""
122
+ }), /*#__PURE__*/_jsx(License, {
123
+ license: license
124
+ })]
125
+ }), /*#__PURE__*/_jsxs(ButtonWrapper, {
126
+ children: [/*#__PURE__*/_jsx(Button, {
127
+ variant: "secondary",
128
+ size: "small",
129
+ onClick: () => setIsPreviewing(p => !p),
130
+ "aria-expanded": isPreviewing,
131
+ "aria-controls": `video-preview-${video.id}`,
132
+ children: translations.previewVideo
133
+ }), /*#__PURE__*/_jsx(Button, {
134
+ size: "small",
135
+ onClick: () => onVideoSelect(video),
136
+ children: translations.addVideo
137
+ })]
138
+ })]
139
+ })]
140
+ }), isPreviewing && /*#__PURE__*/_jsxs(PreviewWrapper, {
141
+ id: `video-preview-${video.id}`,
142
+ children: [/*#__PURE__*/_jsx("div", {}), /*#__PURE__*/_jsx(PreviewIframe, {
143
+ title: video.name,
144
+ src: `//players.brightcove.net/${video.account_id}/BkLm8fT_default/index.html?videoId=${video.id}`,
145
+ allowFullScreen: true
146
+ }), /*#__PURE__*/_jsx(StyledIconButton, {
147
+ variant: "secondary",
148
+ "aria-label": translations.close,
149
+ title: translations.close,
150
+ onClick: () => setIsPreviewing(false),
151
+ children: /*#__PURE__*/_jsx(CloseLine, {})
152
+ })]
153
+ })]
154
+ });
155
+ };