video-privacy 1.0.0-beta.1 → 1.0.0-beta.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/README.md +60 -22
- package/dist/index.js +69 -2
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,36 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
# Video Privacy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a simple React component that allows to wrap iframes in to a privacy layer that has to be acknowledged before loading external data. It was originally intended for use in [Docusaurus](https://www.docusaurus.io) but should work in any React context.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
In your project, execute
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install --save video-privacy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then, import the component where you wish to use it:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
import VideoPrivacy from "video-privacy"
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## Usage
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Simply wrap the embed code in the component, like in this example:
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
```
|
|
24
|
+
<VideoPrivacy>
|
|
25
|
+
<iframe
|
|
26
|
+
width="800"
|
|
27
|
+
height="450"
|
|
28
|
+
src="https://www.youtube.com/embed/b5c2oawLPU8"
|
|
29
|
+
title="Ontologien - was ist das eigentlich?"
|
|
30
|
+
frameborder="0"
|
|
31
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
32
|
+
referrerpolicy="strict-origin-when-cross-origin"
|
|
33
|
+
allowfullscreen
|
|
34
|
+
></iframe>
|
|
35
|
+
</VideoPrivacy>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The component can be customized with props:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
<VideoPrivacy width={1024} info="Your text goes here" imageUrl="https://your_backdrop.jpg">
|
|
42
|
+
```
|
|
22
43
|
|
|
23
|
-
##
|
|
44
|
+
## Allowed Props
|
|
24
45
|
|
|
25
|
-
|
|
46
|
+
- `width`
|
|
47
|
+
**Description:** The width of the privacy container. Should be the same as the width of the iframe to prevent awkward results.
|
|
48
|
+
**Type:** Number
|
|
49
|
+
**Default value:** 800
|
|
26
50
|
|
|
27
|
-
-
|
|
28
|
-
|
|
51
|
+
- `info`
|
|
52
|
+
**Description:** The info text the be displayed
|
|
53
|
+
**Type:** String
|
|
54
|
+
**Default value:** "Please indicate that you understand that this video is loaded from an external source."
|
|
29
55
|
|
|
30
|
-
|
|
56
|
+
- `buttonText`
|
|
57
|
+
**Description:** The text on the acknowledge button
|
|
58
|
+
**Type:** String
|
|
59
|
+
**Default value:** "I understand"
|
|
31
60
|
|
|
32
|
-
|
|
61
|
+
- `imageUrl`
|
|
62
|
+
**Description:** The URL of a preview image to be shown as backrop in the container
|
|
63
|
+
**Type:** String
|
|
64
|
+
**Default value:** _empty_
|
|
33
65
|
|
|
34
|
-
|
|
66
|
+
- `customInfoClass`
|
|
67
|
+
**Description:** A CSS class definition for styling the info text
|
|
68
|
+
**Type:** String
|
|
69
|
+
**Default value:** _empty_
|
|
35
70
|
|
|
36
|
-
|
|
71
|
+
- `customButtonClass`
|
|
72
|
+
**Description:** A CSS class definition for styling the acknowledge button
|
|
73
|
+
**Type:** String
|
|
74
|
+
**Default value:** _empty_
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,69 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var styles = ".container {\n position: relative;\n background-color: black;\n aspect-ratio: 16 / 9;\n}\n\n.backdrop {\n background-size: cover;\n width: 100%;\n height: 100%;\n filter: blur(5px);\n opacity: 0.25;\n}\n\n.content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.info {\n font-family: Arial, Helvetica, sans-serif;\n color: white;\n text-align: center;\n}\n\n.button {\n font-family: Arial, Helvetica, sans-serif;\n border: solid;\n border-width: 1px;\n border-color: white;\n border-radius: 0;\n background-color: transparent;\n padding: 10px 20px;\n color: white;\n font-weight: bold;\n cursor: pointer;\n}\n\n.button:hover {\n background-color: white;\n color: black;\n transition: all 0.3s;\n}\n";
|
|
6
|
+
|
|
7
|
+
function VideoPrivacy(props) {
|
|
8
|
+
// State to determine if the user has acknowledged the privacy notice
|
|
9
|
+
|
|
10
|
+
var _useState = useState(false),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
acknowledged = _useState2[0],
|
|
13
|
+
setAcknowledged = _useState2[1];
|
|
14
|
+
|
|
15
|
+
// Info and button text, either from props or default values
|
|
16
|
+
|
|
17
|
+
var info = props.info || "Info text";
|
|
18
|
+
var buttonText = props.buttonText || "I agree";
|
|
19
|
+
|
|
20
|
+
// Style definitions, either from module CSS or from props
|
|
21
|
+
|
|
22
|
+
var customInfoClass = styles.info;
|
|
23
|
+
if (props.customInfoClass) {
|
|
24
|
+
customInfoClass = props.customInfoClass;
|
|
25
|
+
}
|
|
26
|
+
var customButtonClass = styles.button;
|
|
27
|
+
if (props.customButtonClass) {
|
|
28
|
+
customButtonClass = props.customButtonClass;
|
|
29
|
+
}
|
|
30
|
+
var containerStyle = {
|
|
31
|
+
width: props.width || 800
|
|
32
|
+
};
|
|
33
|
+
var backdropStyle = {
|
|
34
|
+
backgroundImage: "url(".concat(props.imageUrl || "", ")")
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// If the user has acknowledged the privacy notice, render the children
|
|
38
|
+
|
|
39
|
+
if (acknowledged) {
|
|
40
|
+
return /*#__PURE__*/jsx(React.Fragment, {
|
|
41
|
+
children: props.children
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Otherwise, render the privacy notice container
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/jsxs("div", {
|
|
48
|
+
className: styles.container,
|
|
49
|
+
style: containerStyle,
|
|
50
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
51
|
+
className: styles.backdrop,
|
|
52
|
+
style: backdropStyle
|
|
53
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
54
|
+
className: styles.content,
|
|
55
|
+
children: [/*#__PURE__*/jsx("h2", {
|
|
56
|
+
className: customInfoClass,
|
|
57
|
+
children: info
|
|
58
|
+
}), /*#__PURE__*/jsx("button", {
|
|
59
|
+
className: customButtonClass,
|
|
60
|
+
onClick: function onClick() {
|
|
61
|
+
return setAcknowledged(true);
|
|
62
|
+
},
|
|
63
|
+
children: buttonText
|
|
64
|
+
})]
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { VideoPrivacy as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "video-privacy",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"rollup": "node_modules/rollup/dist/rollup.js",
|
|
6
6
|
"dev": "next dev",
|
|
@@ -31,8 +31,6 @@
|
|
|
31
31
|
"@chromatic-com/storybook": "^1.5.0",
|
|
32
32
|
"@rollup/plugin-babel": "^6.0.4",
|
|
33
33
|
"@rollup/plugin-commonjs": "^26.0.1",
|
|
34
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
35
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
36
34
|
"@semantic-release/git": "^10.0.1",
|
|
37
35
|
"@semantic-release/gitlab": "^13.1.0",
|
|
38
36
|
"@semantic-release/npm": "^12.0.1",
|
|
@@ -48,10 +46,13 @@
|
|
|
48
46
|
"eslint-config-next": "14.2.4",
|
|
49
47
|
"eslint-plugin-storybook": "^0.8.0",
|
|
50
48
|
"rollup": "^4.18.0",
|
|
49
|
+
"rollup-plugin-import-css": "^3.5.0",
|
|
51
50
|
"semantic-release": "^24.0.0",
|
|
52
51
|
"storybook": "^8.1.10"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
54
|
+
"@docusaurus/core": "^3.4.0",
|
|
55
|
+
"@docusaurus/preset-classic": "^3.4.0",
|
|
55
56
|
"next": "14.2.4",
|
|
56
57
|
"react": "^18",
|
|
57
58
|
"react-dom": "^18"
|