@bbl-digital/snorre 3.1.59 → 3.1.60
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +162 -89
- package/esm/core/MediaCarousel/index.js +5 -2
- package/esm/core/Video/Video.stories.js +10 -8
- package/esm/core/Video/index.js +71 -12
- package/esm/core/Video/styles.js +16 -7
- package/lib/core/MediaCarousel/index.d.ts +3 -1
- package/lib/core/MediaCarousel/index.d.ts.map +1 -1
- package/lib/core/MediaCarousel/index.js +5 -2
- package/lib/core/Video/Video.stories.d.ts +1 -3
- package/lib/core/Video/Video.stories.d.ts.map +1 -1
- package/lib/core/Video/Video.stories.js +10 -8
- package/lib/core/Video/index.d.ts +16 -8
- package/lib/core/Video/index.d.ts.map +1 -1
- package/lib/core/Video/index.js +71 -12
- package/lib/core/Video/styles.d.ts +5 -6
- package/lib/core/Video/styles.d.ts.map +1 -1
- package/lib/core/Video/styles.js +16 -7
- package/package.json +2 -1
@@ -10,6 +10,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
11
|
const MediaCarousel = ({
|
12
12
|
media,
|
13
|
+
autoPlay = false,
|
13
14
|
objectFit = 'contain',
|
14
15
|
height = '100%',
|
15
16
|
className,
|
@@ -25,7 +26,9 @@ const MediaCarousel = ({
|
|
25
26
|
return /*#__PURE__*/_jsx(ImageWrapper, {
|
26
27
|
height: height,
|
27
28
|
children: isVideo ? /*#__PURE__*/_jsx(Video, {
|
28
|
-
src: mediaItem.src
|
29
|
+
src: mediaItem.src,
|
30
|
+
autoPlay: autoPlay,
|
31
|
+
intersectionObserver: true
|
29
32
|
}) : /*#__PURE__*/_jsx(Image, {
|
30
33
|
src: mediaItem.src,
|
31
34
|
alt: "produktbilde",
|
@@ -44,7 +47,7 @@ const MediaCarousel = ({
|
|
44
47
|
swiping: hasMultipleImages,
|
45
48
|
dragging: hasMultipleImages,
|
46
49
|
wrapAround: true,
|
47
|
-
cellSpacing:
|
50
|
+
cellSpacing: 15,
|
48
51
|
renderCenterRightControls: ({
|
49
52
|
nextSlide
|
50
53
|
}) => hasMultipleImages && /*#__PURE__*/_jsx(ControlButton, {
|
@@ -8,24 +8,26 @@ export default {
|
|
8
8
|
export const Default = {
|
9
9
|
render: () => /*#__PURE__*/_jsx(Video, {
|
10
10
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
11
|
-
|
11
|
+
height: "100%"
|
12
12
|
})
|
13
13
|
};
|
14
14
|
export const VideoWithSrc = {
|
15
15
|
render: () => /*#__PURE__*/_jsx(Video, {
|
16
|
-
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
|
16
|
+
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
17
|
+
height: "500px"
|
17
18
|
})
|
18
19
|
};
|
19
20
|
export const VideoWithPoster = {
|
20
21
|
render: () => /*#__PURE__*/_jsx(Video, {
|
21
22
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
22
|
-
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg"
|
23
|
+
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg",
|
24
|
+
height: "500px"
|
23
25
|
})
|
24
26
|
};
|
25
|
-
export const VideoWithWidthAndHeight = {
|
26
|
-
|
27
|
+
export const VideoWithWidthAndHeight = () => {
|
28
|
+
return /*#__PURE__*/_jsx(Video, {
|
27
29
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
28
|
-
|
29
|
-
|
30
|
-
})
|
30
|
+
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg",
|
31
|
+
height: "500px"
|
32
|
+
});
|
31
33
|
};
|
package/esm/core/Video/index.js
CHANGED
@@ -1,28 +1,87 @@
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
2
|
-
import
|
3
|
-
import
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
3
|
+
import ReactPlayer from 'react-player';
|
4
|
+
import { PlayerContainer } from './styles';
|
4
5
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
5
6
|
const Video = ({
|
6
7
|
src,
|
8
|
+
intersectionObserver = false,
|
7
9
|
controls = true,
|
8
|
-
playsInline = true,
|
9
|
-
preload = 'auto',
|
10
10
|
poster,
|
11
|
+
config = {
|
12
|
+
file: {
|
13
|
+
attributes: {
|
14
|
+
controlsList: 'nodownload noplaybackrate'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
playing = false,
|
19
|
+
autoPlay = false,
|
11
20
|
height = 'auto',
|
12
21
|
width = '100%',
|
13
22
|
css,
|
23
|
+
onPause,
|
24
|
+
onPlay,
|
14
25
|
...restProps
|
15
26
|
}) => {
|
27
|
+
const containerRef = useRef(null);
|
28
|
+
|
29
|
+
/** Determines if the video controls have been physically interacted with */
|
30
|
+
const [playPressed, setPlayPressed] = useState(false);
|
31
|
+
/** The play state of the player */
|
32
|
+
const [isPlaying, setIsPlaying] = useState(playing);
|
16
33
|
const videoSrc = src || undefined;
|
17
34
|
const posterSrc = poster || undefined;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
const intersectionObsOptions = {
|
36
|
+
root: null,
|
37
|
+
rootMargin: '0px',
|
38
|
+
threshold: 0.5
|
39
|
+
};
|
40
|
+
const intersectionCallback = entries => {
|
41
|
+
const [entry] = entries;
|
42
|
+
// If the video is in the viewport and autoPlay is true or the user has physically pressed play, start playing
|
43
|
+
if (entry.isIntersecting && (autoPlay || playPressed)) {
|
44
|
+
setIsPlaying(true);
|
45
|
+
} else {
|
46
|
+
setIsPlaying(false);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
useEffect(() => {
|
50
|
+
if (!intersectionObserver || !window.IntersectionObserver) return;
|
51
|
+
const observer = new IntersectionObserver(intersectionCallback, intersectionObsOptions);
|
52
|
+
const currentRef = containerRef.current;
|
53
|
+
if (currentRef) {
|
54
|
+
observer.observe(currentRef);
|
55
|
+
}
|
56
|
+
return () => {
|
57
|
+
if (currentRef) observer.unobserve(currentRef);
|
58
|
+
};
|
59
|
+
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
61
|
+
}, [containerRef.current, intersectionObsOptions, intersectionObserver]);
|
62
|
+
const handlePlay = () => {
|
63
|
+
setPlayPressed(true);
|
64
|
+
onPlay && onPlay();
|
65
|
+
};
|
66
|
+
const handlePause = () => {
|
67
|
+
setPlayPressed(false);
|
68
|
+
onPause && onPause();
|
69
|
+
};
|
70
|
+
return _jsx(PlayerContainer, {
|
71
|
+
ref: containerRef,
|
72
|
+
children: _jsx(ReactPlayer, {
|
73
|
+
url: videoSrc,
|
74
|
+
controls: controls,
|
75
|
+
playing: isPlaying,
|
76
|
+
light: posterSrc ?? false,
|
77
|
+
width: width,
|
78
|
+
height: height,
|
79
|
+
config: config,
|
80
|
+
onPlay: handlePlay,
|
81
|
+
onPause: handlePause,
|
82
|
+
css: () => [css && css],
|
83
|
+
...restProps
|
84
|
+
})
|
26
85
|
});
|
27
86
|
};
|
28
87
|
export default Video;
|
package/esm/core/Video/styles.js
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
|
1
|
+
import _styled from "@emotion/styled/base";
|
2
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
3
|
+
export const PlayerContainer = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
|
4
|
+
target: "eryog930"
|
5
|
+
} : {
|
6
|
+
target: "eryog930",
|
7
|
+
label: "PlayerContainer"
|
8
|
+
})(process.env.NODE_ENV === "production" ? {
|
9
|
+
name: "1saf8wx",
|
10
|
+
styles: "display:flex;align-items:center;justify-content:center;width:100%;height:auto"
|
11
|
+
} : {
|
12
|
+
name: "1saf8wx",
|
13
|
+
styles: "display:flex;align-items:center;justify-content:center;width:100%;height:auto",
|
14
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYWNrYWdlcy9jb3JlL1ZpZGVvL3N0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFeUMiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL3BhY2thZ2VzL2NvcmUvVmlkZW8vc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5cbmV4cG9ydCBjb25zdCBQbGF5ZXJDb250YWluZXIgPSBzdHlsZWQuZGl2YFxuICBkaXNwbGF5OiBmbGV4O1xuICBhbGlnbi1pdGVtczogY2VudGVyO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcbiAgd2lkdGg6IDEwMCU7XG4gIGhlaWdodDogYXV0bztcbmBcbiJdfQ== */",
|
15
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
16
|
+
});
|
@@ -8,6 +8,8 @@ declare type CarouselMedia = {
|
|
8
8
|
declare type Props = {
|
9
9
|
/** The media */
|
10
10
|
media: CarouselMedia[];
|
11
|
+
/** Sets autoplay for media that is playable */
|
12
|
+
autoPlay?: boolean;
|
11
13
|
/** If the carousel should have a shadow */
|
12
14
|
withShadow?: boolean;
|
13
15
|
/** The height of the carousel */
|
@@ -19,7 +21,7 @@ declare type Props = {
|
|
19
21
|
/** The object fit of the image */
|
20
22
|
objectFit?: 'fill' | 'contain' | 'cover' | 'non' | 'scale-down' | 'initial' | 'inherit';
|
21
23
|
};
|
22
|
-
declare const MediaCarousel: ({ media, objectFit, height, className, radius, withShadow, }: Props) => React.JSX.Element;
|
24
|
+
declare const MediaCarousel: ({ media, autoPlay, objectFit, height, className, radius, withShadow, }: Props) => React.JSX.Element;
|
23
25
|
export type { CarouselMedia };
|
24
26
|
export default MediaCarousel;
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/MediaCarousel/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,aAAK,aAAa,GAAG;IACnB,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,aAAK,KAAK,GAAG;IACX,gBAAgB;IAChB,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kCAAkC;IAClC,SAAS,CAAC,EACN,MAAM,GACN,SAAS,GACT,OAAO,GACP,KAAK,GACL,YAAY,GACZ,SAAS,GACT,SAAS,CAAA;CACd,CAAA;AAED,QAAA,MAAM,aAAa,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/MediaCarousel/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,aAAK,aAAa,GAAG;IACnB,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,aAAK,KAAK,GAAG;IACX,gBAAgB;IAChB,KAAK,EAAE,aAAa,EAAE,CAAA;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kCAAkC;IAClC,SAAS,CAAC,EACN,MAAM,GACN,SAAS,GACT,OAAO,GACP,KAAK,GACL,YAAY,GACZ,SAAS,GACT,SAAS,CAAA;CACd,CAAA;AAED,QAAA,MAAM,aAAa,2EAQhB,KAAK,sBAkEP,CAAA;AACD,YAAY,EAAE,aAAa,EAAE,CAAA;AAC7B,eAAe,aAAa,CAAA"}
|
@@ -10,6 +10,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
11
11
|
const MediaCarousel = ({
|
12
12
|
media,
|
13
|
+
autoPlay = false,
|
13
14
|
objectFit = 'contain',
|
14
15
|
height = '100%',
|
15
16
|
className,
|
@@ -25,7 +26,9 @@ const MediaCarousel = ({
|
|
25
26
|
return /*#__PURE__*/_jsx(ImageWrapper, {
|
26
27
|
height: height,
|
27
28
|
children: isVideo ? /*#__PURE__*/_jsx(Video, {
|
28
|
-
src: mediaItem.src
|
29
|
+
src: mediaItem.src,
|
30
|
+
autoPlay: autoPlay,
|
31
|
+
intersectionObserver: true
|
29
32
|
}) : /*#__PURE__*/_jsx(Image, {
|
30
33
|
src: mediaItem.src,
|
31
34
|
alt: "produktbilde",
|
@@ -44,7 +47,7 @@ const MediaCarousel = ({
|
|
44
47
|
swiping: hasMultipleImages,
|
45
48
|
dragging: hasMultipleImages,
|
46
49
|
wrapAround: true,
|
47
|
-
cellSpacing:
|
50
|
+
cellSpacing: 15,
|
48
51
|
renderCenterRightControls: ({
|
49
52
|
nextSlide
|
50
53
|
}) => hasMultipleImages && /*#__PURE__*/_jsx(ControlButton, {
|
@@ -10,7 +10,5 @@ export declare const VideoWithSrc: {
|
|
10
10
|
export declare const VideoWithPoster: {
|
11
11
|
render: () => React.JSX.Element;
|
12
12
|
};
|
13
|
-
export declare const VideoWithWidthAndHeight:
|
14
|
-
render: () => React.JSX.Element;
|
15
|
-
};
|
13
|
+
export declare const VideoWithWidthAndHeight: () => React.JSX.Element;
|
16
14
|
//# sourceMappingURL=Video.stories.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Video.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/Video.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;;AAGzB,wBAGS;AAET,eAAO,MAAM,OAAO;;CAOnB,CAAA;AAED,eAAO,MAAM,YAAY;;
|
1
|
+
{"version":3,"file":"Video.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/Video.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;;AAGzB,wBAGS;AAET,eAAO,MAAM,OAAO;;CAOnB,CAAA;AAED,eAAO,MAAM,YAAY;;CAOxB,CAAA;AAED,eAAO,MAAM,eAAe;;CAQ3B,CAAA;AAED,eAAO,MAAM,uBAAuB,yBAQnC,CAAA"}
|
@@ -8,24 +8,26 @@ export default {
|
|
8
8
|
export const Default = {
|
9
9
|
render: () => /*#__PURE__*/_jsx(Video, {
|
10
10
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
11
|
-
|
11
|
+
height: "100%"
|
12
12
|
})
|
13
13
|
};
|
14
14
|
export const VideoWithSrc = {
|
15
15
|
render: () => /*#__PURE__*/_jsx(Video, {
|
16
|
-
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
|
16
|
+
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
17
|
+
height: "500px"
|
17
18
|
})
|
18
19
|
};
|
19
20
|
export const VideoWithPoster = {
|
20
21
|
render: () => /*#__PURE__*/_jsx(Video, {
|
21
22
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
22
|
-
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg"
|
23
|
+
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg",
|
24
|
+
height: "500px"
|
23
25
|
})
|
24
26
|
};
|
25
|
-
export const VideoWithWidthAndHeight = {
|
26
|
-
|
27
|
+
export const VideoWithWidthAndHeight = () => {
|
28
|
+
return /*#__PURE__*/_jsx(Video, {
|
27
29
|
src: "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",
|
28
|
-
|
29
|
-
|
30
|
-
})
|
30
|
+
poster: "https://flxt.tmsimg.com/assets/p10163210_v_h9_aa.jpg",
|
31
|
+
height: "500px"
|
32
|
+
});
|
31
33
|
};
|
@@ -1,23 +1,31 @@
|
|
1
|
-
|
2
|
-
import React from 'react';
|
1
|
+
/// <reference types="react" />
|
3
2
|
import { SerializedStyles } from '@emotion/react';
|
4
|
-
|
3
|
+
import { Config } from 'react-player';
|
4
|
+
interface IProps {
|
5
5
|
/** The source */
|
6
6
|
src?: string;
|
7
7
|
/** Controls defaults to true */
|
8
8
|
controls?: boolean;
|
9
|
-
/**
|
10
|
-
|
11
|
-
/**
|
12
|
-
|
9
|
+
/** Specify to let an Intersection Observer to auto stop or auto start the player when in the viewport */
|
10
|
+
intersectionObserver?: boolean;
|
11
|
+
/** Override config of the player */
|
12
|
+
config?: Config;
|
13
|
+
/** Set play state */
|
14
|
+
playing?: boolean;
|
15
|
+
/** Plays automatically when loaded */
|
16
|
+
autoPlay?: boolean;
|
13
17
|
/** An URL for an image to be shown while the video is downloading */
|
14
18
|
poster?: string;
|
15
19
|
/** Video height, e.g. 100px */
|
16
20
|
height?: string;
|
17
|
-
/** Video
|
21
|
+
/** Video width, e.g. 100% */
|
18
22
|
width?: string;
|
19
23
|
/** CSS override */
|
20
24
|
css?: SerializedStyles;
|
25
|
+
/** Pause callback */
|
26
|
+
onPause?: () => void;
|
27
|
+
/** Play callback */
|
28
|
+
onPlay?: () => void;
|
21
29
|
}
|
22
30
|
declare const Video: React.FC<IProps>;
|
23
31
|
export default Video;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/index.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAoB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGlD,UAAU,MAAM;IACd,iBAAiB;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,gCAAgC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,yGAAyG;IACzG,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,mBAAmB;IACnB,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CA6F3B,CAAA;AAED,eAAe,KAAK,CAAA"}
|
package/lib/core/Video/index.js
CHANGED
@@ -1,28 +1,87 @@
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
2
|
-
import
|
3
|
-
import
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
3
|
+
import ReactPlayer from 'react-player';
|
4
|
+
import { PlayerContainer } from './styles';
|
4
5
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
5
6
|
const Video = ({
|
6
7
|
src,
|
8
|
+
intersectionObserver = false,
|
7
9
|
controls = true,
|
8
|
-
playsInline = true,
|
9
|
-
preload = 'auto',
|
10
10
|
poster,
|
11
|
+
config = {
|
12
|
+
file: {
|
13
|
+
attributes: {
|
14
|
+
controlsList: 'nodownload noplaybackrate'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
},
|
18
|
+
playing = false,
|
19
|
+
autoPlay = false,
|
11
20
|
height = 'auto',
|
12
21
|
width = '100%',
|
13
22
|
css,
|
23
|
+
onPause,
|
24
|
+
onPlay,
|
14
25
|
...restProps
|
15
26
|
}) => {
|
27
|
+
const containerRef = useRef(null);
|
28
|
+
|
29
|
+
/** Determines if the video controls have been physically interacted with */
|
30
|
+
const [playPressed, setPlayPressed] = useState(false);
|
31
|
+
/** The play state of the player */
|
32
|
+
const [isPlaying, setIsPlaying] = useState(playing);
|
16
33
|
const videoSrc = src || undefined;
|
17
34
|
const posterSrc = poster || undefined;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
const intersectionObsOptions = {
|
36
|
+
root: null,
|
37
|
+
rootMargin: '0px',
|
38
|
+
threshold: 0.5
|
39
|
+
};
|
40
|
+
const intersectionCallback = entries => {
|
41
|
+
const [entry] = entries;
|
42
|
+
// If the video is in the viewport and autoPlay is true or the user has physically pressed play, start playing
|
43
|
+
if (entry.isIntersecting && (autoPlay || playPressed)) {
|
44
|
+
setIsPlaying(true);
|
45
|
+
} else {
|
46
|
+
setIsPlaying(false);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
useEffect(() => {
|
50
|
+
if (!intersectionObserver || !window.IntersectionObserver) return;
|
51
|
+
const observer = new IntersectionObserver(intersectionCallback, intersectionObsOptions);
|
52
|
+
const currentRef = containerRef.current;
|
53
|
+
if (currentRef) {
|
54
|
+
observer.observe(currentRef);
|
55
|
+
}
|
56
|
+
return () => {
|
57
|
+
if (currentRef) observer.unobserve(currentRef);
|
58
|
+
};
|
59
|
+
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
61
|
+
}, [containerRef.current, intersectionObsOptions, intersectionObserver]);
|
62
|
+
const handlePlay = () => {
|
63
|
+
setPlayPressed(true);
|
64
|
+
onPlay && onPlay();
|
65
|
+
};
|
66
|
+
const handlePause = () => {
|
67
|
+
setPlayPressed(false);
|
68
|
+
onPause && onPause();
|
69
|
+
};
|
70
|
+
return _jsx(PlayerContainer, {
|
71
|
+
ref: containerRef,
|
72
|
+
children: _jsx(ReactPlayer, {
|
73
|
+
url: videoSrc,
|
74
|
+
controls: controls,
|
75
|
+
playing: isPlaying,
|
76
|
+
light: posterSrc ?? false,
|
77
|
+
width: width,
|
78
|
+
height: height,
|
79
|
+
config: config,
|
80
|
+
onPlay: handlePlay,
|
81
|
+
onPause: handlePause,
|
82
|
+
css: () => [css && css],
|
83
|
+
...restProps
|
84
|
+
})
|
26
85
|
});
|
27
86
|
};
|
28
87
|
export default Video;
|
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
export { styles };
|
1
|
+
/// <reference types="react" />
|
2
|
+
export declare const PlayerContainer: import("@emotion/styled").StyledComponent<{
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
4
|
+
as?: import("react").ElementType<any> | undefined;
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
7
6
|
//# sourceMappingURL=styles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/styles.ts"],"names":[],"mappings":"AAEA,
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Video/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,eAAe;;;yGAM3B,CAAA"}
|
package/lib/core/Video/styles.js
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
6
|
-
|
7
|
-
|
1
|
+
import _styled from "@emotion/styled/base";
|
2
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
3
|
+
export const PlayerContainer = /*#__PURE__*/_styled("div", process.env.NODE_ENV === "production" ? {
|
4
|
+
target: "eryog930"
|
5
|
+
} : {
|
6
|
+
target: "eryog930",
|
7
|
+
label: "PlayerContainer"
|
8
|
+
})(process.env.NODE_ENV === "production" ? {
|
9
|
+
name: "1saf8wx",
|
10
|
+
styles: "display:flex;align-items:center;justify-content:center;width:100%;height:auto"
|
11
|
+
} : {
|
12
|
+
name: "1saf8wx",
|
13
|
+
styles: "display:flex;align-items:center;justify-content:center;width:100%;height:auto",
|
14
|
+
map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYWNrYWdlcy9jb3JlL1ZpZGVvL3N0eWxlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFeUMiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL3BhY2thZ2VzL2NvcmUvVmlkZW8vc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnXG5cbmV4cG9ydCBjb25zdCBQbGF5ZXJDb250YWluZXIgPSBzdHlsZWQuZGl2YFxuICBkaXNwbGF5OiBmbGV4O1xuICBhbGlnbi1pdGVtczogY2VudGVyO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjtcbiAgd2lkdGg6IDEwMCU7XG4gIGhlaWdodDogYXV0bztcbmBcbiJdfQ== */",
|
15
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
16
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@bbl-digital/snorre",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.60",
|
4
4
|
"description": "Design library for BBL Digital",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "./lib/index.js",
|
@@ -31,6 +31,7 @@
|
|
31
31
|
"react-beautiful-dnd": "^13.1.0",
|
32
32
|
"react-day-picker": "^8.3.4",
|
33
33
|
"react-images-uploading": "^3.1.7",
|
34
|
+
"react-player": "^2.12.0",
|
34
35
|
"react-stately": "^3.21.0",
|
35
36
|
"react-test-renderer": "^18.2.0",
|
36
37
|
"recharts": "2.1.16"
|