@soul-refiner/design-system 0.2.123 → 0.2.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/dist/components/atoms/index.d.ts +2 -0
- package/dist/components/atoms/index.js +1 -0
- package/dist/components/atoms/seconds_to_duration/index.d.ts +2 -0
- package/dist/components/atoms/seconds_to_duration/index.js +1 -0
- package/dist/components/atoms/seconds_to_duration/seconds_to_duration.d.ts +5 -0
- package/dist/components/atoms/seconds_to_duration/seconds_to_duration.js +27 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/media/index.d.ts +2 -0
- package/dist/components/media/index.js +1 -0
- package/dist/components/media/video/index.d.ts +2 -0
- package/dist/components/media/video/index.js +1 -0
- package/dist/components/media/video/playlist-item.d.ts +11 -0
- package/dist/components/media/video/playlist-item.js +36 -0
- package/dist/components/media/video/video.d.ts +57 -0
- package/dist/components/media/video/video.js +151 -0
- package/dist/components/surfaces/carousel/card/card.js +14 -1
- package/package.json +9 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Box } from './box';
|
|
2
2
|
export type { BoxProps } from './box';
|
|
3
|
+
export { SecToDuration } from './seconds_to_duration';
|
|
4
|
+
export type { SecondsToDurationProps } from './seconds_to_duration';
|
|
3
5
|
export { Display, H, P, Typography } from './typography';
|
|
4
6
|
export type { DisplayProps, HeadingProps, ParagraphProps, TypographyProps, } from './typography';
|
|
5
7
|
export { TimeAgo } from './time_ago';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SecToDuration } from './seconds_to_duration';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export const SecToDuration = ({ seconds }) => {
|
|
3
|
+
if (seconds <= 0)
|
|
4
|
+
throw new Error('Seconds cannot be less than 0');
|
|
5
|
+
if (seconds === 1)
|
|
6
|
+
return React.createElement(React.Fragment, null, "1 sec");
|
|
7
|
+
if (seconds < 60)
|
|
8
|
+
return React.createElement(React.Fragment, null,
|
|
9
|
+
seconds,
|
|
10
|
+
" secs");
|
|
11
|
+
if (Math.round(seconds / 60) === 1)
|
|
12
|
+
return React.createElement(React.Fragment, null, "1 min");
|
|
13
|
+
if (seconds < 3600)
|
|
14
|
+
return React.createElement(React.Fragment, null,
|
|
15
|
+
Math.round(seconds / 60),
|
|
16
|
+
" mins");
|
|
17
|
+
if (Math.round(seconds / 36) === 100)
|
|
18
|
+
return React.createElement(React.Fragment, null, "1 hr");
|
|
19
|
+
const hours = Math.floor(seconds / 3600);
|
|
20
|
+
const hourText = hours === 1 ? '1 hr' : `${hours} hrs`;
|
|
21
|
+
const min = Math.round((seconds % 3600) / 60);
|
|
22
|
+
const minText = min === 0 ? '' : min === 1 ? '1 min' : `${min} mins`;
|
|
23
|
+
return (React.createElement(React.Fragment, null,
|
|
24
|
+
hourText,
|
|
25
|
+
" ",
|
|
26
|
+
minText));
|
|
27
|
+
};
|
package/dist/components/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VideoPlayer } from './video';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VideoPlayer } from './video';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface PlaylistItemProps {
|
|
3
|
+
duration: number;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
progress?: number;
|
|
6
|
+
shortDescription: string;
|
|
7
|
+
thumbnail: string;
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const PlaylistItem: ({ duration, onClick, progress, shortDescription, thumbnail, title, }: PlaylistItemProps) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Box } from 'components/atoms/box';
|
|
5
|
+
import { SecToDuration } from '../../atoms/seconds_to_duration';
|
|
6
|
+
import { P } from '../../atoms/typography';
|
|
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 },
|
|
10
|
+
React.createElement(PlaySolid, { color: "white", size: 16, sx: "position: absolute; left: 8px; bottom: 4px;" }),
|
|
11
|
+
React.createElement(Image, { alt: `thumbnail for ${title}`, height: 75, src: thumbnail, width: 133 }),
|
|
12
|
+
React.createElement(ProgressBar, { progressPercent: progress / duration }),
|
|
13
|
+
React.createElement(Box, { "$dir": "column", "$gap": 4, sx: "margin-left: 16px; margin-right: auto; flex: 0 1 auto; flex-basis: content;" },
|
|
14
|
+
React.createElement(P, { "$color": "grey-10", "$semiBold": true }, title),
|
|
15
|
+
React.createElement(P, { "$color": "grey-9", "$fontSize": 14, "$lineHeight": 20, "$textClampLines": 2, sx: "max-width: min(500px, 75%);" }, shortDescription)),
|
|
16
|
+
React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, sx: "flex-shrink: 0;" },
|
|
17
|
+
React.createElement(SecToDuration, { seconds: duration }))));
|
|
18
|
+
};
|
|
19
|
+
const Wrapper = styled.div `
|
|
20
|
+
width: 100%;
|
|
21
|
+
flex: 0 1 auto;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
position: relative;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
`;
|
|
28
|
+
const ProgressBar = ({ progressPercent }) => (React.createElement(ProgressBarSvg, { viewBox: "0 0 133 2", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
29
|
+
React.createElement("rect", { width: 133 * progressPercent, height: "2", fill: "var(--color-primary-blue-2)" }),
|
|
30
|
+
React.createElement("rect", { x: 133 * progressPercent, width: 133 - 133 * progressPercent, height: "2", fill: "var(--color-grey-8)" })));
|
|
31
|
+
const ProgressBarSvg = styled.svg `
|
|
32
|
+
width: 133px;
|
|
33
|
+
position: absolute;
|
|
34
|
+
bottom: 0px;
|
|
35
|
+
left: 0px;
|
|
36
|
+
`;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface MediaItem {
|
|
3
|
+
id: string;
|
|
4
|
+
duration: number;
|
|
5
|
+
progress?: number;
|
|
6
|
+
src: string;
|
|
7
|
+
shortDescription: string;
|
|
8
|
+
thumbnail: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
11
|
+
export interface VideoPlayerProps {
|
|
12
|
+
/**
|
|
13
|
+
* @param activeIndex the media item from the playlist currently playing
|
|
14
|
+
*/
|
|
15
|
+
activeIndex: number;
|
|
16
|
+
/**
|
|
17
|
+
* @param orientation the orientation of the player
|
|
18
|
+
*/
|
|
19
|
+
orientation: 'horizontal' | 'vertical';
|
|
20
|
+
/**
|
|
21
|
+
* @param onPipChange when the pip changes
|
|
22
|
+
*/
|
|
23
|
+
onPipChange?: (pip: boolean) => void;
|
|
24
|
+
/**
|
|
25
|
+
* @param onProgress the handler as the video progresses
|
|
26
|
+
*/
|
|
27
|
+
onProgress: (progress: {
|
|
28
|
+
playedSeconds: number;
|
|
29
|
+
loadedSeconds: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* @param pip picture in picture is enabled
|
|
33
|
+
*/
|
|
34
|
+
pip?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @param playlist the media items in the player
|
|
37
|
+
*/
|
|
38
|
+
playlist: MediaItem[];
|
|
39
|
+
/**
|
|
40
|
+
* @param subtitle the video player's subtitle
|
|
41
|
+
*/
|
|
42
|
+
subtitle: string;
|
|
43
|
+
/**
|
|
44
|
+
* @param title the video player's title
|
|
45
|
+
*/
|
|
46
|
+
title: string;
|
|
47
|
+
/**
|
|
48
|
+
* @param setMediaItem sets the index of the item to be played
|
|
49
|
+
*/
|
|
50
|
+
setMediaItem: (index: number) => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
|
|
54
|
+
* HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
|
|
55
|
+
*/
|
|
56
|
+
export declare const VideoPlayer: ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }: VideoPlayerProps) => React.JSX.Element | null;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import ReactPlayer from 'react-player';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { Box } from '../../atoms/box';
|
|
7
|
+
import { H, P } from '../../atoms/typography';
|
|
8
|
+
import { Button } from '../../actions/button';
|
|
9
|
+
import { PlaylistItem } from './playlist-item';
|
|
10
|
+
/**
|
|
11
|
+
* ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
|
|
12
|
+
* HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
|
|
13
|
+
*/
|
|
14
|
+
export const VideoPlayer = ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }) => {
|
|
15
|
+
const [showingAll, setShowingAll] = React.useState(false);
|
|
16
|
+
const ref = React.useRef(null);
|
|
17
|
+
const mediaItem = playlist?.[activeIndex];
|
|
18
|
+
const handleReady = () => {
|
|
19
|
+
const currTime = ref?.current?.getCurrentTime();
|
|
20
|
+
if (currTime === 0 && mediaItem?.progress !== 0) {
|
|
21
|
+
ref.current.seekTo(mediaItem.progress);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const toggleShowingAll = () => setShowingAll((prev) => !prev);
|
|
25
|
+
if (!mediaItem)
|
|
26
|
+
return null;
|
|
27
|
+
return (React.createElement(Wrapper, { "$orientation": orientation },
|
|
28
|
+
React.createElement(InnerWrapper, { "$orientation": orientation },
|
|
29
|
+
orientation === 'vertical' && (React.createElement(Box, { "$dir": "column", "$gap": 4, sx: "margin: 24px;" },
|
|
30
|
+
React.createElement(H, { as: "h2", "$bold": true, "$color": "white", "$fontSize": 28, "$lineHeight": 36 }, title),
|
|
31
|
+
React.createElement(P, { as: "h3", "$bold": true, "$color": "grey-8" }, subtitle))),
|
|
32
|
+
React.createElement(ReactPlayer, { config: {
|
|
33
|
+
file: {
|
|
34
|
+
forceHLS: true,
|
|
35
|
+
hlsOptions: {
|
|
36
|
+
autoStartLoad: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}, controls: true, height: "100%", light: React.createElement(Image, { alt: `thumbnail for ${title}`, layout: "fill", objectFit: "contain", src: mediaItem.thumbnail }), onDisablePIP: () => onPipChange && onPipChange(false), onEnablePIP: () => onPipChange && onPipChange(true), onProgress: onProgress, onReady: handleReady, pip: pip, playing: true, ref: ref, style: {
|
|
40
|
+
maxHeight: 720,
|
|
41
|
+
maxWidth: 1280,
|
|
42
|
+
minHeight: 480,
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
position: 'relative',
|
|
45
|
+
}, url: mediaItem.src, width: "100%" }),
|
|
46
|
+
orientation === 'horizontal' && (React.createElement(Side, null,
|
|
47
|
+
React.createElement(Box, { "$dir": "column", "$gap": 4 },
|
|
48
|
+
React.createElement(H, { as: "h2", "$bold": true, "$color": "white", "$fontSize": 28, "$lineHeight": 36 }, title),
|
|
49
|
+
React.createElement(P, { as: "h3", "$bold": true, "$color": "grey-8" }, subtitle)),
|
|
50
|
+
React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px 8px 14px;" },
|
|
51
|
+
React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons")),
|
|
52
|
+
React.createElement(HorizontalPlaylistWrapper, null, playlist.map((playlistItem, index) => (React.createElement(PlaylistItem, { key: playlistItem.id, duration: playlistItem.duration, onClick: () => setMediaItem(index), progress: playlistItem.progress, shortDescription: playlistItem.shortDescription, thumbnail: playlistItem.thumbnail, title: playlistItem.title })))))),
|
|
53
|
+
orientation === 'vertical' && (React.createElement(Box, { "$dir": "column", "$gap": 24 },
|
|
54
|
+
React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px; margin: 0px 24px; border-bottom: 1px solid var(--color-grey-3);" },
|
|
55
|
+
React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons"),
|
|
56
|
+
React.createElement(Button, { onClick: toggleShowingAll, size: "small", sx: "background-color: var(--color-grey-2); border-color: var(--color-grey-8); color: var(--color-grey-8);", type: "text" }, showingAll ? 'Collapse' : 'View all')),
|
|
57
|
+
React.createElement(VerticalPlaylistWrapper, { "$showingAll": showingAll }, playlist.map((playlistItem, index) => (React.createElement(PlaylistItem, { key: playlistItem.id, duration: playlistItem.duration, onClick: () => setMediaItem(index), progress: playlistItem.progress, shortDescription: playlistItem.shortDescription, thumbnail: playlistItem.thumbnail, title: playlistItem.title })))))))));
|
|
58
|
+
};
|
|
59
|
+
const Wrapper = styled.div `
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
background-color: var(--color-grey-0);
|
|
63
|
+
|
|
64
|
+
${({ $orientation }) => $orientation === 'vertical' ? 'max-width: 960px; height: max-content;' : ''}
|
|
65
|
+
`;
|
|
66
|
+
const InnerWrapper = styled.div `
|
|
67
|
+
max-width: 2284px;
|
|
68
|
+
flex: 1;
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: flex-end;
|
|
71
|
+
${({ $orientation }) => $orientation === 'vertical'
|
|
72
|
+
? `
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: 24px;
|
|
75
|
+
justify-content: flex-start;`
|
|
76
|
+
: `
|
|
77
|
+
& > div:first-of-type {
|
|
78
|
+
flex: 5;
|
|
79
|
+
aspect-ratio: 1280 / 720;
|
|
80
|
+
}
|
|
81
|
+
& > div:last-of-type {
|
|
82
|
+
flex: 3;
|
|
83
|
+
}`}
|
|
84
|
+
`;
|
|
85
|
+
const Side = styled.div `
|
|
86
|
+
position: relative;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
padding: 24px;
|
|
91
|
+
gap: 24px;
|
|
92
|
+
`;
|
|
93
|
+
const HorizontalPlaylistWrapper = styled.div `
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 24px;
|
|
97
|
+
max-height: 548px;
|
|
98
|
+
overflow-y: auto;
|
|
99
|
+
overflow-x: hidden;
|
|
100
|
+
padding-right: 24px;
|
|
101
|
+
|
|
102
|
+
&::-webkit-scrollbar-track {
|
|
103
|
+
box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
|
|
104
|
+
-webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
background-color: var(--color-grey-2);
|
|
107
|
+
margin: 40px 0px 15px 0px;
|
|
108
|
+
}
|
|
109
|
+
&::-webkit-scrollbar {
|
|
110
|
+
width: 8px;
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
}
|
|
113
|
+
&::-webkit-scrollbar-thumb {
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
background-color: var(--color-grey-6);
|
|
116
|
+
opacity: 30%;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
const VerticalPlaylistWrapper = styled.div `
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
gap: 24px;
|
|
123
|
+
padding: 0px 12px 48px 24px;
|
|
124
|
+
margin-right: 24px;
|
|
125
|
+
max-height: 350px;
|
|
126
|
+
overflow-y: scroll;
|
|
127
|
+
overflow-x: hidden;
|
|
128
|
+
|
|
129
|
+
&::-webkit-scrollbar-track {
|
|
130
|
+
box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
|
|
131
|
+
-webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
|
|
132
|
+
border-radius: 4px;
|
|
133
|
+
background-color: var(--color-grey-2);
|
|
134
|
+
margin: 40px 0px 15px 0px;
|
|
135
|
+
}
|
|
136
|
+
&::-webkit-scrollbar {
|
|
137
|
+
width: 8px;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
}
|
|
140
|
+
&::-webkit-scrollbar-thumb {
|
|
141
|
+
border-radius: 4px;
|
|
142
|
+
background-color: var(--color-grey-6);
|
|
143
|
+
opacity: 30%;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
${({ $showingAll }) => $showingAll
|
|
147
|
+
? `
|
|
148
|
+
max-height: unset;
|
|
149
|
+
overflow-y: visible;`
|
|
150
|
+
: ''}
|
|
151
|
+
`;
|
|
@@ -44,13 +44,26 @@ const Wrapper = styled.div `
|
|
|
44
44
|
${({ $sx }) => ($sx ? $sx : '')}
|
|
45
45
|
`;
|
|
46
46
|
const Inner = styled.div `
|
|
47
|
+
position: absolute;
|
|
48
|
+
width: 100%;
|
|
49
|
+
z-index: 0;
|
|
50
|
+
top: 0px;
|
|
51
|
+
left: 0px;
|
|
47
52
|
overflow-x: scroll;
|
|
48
|
-
overflow-y:
|
|
53
|
+
overflow-y: visible;
|
|
49
54
|
display: flex;
|
|
50
55
|
gap: 24px;
|
|
51
56
|
flex-flow: row nowrap;
|
|
52
57
|
scroll-behavior: smooth;
|
|
53
58
|
padding-right: 32px;
|
|
59
|
+
margin-top: -200px;
|
|
60
|
+
padding-top: 200px;
|
|
61
|
+
margin-bottom: -200px;
|
|
62
|
+
padding-bottom: 200px;
|
|
63
|
+
|
|
64
|
+
& > * {
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
}
|
|
54
67
|
|
|
55
68
|
&::-webkit-scrollbar {
|
|
56
69
|
width: 0px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soul-refiner/design-system",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.125",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"react-dnd-html5-backend": "^16.0.1",
|
|
63
63
|
"react-dom": "^18.2.0",
|
|
64
64
|
"react-is": "^18.2.0",
|
|
65
|
+
"react-player": "^2.13.0",
|
|
65
66
|
"react-tooltip": "^5.18.0",
|
|
66
67
|
"scheduler": "^0.23.0",
|
|
67
68
|
"slate": "^0.94.1",
|
|
@@ -69,5 +70,12 @@
|
|
|
69
70
|
"slate-hyperscript": "^0.77.0",
|
|
70
71
|
"slate-react": "^0.97.1",
|
|
71
72
|
"styled-components": "^6.0.0-rc.3"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"next": "13.4.10",
|
|
76
|
+
"react": "^18.2.0",
|
|
77
|
+
"react-dom": "^18.2.0",
|
|
78
|
+
"react-player": "^2.13.0",
|
|
79
|
+
"styled-components": "^6.0.0-rc.3"
|
|
72
80
|
}
|
|
73
81
|
}
|