@soul-refiner/design-system 1.0.6 → 1.1.1

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.
@@ -2,10 +2,11 @@ import React from 'react';
2
2
  interface PlaylistItemProps {
3
3
  duration: number;
4
4
  onClick: () => void;
5
+ playable?: boolean;
5
6
  progress?: number;
6
7
  shortDescription: string;
7
8
  thumbnail: string;
8
9
  title: string;
9
10
  }
10
- export declare const PlaylistItem: ({ duration, onClick, progress, shortDescription, thumbnail, title, }: PlaylistItemProps) => React.JSX.Element;
11
+ export declare const PlaylistItem: ({ duration, onClick, playable, progress, shortDescription, thumbnail, title, }: PlaylistItemProps) => React.JSX.Element;
11
12
  export {};
@@ -5,8 +5,8 @@ import { Box } from '../../atoms/box';
5
5
  import { SecToDuration } from '../../atoms/seconds_to_duration';
6
6
  import { P } from '../../atoms/typography';
7
7
  import { PlaySolid } from '../../../icons/audio_video';
8
- export const PlaylistItem = ({ duration, onClick, progress = 0, shortDescription, thumbnail, title, }) => {
9
- return (React.createElement(Wrapper, { onClick: onClick },
8
+ export const PlaylistItem = ({ duration, onClick, playable, progress = 0, shortDescription, thumbnail, title, }) => {
9
+ return (React.createElement(Wrapper, { onClick: playable ? onClick : undefined, "$playable": playable },
10
10
  React.createElement(PlaySolid, { color: "white", size: 16, sx: "position: absolute; left: 8px; bottom: 4px;" }),
11
11
  React.createElement(Image, { alt: `thumbnail for ${title}`, height: 75, src: thumbnail, width: 133 }),
12
12
  React.createElement(ProgressBar, { progressPercent: progress / duration }),
@@ -24,6 +24,7 @@ const Wrapper = styled.div `
24
24
  position: relative;
25
25
  box-sizing: border-box;
26
26
  cursor: pointer;
27
+ ${({ $playable }) => $playable ? '' : 'pointer-events: none; cursor: initial;'}
27
28
  `;
28
29
  const ProgressBar = ({ progressPercent }) => (React.createElement(ProgressBarSvg, { viewBox: "0 0 133 2", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
29
30
  React.createElement("rect", { width: 133 * progressPercent, height: "2", fill: "var(--color-primary-blue-2)" }),
@@ -34,6 +34,10 @@ export interface VideoPlayerProps {
34
34
  * @param pip picture in picture is enabled
35
35
  */
36
36
  pip?: boolean;
37
+ /**
38
+ * @param playable whether the video can play
39
+ */
40
+ playable: boolean;
37
41
  /**
38
42
  * @param playlist the media items in the player
39
43
  */
@@ -55,5 +59,5 @@ export interface VideoPlayerProps {
55
59
  * ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
56
60
  * HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
57
61
  */
58
- export declare const VideoPlayer: ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }: VideoPlayerProps) => React.JSX.Element | null;
62
+ export declare const VideoPlayer: ({ activeIndex, pip, playable, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }: VideoPlayerProps) => React.JSX.Element | null;
59
63
  export {};
@@ -6,12 +6,13 @@ import styled from 'styled-components';
6
6
  import { Box } from '../../atoms/box';
7
7
  import { H, P } from '../../atoms/typography';
8
8
  import { Button } from '../../actions/button';
9
+ import { LockCircle, PlaySolid } from '../../../icons';
9
10
  import { PlaylistItem } from './playlist-item';
10
11
  /**
11
12
  * ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
12
13
  * HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
13
14
  */
14
- export const VideoPlayer = ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }) => {
15
+ export const VideoPlayer = ({ activeIndex, pip, playable, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }) => {
15
16
  const [showingAll, setShowingAll] = React.useState(false);
16
17
  const ref = React.useRef(null);
17
18
  const mediaItem = playlist?.[activeIndex];
@@ -25,11 +26,11 @@ export const VideoPlayer = ({ activeIndex, pip, playlist, onPipChange, onProgres
25
26
  if (!mediaItem)
26
27
  return null;
27
28
  return (React.createElement(Wrapper, { "$orientation": orientation },
28
- React.createElement(InnerWrapper, { "$orientation": orientation },
29
+ React.createElement(InnerWrapper, { "$orientation": orientation, "$playable": playable },
29
30
  orientation === 'vertical' && (React.createElement(Box, { "$dir": "column", "$gap": 4, sx: "margin: 24px;" },
30
31
  React.createElement(H, { as: "h2", "$bold": true, "$color": "white", "$fontSize": 28, "$lineHeight": 36 }, title),
31
32
  React.createElement(P, { as: "h3", "$bold": true, "$color": "grey-8" }, subtitle))),
32
- React.createElement(ReactPlayer, { config: {
33
+ React.createElement(ReactPlayer, { className: "player", config: {
33
34
  file: {
34
35
  attributes: {
35
36
  crossOrigin: 'true',
@@ -45,7 +46,9 @@ export const VideoPlayer = ({ activeIndex, pip, playlist, onPipChange, onProgres
45
46
  srcLang: subtitle.locale,
46
47
  })),
47
48
  },
48
- }, controls: true, height: "100%", light: React.createElement(Image, { alt: `thumbnail for ${title}`, layout: "fill", priority: true, style: { objectFit: 'contain' }, src: mediaItem.thumbnail }), onDisablePIP: () => onPipChange && onPipChange(false), onEnablePIP: () => onPipChange && onPipChange(true), onProgress: onProgress, onReady: handleReady, pip: pip, playing: true, ref: ref, style: {
49
+ }, controls: true, height: "100%", light: React.createElement(Image, { alt: `thumbnail for ${title}`, layout: "fill", priority: true, style: {
50
+ objectFit: 'contain',
51
+ }, src: mediaItem.thumbnail }), progressInterval: 4000, onDisablePIP: () => onPipChange && onPipChange(false), onEnablePIP: () => onPipChange && onPipChange(true), onProgress: onProgress, onReady: handleReady, pip: pip, playIcon: playable ? (React.createElement(PlaySolid, { color: "white", size: 24, sx: "position: absolute; width: 54px; height: 54px;" })) : (React.createElement(LockCircle, { color: "white", size: 24, sx: "position: absolute; width: 54px; height: 54px;" })), playing: playable, ref: ref, style: {
49
52
  backgroundColor: 'var(--color-grey-0)',
50
53
  maxHeight: 720,
51
54
  maxWidth: 1280,
@@ -82,6 +85,16 @@ const InnerWrapper = styled.div `
82
85
  flex: 1;
83
86
  display: flex;
84
87
  justify-content: flex-end;
88
+
89
+ ${({ $playable }) => $playable
90
+ ? ''
91
+ : `
92
+ .player {
93
+ cursor: initial;
94
+ pointer-events: none;
95
+ user-select: none;
96
+ }`}
97
+
85
98
  ${({ $orientation }) => $orientation === 'vertical'
86
99
  ? `
87
100
  flex-direction: column;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {