@soul-refiner/design-system 1.0.0 → 1.0.2

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.
Files changed (35) hide show
  1. package/dist/components/index.d.ts +1 -1
  2. package/dist/components/index.js +1 -1
  3. package/dist/components/media/common.d.ts +6 -0
  4. package/dist/components/media/common.js +1 -0
  5. package/dist/components/media/index.d.ts +4 -2
  6. package/dist/components/media/index.js +2 -1
  7. package/dist/components/media/video/index.d.ts +2 -2
  8. package/dist/components/media/video/index.js +1 -1
  9. package/dist/components/media/video/video.d.ts +9 -60
  10. package/dist/components/media/video/video.js +27 -161
  11. package/dist/components/media/video-player/index.d.ts +2 -0
  12. package/dist/components/media/video-player/index.js +1 -0
  13. package/dist/components/media/video-player/video.d.ts +59 -0
  14. package/dist/components/media/video-player/video.js +165 -0
  15. package/dist/components/navigation/breadcrumb/breadcrumb.js +3 -2
  16. package/dist/components/navigation/inner/inner.d.ts +1 -2
  17. package/dist/components/navigation/inner/inner.js +32 -8
  18. package/dist/components/navigation/tabs/tabs.js +3 -3
  19. package/dist/components/surfaces/calendar_date/calendar_date.d.ts +2 -1
  20. package/dist/components/surfaces/calendar_date/calendar_date.js +14 -9
  21. package/package.json +1 -1
  22. package/dist/components/hooks/click-outside.d.ts +0 -2
  23. package/dist/components/hooks/click-outside.js +0 -10
  24. package/dist/components/hooks/event-listenter.d.ts +0 -1
  25. package/dist/components/hooks/event-listenter.js +0 -15
  26. package/dist/components/hooks/hover.d.ts +0 -2
  27. package/dist/components/hooks/hover.js +0 -9
  28. package/dist/components/hooks/index.d.ts +0 -4
  29. package/dist/components/hooks/index.js +0 -4
  30. package/dist/components/hooks/window-size.d.ts +0 -4
  31. package/dist/components/hooks/window-size.js +0 -13
  32. package/dist/components/surfaces/post/helpers.d.ts +0 -1
  33. package/dist/components/surfaces/post/helpers.js +0 -26
  34. /package/dist/components/media/{video → video-player}/playlist-item.d.ts +0 -0
  35. /package/dist/components/media/{video → video-player}/playlist-item.js +0 -0
@@ -5,7 +5,7 @@ export * from './editor';
5
5
  export * from './feedback';
6
6
  export * from './iconography';
7
7
  export * from './input';
8
- export * from './media/video';
8
+ export * from './media/video-player';
9
9
  export * from './navigation';
10
10
  export * from './surfaces';
11
11
  export * from './table';
@@ -5,7 +5,7 @@ export * from './editor';
5
5
  export * from './feedback';
6
6
  export * from './iconography';
7
7
  export * from './input';
8
- export * from './media/video';
8
+ export * from './media/video-player';
9
9
  export * from './navigation';
10
10
  export * from './surfaces';
11
11
  export * from './table';
@@ -0,0 +1,6 @@
1
+ export interface Subtitle {
2
+ id: string;
3
+ label: string;
4
+ locale: string;
5
+ src: string;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
- export { VideoPlayer } from './video';
2
- export type { VideoPlayerProps } from './video';
1
+ export { Video } from './video';
2
+ export type { VideoProps } from './video';
3
+ export { VideoPlayer } from './video-player';
4
+ export type { VideoPlayerProps } from './video-player';
@@ -1 +1,2 @@
1
- export { VideoPlayer } from './video';
1
+ export { Video } from './video';
2
+ export { VideoPlayer } from './video-player';
@@ -1,2 +1,2 @@
1
- export { VideoPlayer } from './video';
2
- export type { VideoPlayerProps } from './video';
1
+ export { Video } from './video';
2
+ export type { VideoProps } from './video';
@@ -1 +1 @@
1
- export { VideoPlayer } from './video';
1
+ export { Video } from './video';
@@ -1,64 +1,13 @@
1
1
  import React from 'react';
2
- interface MediaItem {
3
- id: string;
4
- duration: number;
5
- progress?: number;
2
+ import { Subtitle } from '../common';
3
+ export interface VideoProps {
4
+ controls?: boolean;
5
+ loop?: boolean;
6
+ muted?: boolean;
7
+ playsInline?: boolean;
6
8
  src: string;
7
- subtitles: Subtitle[];
8
- shortDescription: string;
9
+ subtitles?: Subtitle[];
10
+ style?: React.CSSProperties;
9
11
  thumbnail: string;
10
- title: string;
11
12
  }
12
- interface Subtitle {
13
- id: string;
14
- label: string;
15
- locale: string;
16
- src: string;
17
- }
18
- export interface VideoPlayerProps {
19
- /**
20
- * @param activeIndex the media item from the playlist currently playing
21
- */
22
- activeIndex: number;
23
- /**
24
- * @param orientation the orientation of the player
25
- */
26
- orientation: 'horizontal' | 'vertical';
27
- /**
28
- * @param onPipChange when the pip changes
29
- */
30
- onPipChange?: (pip: boolean) => void;
31
- /**
32
- * @param onProgress the handler as the video progresses
33
- */
34
- onProgress: (progress: {
35
- playedSeconds: number;
36
- loadedSeconds: number;
37
- }) => void;
38
- /**
39
- * @param pip picture in picture is enabled
40
- */
41
- pip?: boolean;
42
- /**
43
- * @param playlist the media items in the player
44
- */
45
- playlist: MediaItem[];
46
- /**
47
- * @param subtitle the video player's subtitle
48
- */
49
- subtitle: string;
50
- /**
51
- * @param title the video player's title
52
- */
53
- title: string;
54
- /**
55
- * @param setMediaItem sets the index of the item to be played
56
- */
57
- setMediaItem: (index: number) => void;
58
- }
59
- /**
60
- * ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
61
- * HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
62
- */
63
- export declare const VideoPlayer: ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }: VideoPlayerProps) => React.JSX.Element | null;
64
- export {};
13
+ export declare const Video: ({ controls, loop, playsInline, src, subtitles, style, thumbnail, }: VideoProps) => React.JSX.Element;
@@ -1,165 +1,31 @@
1
- 'use client';
2
1
  import React from 'react';
3
- import Image from 'next/image';
4
2
  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);
3
+ import Image from 'next/image';
4
+ export const Video = ({ controls = true, loop = false, playsInline, src, subtitles, style, thumbnail, }) => {
16
5
  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
- attributes: {
35
- crossOrigin: 'true',
36
- },
37
- forceHLS: true,
38
- hlsOptions: {
39
- autoStartLoad: true,
40
- },
41
- tracks: mediaItem.subtitles.map((subtitle) => ({
42
- kind: 'subtitles',
43
- label: subtitle.label,
44
- src: subtitle.src,
45
- srcLang: subtitle.locale,
46
- })),
47
- },
48
- }, controls: true, height: "100%", light: React.createElement(Image, { alt: `thumbnail for ${title}`, layout: "fill", objectFit: "contain", priority: true, src: mediaItem.thumbnail }), onDisablePIP: () => onPipChange && onPipChange(false), onEnablePIP: () => onPipChange && onPipChange(true), onProgress: onProgress, onReady: handleReady, pip: pip, playing: true, ref: ref, style: {
49
- backgroundColor: 'var(--color-grey-0)',
50
- maxHeight: 720,
51
- maxWidth: 1280,
52
- minHeight: 480,
53
- overflow: 'hidden',
54
- position: 'relative',
55
- }, url: mediaItem.src, width: "100%" }),
56
- orientation === 'horizontal' && (React.createElement(Side, null,
57
- React.createElement(Box, { "$dir": "column", "$gap": 4 },
58
- React.createElement(H, { as: "h2", "$bold": true, "$color": "white", "$fontSize": 28, "$lineHeight": 36 }, title),
59
- React.createElement(P, { as: "h3", "$bold": true, "$color": "grey-8" }, subtitle)),
60
- React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px 8px 14px;" },
61
- React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons")),
62
- 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 })))))),
63
- orientation === 'vertical' && (React.createElement(Box, { "$dir": "column", "$gap": 24 },
64
- React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px; margin: 0px 24px; border-bottom: 1px solid var(--color-grey-3);" },
65
- React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons"),
66
- 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')),
67
- 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 })))))))));
6
+ return (React.createElement(ReactPlayer, { config: {
7
+ file: {
8
+ attributes: {
9
+ crossOrigin: 'true',
10
+ },
11
+ forceHLS: true,
12
+ hlsOptions: {
13
+ autoStartLoad: true,
14
+ },
15
+ tracks: subtitles?.map((subtitle) => ({
16
+ kind: 'subtitles',
17
+ label: subtitle.label,
18
+ src: subtitle.src,
19
+ srcLang: subtitle.locale,
20
+ })),
21
+ },
22
+ }, controls: controls, height: "100%", light: thumbnail ? (React.createElement(Image, { alt: "thumbnail for trailer", layout: "fill", objectFit: "contain", priority: true, src: thumbnail })) : undefined, loop: loop, pip: false, playsinline: playsInline, playing: true, ref: ref, style: {
23
+ backgroundColor: 'var(--color-grey-0)',
24
+ maxHeight: 720,
25
+ maxWidth: 1280,
26
+ minHeight: 480,
27
+ overflow: 'hidden',
28
+ position: 'relative',
29
+ ...(style || {}),
30
+ }, url: src, width: "100%" }));
68
31
  };
69
- const Wrapper = styled.div `
70
- display: flex;
71
- justify-content: center;
72
- background-color: var(--color-grey-0);
73
-
74
- img {
75
- object-fit: cover !important;
76
- }
77
-
78
- ${({ $orientation }) => $orientation === 'vertical' ? 'max-width: 960px; height: max-content;' : ''}
79
- `;
80
- const InnerWrapper = styled.div `
81
- max-width: 2284px;
82
- flex: 1;
83
- display: flex;
84
- justify-content: flex-end;
85
- ${({ $orientation }) => $orientation === 'vertical'
86
- ? `
87
- flex-direction: column;
88
- gap: 24px;
89
- justify-content: flex-start;`
90
- : `
91
- & > div:first-of-type {
92
- flex: 5;
93
- aspect-ratio: 1280 / 720;
94
- }
95
- & > div:last-of-type {
96
- flex: 3;
97
- }`}
98
- `;
99
- const Side = styled.div `
100
- position: relative;
101
- box-sizing: border-box;
102
- display: flex;
103
- flex-direction: column;
104
- padding: 24px;
105
- gap: 24px;
106
- `;
107
- const HorizontalPlaylistWrapper = styled.div `
108
- display: flex;
109
- flex-direction: column;
110
- gap: 24px;
111
- max-height: 548px;
112
- overflow-y: auto;
113
- overflow-x: hidden;
114
- padding-right: 24px;
115
-
116
- &::-webkit-scrollbar-track {
117
- box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
118
- -webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
119
- border-radius: 4px;
120
- background-color: var(--color-grey-2);
121
- margin: 40px 0px 15px 0px;
122
- }
123
- &::-webkit-scrollbar {
124
- width: 8px;
125
- border-radius: 4px;
126
- }
127
- &::-webkit-scrollbar-thumb {
128
- border-radius: 4px;
129
- background-color: var(--color-grey-6);
130
- opacity: 30%;
131
- }
132
- `;
133
- const VerticalPlaylistWrapper = styled.div `
134
- display: flex;
135
- flex-direction: column;
136
- gap: 24px;
137
- padding: 0px 12px 48px 24px;
138
- margin-right: 24px;
139
- max-height: 350px;
140
- overflow-y: scroll;
141
- overflow-x: hidden;
142
-
143
- &::-webkit-scrollbar-track {
144
- box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
145
- -webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
146
- border-radius: 4px;
147
- background-color: var(--color-grey-2);
148
- margin: 40px 0px 15px 0px;
149
- }
150
- &::-webkit-scrollbar {
151
- width: 8px;
152
- border-radius: 4px;
153
- }
154
- &::-webkit-scrollbar-thumb {
155
- border-radius: 4px;
156
- background-color: var(--color-grey-6);
157
- opacity: 30%;
158
- }
159
-
160
- ${({ $showingAll }) => $showingAll
161
- ? `
162
- max-height: unset;
163
- overflow-y: visible;`
164
- : ''}
165
- `;
@@ -0,0 +1,2 @@
1
+ export { VideoPlayer } from './video';
2
+ export type { VideoPlayerProps } from './video';
@@ -0,0 +1 @@
1
+ export { VideoPlayer } from './video';
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { Subtitle } from '../common';
3
+ interface MediaItem {
4
+ id: string;
5
+ duration: number;
6
+ progress?: number;
7
+ src: string;
8
+ subtitles: Subtitle[];
9
+ shortDescription: string;
10
+ thumbnail: string;
11
+ title: string;
12
+ }
13
+ export interface VideoPlayerProps {
14
+ /**
15
+ * @param activeIndex the media item from the playlist currently playing
16
+ */
17
+ activeIndex: number;
18
+ /**
19
+ * @param orientation the orientation of the player
20
+ */
21
+ orientation: 'horizontal' | 'vertical';
22
+ /**
23
+ * @param onPipChange when the pip changes
24
+ */
25
+ onPipChange?: (pip: boolean) => void;
26
+ /**
27
+ * @param onProgress the handler as the video progresses
28
+ */
29
+ onProgress: (progress: {
30
+ playedSeconds: number;
31
+ loadedSeconds: number;
32
+ }) => void;
33
+ /**
34
+ * @param pip picture in picture is enabled
35
+ */
36
+ pip?: boolean;
37
+ /**
38
+ * @param playlist the media items in the player
39
+ */
40
+ playlist: MediaItem[];
41
+ /**
42
+ * @param subtitle the video player's subtitle
43
+ */
44
+ subtitle: string;
45
+ /**
46
+ * @param title the video player's title
47
+ */
48
+ title: string;
49
+ /**
50
+ * @param setMediaItem sets the index of the item to be played
51
+ */
52
+ setMediaItem: (index: number) => void;
53
+ }
54
+ /**
55
+ * ReactPlayer props reference -> https://www.npmjs.com/package/react-player#props
56
+ * HLS Option props reference -> https://github.com/video-dev/hls.js/blob/master/docs/API.md#fine-tuning
57
+ */
58
+ export declare const VideoPlayer: ({ activeIndex, pip, playlist, onPipChange, onProgress, orientation, setMediaItem, subtitle, title, }: VideoPlayerProps) => React.JSX.Element | null;
59
+ export {};
@@ -0,0 +1,165 @@
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
+ attributes: {
35
+ crossOrigin: 'true',
36
+ },
37
+ forceHLS: true,
38
+ hlsOptions: {
39
+ autoStartLoad: true,
40
+ },
41
+ tracks: mediaItem.subtitles.map((subtitle) => ({
42
+ kind: 'subtitles',
43
+ label: subtitle.label,
44
+ src: subtitle.src,
45
+ srcLang: subtitle.locale,
46
+ })),
47
+ },
48
+ }, controls: true, height: "100%", light: React.createElement(Image, { alt: `thumbnail for ${title}`, layout: "fill", objectFit: "contain", priority: true, src: mediaItem.thumbnail }), onDisablePIP: () => onPipChange && onPipChange(false), onEnablePIP: () => onPipChange && onPipChange(true), onProgress: onProgress, onReady: handleReady, pip: pip, playing: true, ref: ref, style: {
49
+ backgroundColor: 'var(--color-grey-0)',
50
+ maxHeight: 720,
51
+ maxWidth: 1280,
52
+ minHeight: 480,
53
+ overflow: 'hidden',
54
+ position: 'relative',
55
+ }, url: mediaItem.src, width: "100%" }),
56
+ orientation === 'horizontal' && (React.createElement(Side, null,
57
+ React.createElement(Box, { "$dir": "column", "$gap": 4 },
58
+ React.createElement(H, { as: "h2", "$bold": true, "$color": "white", "$fontSize": 28, "$lineHeight": 36 }, title),
59
+ React.createElement(P, { as: "h3", "$bold": true, "$color": "grey-8" }, subtitle)),
60
+ React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px 8px 14px;" },
61
+ React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons")),
62
+ 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 })))))),
63
+ orientation === 'vertical' && (React.createElement(Box, { "$dir": "column", "$gap": 24 },
64
+ React.createElement(Box, { "$align": "center", "$justify": "space-between", sx: "padding: 8px 0px; margin: 0px 24px; border-bottom: 1px solid var(--color-grey-3);" },
65
+ React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, "$semiBold": true }, "All lessons"),
66
+ 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')),
67
+ 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 })))))))));
68
+ };
69
+ const Wrapper = styled.div `
70
+ display: flex;
71
+ justify-content: center;
72
+ background-color: var(--color-grey-0);
73
+
74
+ img {
75
+ object-fit: cover !important;
76
+ }
77
+
78
+ ${({ $orientation }) => $orientation === 'vertical' ? 'max-width: 960px; height: max-content;' : ''}
79
+ `;
80
+ const InnerWrapper = styled.div `
81
+ max-width: 2284px;
82
+ flex: 1;
83
+ display: flex;
84
+ justify-content: flex-end;
85
+ ${({ $orientation }) => $orientation === 'vertical'
86
+ ? `
87
+ flex-direction: column;
88
+ gap: 24px;
89
+ justify-content: flex-start;`
90
+ : `
91
+ & > div:first-of-type {
92
+ flex: 5;
93
+ aspect-ratio: 1280 / 720;
94
+ }
95
+ & > div:last-of-type {
96
+ flex: 3;
97
+ }`}
98
+ `;
99
+ const Side = styled.div `
100
+ position: relative;
101
+ box-sizing: border-box;
102
+ display: flex;
103
+ flex-direction: column;
104
+ padding: 24px;
105
+ gap: 24px;
106
+ `;
107
+ const HorizontalPlaylistWrapper = styled.div `
108
+ display: flex;
109
+ flex-direction: column;
110
+ gap: 24px;
111
+ max-height: 548px;
112
+ overflow-y: auto;
113
+ overflow-x: hidden;
114
+ padding-right: 24px;
115
+
116
+ &::-webkit-scrollbar-track {
117
+ box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
118
+ -webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
119
+ border-radius: 4px;
120
+ background-color: var(--color-grey-2);
121
+ margin: 40px 0px 15px 0px;
122
+ }
123
+ &::-webkit-scrollbar {
124
+ width: 8px;
125
+ border-radius: 4px;
126
+ }
127
+ &::-webkit-scrollbar-thumb {
128
+ border-radius: 4px;
129
+ background-color: var(--color-grey-6);
130
+ opacity: 30%;
131
+ }
132
+ `;
133
+ const VerticalPlaylistWrapper = styled.div `
134
+ display: flex;
135
+ flex-direction: column;
136
+ gap: 24px;
137
+ padding: 0px 12px 48px 24px;
138
+ margin-right: 24px;
139
+ max-height: 350px;
140
+ overflow-y: scroll;
141
+ overflow-x: hidden;
142
+
143
+ &::-webkit-scrollbar-track {
144
+ box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
145
+ -webkit-box-shadow: inset 0 4px 4px rgba(0, 0, 0, 0.15);
146
+ border-radius: 4px;
147
+ background-color: var(--color-grey-2);
148
+ margin: 40px 0px 15px 0px;
149
+ }
150
+ &::-webkit-scrollbar {
151
+ width: 8px;
152
+ border-radius: 4px;
153
+ }
154
+ &::-webkit-scrollbar-thumb {
155
+ border-radius: 4px;
156
+ background-color: var(--color-grey-6);
157
+ opacity: 30%;
158
+ }
159
+
160
+ ${({ $showingAll }) => $showingAll
161
+ ? `
162
+ max-height: unset;
163
+ overflow-y: visible;`
164
+ : ''}
165
+ `;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
+ import Link from 'next/link';
4
5
  import { Box } from '../../';
5
6
  import { ChevronLeft, ChevronRight } from '../../../icons';
6
7
  const Breadcrumb = ({ children, previous }) => {
@@ -28,14 +29,14 @@ const Breadcrumb = ({ children, previous }) => {
28
29
  })));
29
30
  };
30
31
  const BreadcrumbItem = ({ avatar, children, href, icon, iconColor = 'blue', onClick, }) => {
31
- return (React.createElement(Item, { as: href ? 'a' : 'div', href: href, onClick: onClick, "$type": icon ? 'icon' : avatar ? 'avatar' : 'text', "$iconColor": `hue-${iconColor}-1` },
32
+ return (React.createElement(Item, { href: href || '#', onClick: onClick, "$type": icon ? 'icon' : avatar ? 'avatar' : 'text', "$iconColor": `hue-${iconColor}-1`, scroll: false },
32
33
  icon && (React.createElement(IconWrapper, { "$color": iconColor }, React.cloneElement(icon, { color: `hue-${iconColor}-1`, size: 24 }))),
33
34
  avatar,
34
35
  children));
35
36
  };
36
37
  Breadcrumb.Item = BreadcrumbItem;
37
38
  BreadcrumbItem.displayName = 'Breadcrumb.Item';
38
- const Item = styled.div `
39
+ const Item = styled(Link) `
39
40
  display: flex;
40
41
  flex-flow: row nowrap;
41
42
  align-items: center;
@@ -9,7 +9,7 @@ declare const InnerNav: {
9
9
  displayName: string;
10
10
  };
11
11
  Dropdown: {
12
- ({ children, href, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
12
+ ({ children, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
13
13
  displayName: string;
14
14
  };
15
15
  BackButton: {
@@ -63,7 +63,6 @@ export interface InnerNavItemProps {
63
63
  * Dropdown
64
64
  */
65
65
  export interface InnerNavDropdownProps extends React.PropsWithChildren {
66
- href?: string;
67
66
  icon?: React.ReactElement;
68
67
  label: React.ReactNode;
69
68
  open: boolean;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
+ import Link from 'next/link';
3
4
  import { Button } from '../../../components/actions/button';
4
5
  import { Drawer } from '../../../components/surfaces/drawer';
5
6
  import { ChevronDown, ChevronLeft, ChevronUp, Plus } from '../../../icons';
@@ -53,12 +54,11 @@ const NavWrapper = styled.nav `
53
54
  border-right: 1px solid var(--color-grey-9);
54
55
  `;
55
56
  const InnerNavItem = ({ active, href, icon, label, sx }) => {
56
- const isAnchor = !!href;
57
- return (React.createElement(Item, { "$active": active, "$sx": sx, as: isAnchor ? 'a' : 'button', href: href },
57
+ return (React.createElement(Item, { "$active": active, "$sx": sx, href: href || '#', scroll: false },
58
58
  icon,
59
59
  label));
60
60
  };
61
- const Item = styled.button `
61
+ const Item = styled(Link) `
62
62
  padding: 14px 16px;
63
63
  display: flex;
64
64
  gap: 16px;
@@ -85,10 +85,9 @@ const Item = styled.button `
85
85
  `;
86
86
  InnerNav.Item = InnerNavItem;
87
87
  InnerNavItem.displayName = 'InnerNav.Item';
88
- const InnerNavDropdown = ({ children, href, icon, label, open, sx, onClick, }) => {
89
- const isAnchor = !!href;
88
+ const InnerNavDropdown = ({ children, icon, label, open, sx, onClick, }) => {
90
89
  return (React.createElement(React.Fragment, null,
91
- React.createElement(Item, { "$active": false, "$sx": sx, as: isAnchor ? 'a' : 'button', href: !!onClick ? undefined : href, onClick: onClick },
90
+ React.createElement(DropdownItem, { "$active": false, "$sx": sx, onClick: onClick },
92
91
  icon,
93
92
  React.createElement(DropdownTriggerWrapper, null,
94
93
  label,
@@ -108,15 +107,40 @@ const DropdownTriggerWrapper = styled.div `
108
107
  align-items: center;
109
108
  flex: 1;
110
109
  `;
110
+ const DropdownItem = styled.a `
111
+ padding: 14px 16px;
112
+ display: flex;
113
+ gap: 16px;
114
+ align-items: center;
115
+ border-radius: 8px;
116
+ font-family: var(--font-inter);
117
+ font-weight: 500;
118
+ font-size: 16px;
119
+ line-height: 24px;
120
+ color: var(--color-blue-2);
121
+ cursor: pointer;
122
+ svg {
123
+ fill: var(--color-blue-2);
124
+ }
125
+ ${({ $active }) => $active
126
+ ? `
127
+ background-color: var(--color-primary-blue-3);`
128
+ : `
129
+ &:hover {
130
+ background-color: var(--color-primary-blue-4);
131
+ }`}
132
+
133
+ ${({ $sx }) => ($sx ? $sx : '')}
134
+ `;
111
135
  InnerNav.Dropdown = InnerNavDropdown;
112
136
  InnerNavDropdown.displayName = 'InnerNav.Dropdown';
113
137
  const InnerNavBackButton = ({ href, label, sx }) => {
114
- return (React.createElement(BackButton, { href: href, "$sx": sx },
138
+ return (React.createElement(BackButton, { href: href, "$sx": sx, scroll: false },
115
139
  React.createElement("div", null,
116
140
  React.createElement(ChevronLeft, { size: 24 })),
117
141
  label));
118
142
  };
119
- const BackButton = styled.a `
143
+ const BackButton = styled(Link) `
120
144
  display: flex;
121
145
  align-items: center;
122
146
  gap: 8px;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
+ import Link from 'next/link';
4
5
  import { P } from '../../';
5
6
  const colorLookup = {
6
7
  blue: {
@@ -64,17 +65,16 @@ const Wrapper = styled.div `
64
65
  ${({ $sx }) => ($sx ? $sx : '')}
65
66
  `;
66
67
  const Item = ({ active, color, disabled, href, icon, label, onClick, size = 'large', }) => {
67
- const isAnchor = !!href;
68
68
  const inputColor = disabled ? 'grey' : color ? color : 'blue';
69
69
  const iconColor = colorLookup[inputColor].icon;
70
70
  const bgColor = colorLookup[inputColor].bg;
71
71
  const fontSize = size === 'large' ? 16 : size === 'medium' ? 14 : 12;
72
72
  const lineHeight = size === 'large' ? 24 : size === 'medium' ? 20 : 16;
73
- return (React.createElement(Element, { as: isAnchor ? 'a' : 'div', href: href, onClick: !disabled && onClick ? onClick : undefined, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
73
+ return (React.createElement(Element, { onClick: !disabled && onClick ? onClick : undefined, href: href || '#', scroll: false, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
74
74
  icon && React.createElement(IconWrapper, { "$bg": bgColor }, icon),
75
75
  React.createElement(P, { "$fontSize": fontSize, "$lineHeight": lineHeight, "$semiBold": true }, label)));
76
76
  };
77
- const Element = styled.div `
77
+ const Element = styled(Link) `
78
78
  position: relative;
79
79
  display: flex;
80
80
  align-items: center;
@@ -6,5 +6,6 @@ export interface CalendarDateProps {
6
6
  startTime?: string;
7
7
  endTime?: string;
8
8
  sx?: string;
9
+ size?: 'small' | 'large';
9
10
  }
10
- export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, }: CalendarDateProps) => React.JSX.Element;
11
+ export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, size, }: CalendarDateProps) => React.JSX.Element;
@@ -2,13 +2,15 @@
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { H, P } from '../../atoms/typography';
5
- export const CalendarDate = ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, }) => {
5
+ export const CalendarDate = ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, size = 'large', }) => {
6
6
  return (React.createElement(Container, { "$sx": sx },
7
- React.createElement(CalendarContainer, null,
8
- React.createElement(MonthContainer, null,
9
- React.createElement(H.Seven, { "$color": "white", "$textAlign": "center", sx: "font-weight: 600;" }, monthAbbreviation)),
10
- React.createElement(DateContainer, null,
11
- React.createElement(H.One, { "$textAlign": "center", sx: "font-weight: 600;" }, date))),
7
+ React.createElement(CalendarContainer, { "$size": size },
8
+ React.createElement(MonthContainer, { "$size": size },
9
+ size === 'large' && (React.createElement(H.Seven, { "$color": "white", "$textAlign": "center", "$semiBold": true }, monthAbbreviation)),
10
+ size === 'small' && (React.createElement(P, { "$color": "white", "$textAlign": "center", "$fontSize": 14 }, monthAbbreviation))),
11
+ React.createElement(DateContainer, { "$size": size },
12
+ size === 'large' && (React.createElement(H.One, { "$textAlign": "center", "$semiBold": true }, date)),
13
+ size === 'small' && (React.createElement(H.Six, { "$color": "grey-2", "$textAlign": "center" }, date)))),
12
14
  dayOfWeek && startTime && endTime && (React.createElement(TimeContainer, null,
13
15
  React.createElement(P, { as: "span", "$color": "red-5" }, `${dayOfWeek}, ${startTime} -> ${endTime}`)))));
14
16
  };
@@ -22,18 +24,21 @@ const Container = styled.div `
22
24
  const CalendarContainer = styled.div `
23
25
  display: flex;
24
26
  flex-direction: column;
25
- width: 120px;
27
+
28
+ ${({ $size }) => ($size === 'large' ? 'width: 120px;' : 'width: 64px;')}
26
29
  `;
27
30
  const MonthContainer = styled.div `
28
- padding: 8px 16px;
29
31
  background-color: var(--color-red-5);
30
32
  border-radius: 16px 16px 0 0;
33
+
34
+ ${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 8px;'}
31
35
  `;
32
36
  const DateContainer = styled.div `
33
- padding: 8px 16px;
34
37
  background-color: white;
35
38
  border-radius: 0 0 16px 16px;
36
39
  box-shadow: var(--elevation-3);
40
+
41
+ ${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 16px;'}
37
42
  `;
38
43
  const TimeContainer = styled.div `
39
44
  margin-top: 16px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const useClickOutside: (ref: React.Ref<HTMLElement>, cb: (...args: any[]) => unknown) => void;
@@ -1,10 +0,0 @@
1
- 'use client';
2
- import { useEventListener } from './event-listenter';
3
- export const useClickOutside = (ref, cb) => {
4
- useEventListener('click', (e) => {
5
- if (ref?.current == null ||
6
- ref?.current?.contains(e.target))
7
- return;
8
- cb(e);
9
- }, document);
10
- };
@@ -1 +0,0 @@
1
- export declare const useEventListener: (eventType: string, callback: (...args: any[]) => unknown, element?: Window & typeof globalThis) => void;
@@ -1,15 +0,0 @@
1
- 'use client';
2
- import React from 'react';
3
- export const useEventListener = (eventType, callback, element = window) => {
4
- const callbackRef = React.useRef(callback);
5
- React.useEffect(() => {
6
- callbackRef.current = callback;
7
- }, [callback]);
8
- React.useEffect(() => {
9
- if (element == null)
10
- return;
11
- const handler = (e) => callbackRef.current(e);
12
- element.addEventListener(eventType, handler);
13
- return () => element.removeEventListener(eventType, handler);
14
- }, [eventType, element]);
15
- };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const useHover: (ref: React.Ref<HTMLElement>) => boolean;
@@ -1,9 +0,0 @@
1
- 'use client';
2
- import React from 'react';
3
- import { useEventListener } from './event-listenter';
4
- export const useHover = (ref) => {
5
- const [hovered, setHovered] = React.useState(false);
6
- useEventListener('mouseover', () => setHovered(true), ref?.current);
7
- useEventListener('mouseout', () => setHovered(false), ref?.current);
8
- return hovered;
9
- };
@@ -1,4 +0,0 @@
1
- export { useClickOutside } from './click-outside';
2
- export { useEventListener } from './event-listenter';
3
- export { useHover } from './hover';
4
- export { useWindowSize } from './window-size';
@@ -1,4 +0,0 @@
1
- export { useClickOutside } from './click-outside';
2
- export { useEventListener } from './event-listenter';
3
- export { useHover } from './hover';
4
- export { useWindowSize } from './window-size';
@@ -1,4 +0,0 @@
1
- export declare const useWindowSize: () => {
2
- width: number;
3
- height: number;
4
- };
@@ -1,13 +0,0 @@
1
- 'use client';
2
- import React from 'react';
3
- import { useEventListener } from './event-listenter';
4
- export const useWindowSize = () => {
5
- const [windowSize, setWindowSize] = React.useState({
6
- width: window.innerWidth,
7
- height: window.innerHeight,
8
- });
9
- useEventListener('resize', () => {
10
- setWindowSize({ width: window.innerWidth, height: window.innerHeight });
11
- });
12
- return windowSize;
13
- };
@@ -1 +0,0 @@
1
- export declare const abbrTimeBeforeDate: (date: Date) => string;
@@ -1,26 +0,0 @@
1
- export const abbrTimeBeforeDate = (date) => {
2
- const now = new Date();
3
- const diff = now.getTime() - date.getTime();
4
- if (diff < 60000) {
5
- // under 1 min
6
- return 'Just now';
7
- }
8
- else if (diff < 3600000) {
9
- // under one hour
10
- const minutes = Math.floor(diff / 60000);
11
- return `${minutes} ${minutes === 1 ? 'min' : 'mins'}`;
12
- }
13
- else if (diff < 86400000) {
14
- // under one day
15
- const hours = Math.floor(diff / 3600000);
16
- return `${hours} ${hours === 1 ? 'hour' : 'hours'}`;
17
- }
18
- else if (diff < 604800000) {
19
- // under one week
20
- const days = Math.floor(diff / 86400000);
21
- return `${days} ${days === 1 ? 'day' : 'days'}`;
22
- }
23
- else {
24
- return date.toDateString().slice(4);
25
- }
26
- };