@soul-refiner/design-system 1.5.1 → 1.6.1-alpha.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.
- package/dist/components/actions/button/button.d.ts +1 -1
- package/dist/components/actions/dropdown/dropdown.stories.d.ts +5 -0
- package/dist/components/actions/rate/rate.js +4 -3
- package/dist/components/atoms/hide/hide.js +1 -1
- package/dist/components/card/feature/feature.js +1 -1
- package/dist/components/custom/courses_selection/courses_selection.js +5 -7
- package/dist/components/custom/courses_selection/courses_selection.stories.d.ts +5 -0
- package/dist/components/custom/users_selection/users_selection.stories.d.ts +5 -0
- package/dist/components/editor/constants.d.ts +7 -0
- package/dist/components/editor/constants.js +11 -0
- package/dist/components/editor/context.d.ts +1 -0
- package/dist/components/editor/context.js +1 -0
- package/dist/components/editor/editor.d.ts +3 -4
- package/dist/components/editor/editor.js +24 -2
- package/dist/components/editor/editor.stories.d.ts +6 -0
- package/dist/components/editor/navbar/index.d.ts +0 -1
- package/dist/components/editor/navbar/navbar.d.ts +1 -4
- package/dist/components/editor/navbar/navbar.js +3 -12
- package/dist/components/editor/plugins/blocks/image.d.ts +8 -2
- package/dist/components/editor/plugins/blocks/image.js +35 -32
- package/dist/components/editor/plugins/blocks/media-popover.d.ts +6 -0
- package/dist/components/editor/plugins/blocks/media-popover.js +32 -0
- package/dist/components/editor/plugins/plate.d.ts +26 -1
- package/dist/components/editor/plugins/plate.js +3 -0
- package/dist/components/iconography/avatar/avatar.d.ts +2 -1
- package/dist/components/iconography/avatar/avatar.js +3 -2
- package/dist/components/iconography/avatar/avatar.stories.d.ts +7 -0
- package/dist/components/iconography/avatar/icons/default.js +2 -3
- package/dist/components/input/text_input/text_input.d.ts +1 -0
- package/dist/components/media/video-player/playlist-item.d.ts +2 -2
- package/dist/components/media/video-player/playlist-item.js +6 -6
- package/dist/components/media/video-player/video.d.ts +13 -3
- package/dist/components/media/video-player/video.js +28 -9
- package/dist/components/media/video-player/video.stories.d.ts +6 -0
- package/dist/components/surfaces/carousel/card/card.js +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +90 -0
- package/dist/styles/output.css +48 -0
- package/package.json +6 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconProps } from '../../';
|
|
3
|
-
type NativeProps = Pick<React.HTMLAttributes<HTMLButtonElement>, 'dangerouslySetInnerHTML' | 'onClick' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver'> & {
|
|
3
|
+
type NativeProps = Pick<React.HTMLAttributes<HTMLButtonElement>, 'dangerouslySetInnerHTML' | 'onClick' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver' | 'onSubmit' | 'onKeyDown'> & {
|
|
4
4
|
value?: string;
|
|
5
5
|
};
|
|
6
6
|
type ButtonTypes = 'primary' | 'secondary' | 'outlined' | 'danger' | 'text' | 'raised' | 'special' | 'dropdown';
|
|
@@ -6,6 +6,7 @@ const LG_WIDTH = 147;
|
|
|
6
6
|
const SM_HEIGHT = 16;
|
|
7
7
|
const LG_HEIGHT = 24;
|
|
8
8
|
export const Rate = ({ isRateable = true, onRate, percent, size, userRating, }) => {
|
|
9
|
+
const componentId = React.useId();
|
|
9
10
|
const ref = React.useRef(null);
|
|
10
11
|
const [hoveredRating, setHoveredRating] = React.useState();
|
|
11
12
|
const width = size === 'small' ? SM_WIDTH : LG_WIDTH;
|
|
@@ -32,15 +33,15 @@ export const Rate = ({ isRateable = true, onRate, percent, size, userRating, })
|
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
return (React.createElement("div", { ref: ref },
|
|
35
|
-
React.createElement(SVG, { width: width, height: height, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, onClick: handleClick, viewBox: "0 0 98 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
36
|
+
React.createElement(SVG, { "$gradientId": componentId, width: width, height: height, onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, onClick: handleClick, viewBox: "0 0 98 16", xmlns: "http://www.w3.org/2000/svg" },
|
|
36
37
|
React.createElement("path", { d: "M13.1437 16L8.61569 13.5529C8.55281 13.5529 8.48992 13.4902 8.42703 13.4902C8.36414 13.4902 8.30125 13.5529 8.23837 13.5529L3.64752 15.9373C3.58463 16 3.52174 16 3.39597 16C3.33308 16 3.27019 16 3.2073 15.9373C3.14441 15.8745 3.08153 15.8118 3.08153 15.749C3.08153 15.6863 3.01864 15.6235 3.08153 15.5608L3.96196 10.4784C3.96196 10.4157 3.96196 10.3529 3.89907 10.2902C3.89907 10.2275 3.83619 10.1647 3.83619 10.102L0.125777 6.52549C0.0628883 6.46275 0 6.4 0 6.33726C0 6.21177 0 6.14902 0 6.08628C0.0628883 6.02353 0.0628883 5.96079 0.125777 5.89804C0.188665 5.83529 0.251553 5.83529 0.37733 5.83529L5.47128 5.08235C5.53417 5.08235 5.59706 5.01961 5.65995 5.01961C5.65995 4.95686 5.72283 4.89412 5.78572 4.83137L8.0497 0.25098C8.11259 0.188235 8.11259 0.12549 8.17548 0.0627451C8.23837 0.0627451 8.36414 0 8.42703 0C8.48992 0 8.55281 0.0627451 8.61569 0.0627451C8.67858 0.12549 8.74147 0.188235 8.80436 0.25098L11.0683 4.89412C11.0683 4.89412 11.1312 4.95686 11.1941 5.01961C11.257 5.01961 11.3199 5.08235 11.3828 5.08235L16.4767 5.83529C16.5396 5.83529 16.6025 5.89804 16.6654 5.89804C16.7283 5.96079 16.7912 6.02353 16.7912 6.08628C16.8541 6.14902 16.8541 6.27451 16.7912 6.33726C16.7912 6.4 16.7283 6.46275 16.7283 6.52549L13.0179 10.102C12.955 10.1647 12.8921 10.2275 12.8921 10.2902C12.8921 10.3529 12.8921 10.4157 12.8921 10.4784L13.7725 15.5608C13.7725 15.6235 13.7725 15.6863 13.7096 15.749C13.7096 15.8118 13.6468 15.8745 13.5839 15.9373C13.521 16 13.4581 16 13.3952 16C13.3323 16 13.2065 16 13.1437 16Z M33.711 16L29.1201 13.5529C29.0572 13.5529 28.9943 13.4902 28.9315 13.4902C28.8686 13.4902 28.8057 13.5529 28.7428 13.5529L24.2148 15.9373C24.1519 16 24.0262 16 23.9633 16C23.9004 16 23.8375 15.9373 23.7746 15.9373C23.7117 15.8745 23.6488 15.8118 23.6488 15.749C23.5859 15.6863 23.5859 15.6235 23.5859 15.498L24.4664 10.4157C24.4664 10.3529 24.4664 10.2902 24.4664 10.2275C24.4664 10.1647 24.4035 10.102 24.3406 10.102L20.6931 6.46275C20.6302 6.4 20.5673 6.33725 20.5673 6.27451C20.5673 6.21176 20.5673 6.14902 20.5673 6.08628C20.5673 6.02353 20.6302 5.96079 20.6931 5.89804C20.756 5.83529 20.8189 5.83529 20.8818 5.77255L26.0386 5.08235C26.1015 5.01961 26.1644 5.01961 26.1644 4.95686C26.2273 4.95686 26.2901 4.89412 26.2901 4.83137L28.617 0.25098C28.617 0.12549 28.6799 0.12549 28.7428 0.0627451C28.8057 -7.45058e-09 28.8686 0 28.9315 0C29.0572 0 29.1201 -7.45058e-09 29.183 0.0627451C29.2459 0.12549 29.3088 0.12549 29.3088 0.25098L31.6356 4.83137C31.6356 4.89412 31.6985 4.95686 31.7614 5.01961C31.7614 5.01961 31.8243 5.08235 31.8872 5.08235L37.044 5.83529C37.1069 5.83529 37.1698 5.83529 37.2327 5.89804C37.2956 5.96079 37.2956 6.02353 37.3585 6.08628C37.3585 6.14902 37.3585 6.21176 37.3585 6.27451C37.3585 6.4 37.2956 6.46275 37.2327 6.52549L33.5223 10.102C33.5223 10.1647 33.4594 10.1647 33.4594 10.2275C33.3965 10.2902 33.3965 10.3529 33.4594 10.4784L34.277 15.5608C34.3398 15.6235 34.277 15.6863 34.277 15.749C34.277 15.8118 34.2141 15.8745 34.1512 15.9373C34.0883 16 34.0254 16 33.9625 16C33.8367 16 33.7738 16 33.711 16Z M53.5187 16L48.9279 13.5529C48.865 13.5529 48.8021 13.4902 48.7392 13.4902C48.6763 13.4902 48.6134 13.5529 48.5505 13.5529L44.0226 15.9373C43.9597 16 43.8968 16 43.8339 16C43.7081 16 43.6452 16 43.5824 15.9373C43.5195 15.8745 43.5195 15.8118 43.4566 15.749C43.4566 15.6863 43.4566 15.6235 43.4566 15.5608L44.337 10.4784C44.337 10.4157 44.337 10.3529 44.2741 10.2902C44.2741 10.2275 44.2741 10.1647 44.2112 10.102L40.5008 6.52549C40.4379 6.46275 40.4379 6.4 40.375 6.33726C40.375 6.21177 40.375 6.14902 40.375 6.08628C40.4379 6.02353 40.4379 5.96079 40.5008 5.89804C40.5637 5.83529 40.6266 5.83529 40.7524 5.83529L45.8463 5.08235C45.9092 5.08235 45.9721 5.01961 46.035 5.01961C46.0979 4.95686 46.0979 4.89412 46.1608 4.83137L48.4248 0.25098C48.4876 0.188235 48.4876 0.12549 48.5505 0.0627451C48.6134 0.0627451 48.7392 0 48.8021 0C48.865 0 48.9279 0.0627451 48.9907 0.0627451C49.0536 0.12549 49.1165 0.188235 49.1794 0.25098L51.4434 4.89412C51.4434 4.89412 51.5063 4.95686 51.5692 5.01961C51.6321 5.01961 51.6949 5.08235 51.7578 5.08235L56.8518 5.83529C56.9147 5.83529 56.9776 5.89804 57.0404 5.89804C57.1033 5.96079 57.1662 6.02353 57.1662 6.08628C57.1662 6.14902 57.2291 6.27451 57.1662 6.33726C57.1662 6.4 57.1033 6.46275 57.1033 6.52549L53.3929 10.102C53.33 10.1647 53.2671 10.2275 53.2671 10.2902C53.2671 10.3529 53.2671 10.4157 53.2671 10.4784L54.0847 15.5608C54.0847 15.6235 54.0847 15.6863 54.0847 15.749C54.0218 15.8118 53.9589 15.8745 53.896 15.9373C53.896 15.9373 53.7703 16 53.7074 16C53.6445 16 53.5816 16 53.5187 16Z M74.0858 16L69.4949 13.5529C69.4321 13.5529 69.3692 13.4902 69.3063 13.4902C69.2434 13.4902 69.1805 13.5529 69.1176 13.5529L64.5268 15.9373C64.4639 16 64.401 16 64.3381 16C64.2752 16 64.1494 15.9373 64.0865 15.9373C64.0865 15.8745 64.0237 15.8118 63.9608 15.749C63.9608 15.6863 63.9608 15.6235 63.9608 15.498L64.8412 10.4157C64.8412 10.3529 64.8412 10.2902 64.8412 10.2275C64.7783 10.1647 64.7783 10.102 64.7154 10.102L61.005 6.52549C60.9421 6.46275 60.9421 6.4 60.8792 6.33726C60.8792 6.21177 60.8792 6.14902 60.8792 6.08628C60.9421 6.02353 60.9421 5.96079 61.005 5.89804C61.0679 5.83529 61.1308 5.83529 61.2566 5.83529L66.3505 5.08235C66.4134 5.08235 66.4763 5.01961 66.5392 5.01961C66.6021 4.95686 66.6021 4.89412 66.665 4.83137L68.9289 0.25098C68.9918 0.188235 68.9918 0.12549 69.0547 0.0627451C69.1176 0.0627451 69.2434 0 69.3063 0C69.3692 0 69.4321 0.0627451 69.4949 0.0627451C69.5578 0.12549 69.6207 0.188235 69.6836 0.25098L71.9476 4.89412C71.9476 4.89412 72.0105 4.95686 72.0734 5.01961C72.1362 5.01961 72.1991 5.08235 72.262 5.08235L77.356 5.83529C77.4189 5.83529 77.4818 5.89804 77.5446 5.89804C77.6075 5.96079 77.6704 6.02353 77.6704 6.08628C77.7333 6.14902 77.7333 6.27451 77.6704 6.33726C77.6704 6.4 77.6075 6.46275 77.6075 6.52549L73.8971 10.102C73.8342 10.1647 73.7713 10.2275 73.7713 10.2902C73.7713 10.3529 73.7713 10.4157 73.7713 10.4784L74.6518 15.5608C74.6518 15.6235 74.6518 15.6863 74.5889 15.749C74.5889 15.8118 74.526 15.8745 74.4631 15.9373C74.4002 15.9373 74.3373 16 74.2744 16C74.2116 16 74.1487 16 74.0858 16Z M94.0831 16L89.5551 13.5529C89.4922 13.5529 89.4294 13.4902 89.3665 13.4902C89.3036 13.4902 89.2407 13.5529 89.1778 13.5529L84.587 15.9373C84.5241 16 84.4612 16 84.3983 16C84.2725 16 84.2096 15.9373 84.1468 15.9373C84.0839 15.8745 84.0839 15.8118 84.021 15.749C84.021 15.6863 84.021 15.6235 84.021 15.498L84.9014 10.4157C84.9014 10.3529 84.9014 10.2902 84.8385 10.2275C84.8385 10.1647 84.8385 10.102 84.7756 10.102L81.0652 6.46275C81.0023 6.4 81.0023 6.33725 80.9395 6.27451C80.9395 6.21176 80.9395 6.14902 80.9395 6.08628C81.0023 6.02353 81.0023 5.96079 81.0652 5.89804C81.1281 5.83529 81.191 5.83529 81.3168 5.77255L86.4107 5.08235C86.4736 5.01961 86.5365 5.01961 86.5994 4.95686C86.6623 4.95686 86.6623 4.89412 86.7252 4.83137L88.9892 0.25098C89.052 0.12549 89.1149 0.12549 89.1778 0.0627451C89.2407 -7.45058e-09 89.3036 0 89.3665 0C89.4294 0 89.4922 -7.45058e-09 89.5551 0.0627451C89.618 0.12549 89.6809 0.12549 89.7438 0.25098L92.0078 4.83137C92.0078 4.89412 92.0707 4.95686 92.1336 5.01961C92.1965 5.01961 92.2593 5.08235 92.3222 5.08235L97.4162 5.83529C97.4791 5.83529 97.542 5.83529 97.6048 5.89804C97.6677 5.96079 97.7306 6.02353 97.7306 6.08628C97.7935 6.14902 97.7935 6.21176 97.7306 6.27451C97.7306 6.4 97.6677 6.46275 97.6677 6.52549L93.9573 10.102C93.8944 10.1647 93.8315 10.1647 93.8315 10.2275C93.8315 10.2902 93.8315 10.3529 93.8315 10.4784L94.712 15.5608C94.712 15.6235 94.712 15.6863 94.6491 15.749C94.6491 15.8118 94.5862 15.8745 94.5233 15.9373C94.4604 16 94.3975 16 94.3346 16C94.2718 16 94.146 16 94.0831 16Z", stroke: "#D0D2D6", strokeWidth: "0.42154" }),
|
|
37
38
|
React.createElement("defs", null,
|
|
38
|
-
React.createElement("linearGradient", { id:
|
|
39
|
+
React.createElement("linearGradient", { id: componentId },
|
|
39
40
|
React.createElement("stop", { offset: "0%", stopColor: "#FFB51F" }),
|
|
40
41
|
React.createElement("stop", { offset: `${displayPercent}%`, stopColor: "#FF870A" }),
|
|
41
42
|
React.createElement("stop", { offset: `${displayPercent}%`, stopColor: "#FFFFFF" }))))));
|
|
42
43
|
};
|
|
43
44
|
const SVG = styled.svg `
|
|
44
|
-
fill: url(
|
|
45
|
+
fill: url(#${({ $gradientId }) => $gradientId});
|
|
45
46
|
cursor: ${({ $isRateable }) => ($isRateable ? 'pointer' : 'initial')};
|
|
46
47
|
`;
|
|
@@ -3,7 +3,7 @@ export const HideButRender = ({ children, displaceContent = false, show = false,
|
|
|
3
3
|
return (React.createElement("div", { style: {
|
|
4
4
|
visibility: show ? 'visible' : 'hidden',
|
|
5
5
|
position: displaceContent || show ? 'initial' : 'absolute',
|
|
6
|
-
zIndex: -100,
|
|
6
|
+
zIndex: show ? 'initial' : -100,
|
|
7
7
|
...styles,
|
|
8
8
|
} }, children));
|
|
9
9
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import Image from 'next/image';
|
|
3
4
|
import styled from 'styled-components';
|
|
4
5
|
import { Button, P, Box, H } from '../..';
|
|
5
6
|
import { GraduationCap, Search as SearchIcon, Plus, Close, } from '../../../icons';
|
|
@@ -55,7 +56,10 @@ export const CoursesSelection = ({ closeOnChange = true, closeOnBlur = true, dis
|
|
|
55
56
|
alignItems: 'center',
|
|
56
57
|
marginTop: '16px',
|
|
57
58
|
} },
|
|
58
|
-
React.createElement(
|
|
59
|
+
React.createElement(Image, { alt: "", height: 64, width: 114, src: course.imageSrc, quality: 100, style: {
|
|
60
|
+
borderRadius: '8px',
|
|
61
|
+
marginRight: '16px',
|
|
62
|
+
} }),
|
|
59
63
|
React.createElement(P, { sx: "margin-left: 16px;" }, course.name),
|
|
60
64
|
React.createElement(Close, { sx: "cursor: pointer; margin-left: auto;", onClick: () => setCourseIsSelected({
|
|
61
65
|
...courseIsSelected,
|
|
@@ -115,12 +119,6 @@ const OptionWrapper = styled.div `
|
|
|
115
119
|
`;
|
|
116
120
|
}}
|
|
117
121
|
`;
|
|
118
|
-
const StyledImage = styled.img `
|
|
119
|
-
border-radius: 8px;
|
|
120
|
-
width: 113.78px;
|
|
121
|
-
height: 64px;
|
|
122
|
-
margin-right: 16px;
|
|
123
|
-
`;
|
|
124
122
|
const IconWrapper = styled.div `
|
|
125
123
|
padding: 12px;
|
|
126
124
|
border-radius: 8px;
|
|
@@ -7,6 +7,7 @@ export declare const EditorContext: React.Context<{
|
|
|
7
7
|
questionAnswerId: string;
|
|
8
8
|
}) => React.ReactElement;
|
|
9
9
|
handleVideoClick?: ((id: number) => void) | undefined;
|
|
10
|
+
imageSrcLoader: (id: number) => Promise<string>;
|
|
10
11
|
videoTitleLoader: (props: {
|
|
11
12
|
courseMediaId: number;
|
|
12
13
|
}) => React.ReactElement;
|
|
@@ -3,5 +3,6 @@ export const EditorContext = React.createContext({
|
|
|
3
3
|
commentInputLoader: () => React.createElement(React.Fragment, null),
|
|
4
4
|
commentLoader: () => React.createElement(React.Fragment, null),
|
|
5
5
|
handleVideoClick: () => undefined,
|
|
6
|
+
imageSrcLoader: async () => '',
|
|
6
7
|
videoTitleLoader: () => React.createElement(React.Fragment, null),
|
|
7
8
|
});
|
|
@@ -7,10 +7,9 @@ export interface EditorProps {
|
|
|
7
7
|
commentLoader: (props: {
|
|
8
8
|
questionAnswerId: string;
|
|
9
9
|
}) => React.ReactElement;
|
|
10
|
-
communityName: string;
|
|
11
10
|
editable: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
handleVideoClick: (id: number) => void;
|
|
12
|
+
imageSrcLoader: (id: number) => Promise<string>;
|
|
14
13
|
onChange: (newNodes: TElement[]) => void;
|
|
15
14
|
previousContent?: TElement[];
|
|
16
15
|
videoTitleLoader: (props: {
|
|
@@ -18,4 +17,4 @@ export interface EditorProps {
|
|
|
18
17
|
}) => React.ReactElement;
|
|
19
18
|
}
|
|
20
19
|
export type EditorContent = TElement;
|
|
21
|
-
export declare const Editor: ({ commentInputLoader, commentLoader, editable,
|
|
20
|
+
export declare const Editor: ({ commentInputLoader, commentLoader, editable, handleVideoClick, imageSrcLoader, onChange, previousContent, videoTitleLoader, }: EditorProps) => React.JSX.Element;
|
|
@@ -10,16 +10,17 @@ import { blocks, leafs, marks, utils } from './plugins';
|
|
|
10
10
|
const plugins = createPlugins([...blocks, ...leafs, ...marks, ...utils], {
|
|
11
11
|
components: plateUI,
|
|
12
12
|
});
|
|
13
|
-
export const Editor = ({ commentInputLoader, commentLoader, editable,
|
|
13
|
+
export const Editor = ({ commentInputLoader, commentLoader, editable, handleVideoClick, imageSrcLoader, onChange, previousContent, videoTitleLoader, }) => {
|
|
14
14
|
return (React.createElement(EditorContext.Provider, { value: {
|
|
15
15
|
commentInputLoader,
|
|
16
16
|
commentLoader,
|
|
17
17
|
handleVideoClick,
|
|
18
|
+
imageSrcLoader,
|
|
18
19
|
videoTitleLoader,
|
|
19
20
|
} },
|
|
20
21
|
React.createElement(Plate, { id: "main", initialValue: previousContent, onChange: onChange, plugins: plugins },
|
|
21
22
|
React.createElement(Wrapper, null,
|
|
22
|
-
editable && React.createElement(EditorBar,
|
|
23
|
+
editable && React.createElement(EditorBar, null),
|
|
23
24
|
React.createElement(PlateContent, { id: "main", autoFocus: true, placeholder: PLACEHOLDER, readOnly: !editable, spellCheck: true, onContextMenu: (e) => e.preventDefault(), onCopy: () => {
|
|
24
25
|
if ('clipboard' in navigator) {
|
|
25
26
|
return navigator.clipboard.writeText('');
|
|
@@ -52,6 +53,27 @@ const Wrapper = styled.div `
|
|
|
52
53
|
color: var(--color-grey-3);
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
ul {
|
|
57
|
+
padding-left: 24px;
|
|
58
|
+
|
|
59
|
+
li {
|
|
60
|
+
list-style-type: disc;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ol {
|
|
65
|
+
padding-left: 24px;
|
|
66
|
+
|
|
67
|
+
li {
|
|
68
|
+
list-style-type: decimal;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
a {
|
|
73
|
+
text-decoration: underline;
|
|
74
|
+
color: var(--color-primary-blue-1);
|
|
75
|
+
}
|
|
76
|
+
|
|
55
77
|
.slate-code {
|
|
56
78
|
& > * {
|
|
57
79
|
font-family: 'Roboto Mono';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export
|
|
3
|
-
handleUploadImage?: (files: FileList) => Promise<string>;
|
|
4
|
-
}
|
|
5
|
-
export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
|
|
2
|
+
export declare const EditorBar: () => React.JSX.Element;
|
|
6
3
|
export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
7
4
|
$active?: boolean | undefined;
|
|
8
5
|
}>>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { getPluginType,
|
|
3
|
+
import { getPluginType, insertNodes, insertTable, toggleNodeType, useLinkToolbarButton, useLinkToolbarButtonState, useListToolbarButton, useListToolbarButtonState, useMarkToolbarButton, useMarkToolbarButtonState, useEditorRef, useEditorState, } from '@udecode/plate';
|
|
4
4
|
import { Tooltip } from '../../';
|
|
5
5
|
import { Bold, FileCode, Grid, Headphones, Image, Italic, Link, ListOrdered, ListUnordered, Quote, Redo, Strikethrough, Underline, Undo, Video, } from '../../../icons';
|
|
6
6
|
import { ELEMENT_BLOCKQUOTE, ELEMENT_BUTTON, ELEMENT_OL, ELEMENT_UL, MARK_BOLD, MARK_CODE, MARK_ITALIC, MARK_STRIKETHROUGH, MARK_UNDERLINE, } from '../constants';
|
|
7
7
|
import { AlignmentDropdown } from './alignment_dropdown';
|
|
8
8
|
import { ButtonModal } from './button_modal';
|
|
9
9
|
import { StyleDropdown } from './style_dropdown';
|
|
10
|
-
export const EditorBar = (
|
|
10
|
+
export const EditorBar = () => {
|
|
11
11
|
const editorRef = useEditorRef('main');
|
|
12
12
|
const stateEditor = useEditorState();
|
|
13
13
|
const audioRef = React.useRef(null);
|
|
@@ -59,15 +59,6 @@ export const EditorBar = ({ handleUploadImage }) => {
|
|
|
59
59
|
},
|
|
60
60
|
]);
|
|
61
61
|
};
|
|
62
|
-
const handleImageChange = async () => {
|
|
63
|
-
const files = imageRef.current?.files;
|
|
64
|
-
if (!files || !handleUploadImage)
|
|
65
|
-
return;
|
|
66
|
-
const imageurl = await handleUploadImage(files);
|
|
67
|
-
if (imageurl) {
|
|
68
|
-
insertImage(editorRef, imageurl);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
62
|
const handleRedo = () => editorRef.redo();
|
|
72
63
|
const handleUndo = () => editorRef.undo();
|
|
73
64
|
const handleVideoChange = async () => {
|
|
@@ -117,7 +108,7 @@ export const EditorBar = ({ handleUploadImage }) => {
|
|
|
117
108
|
React.createElement(MenuButton, { "$active": currLink, onClick: handleLink },
|
|
118
109
|
React.createElement(Link, { size: 24, color: "grey-5" }))),
|
|
119
110
|
React.createElement(Tooltip, { content: "Image", place: "top" },
|
|
120
|
-
React.createElement(MenuButton, { "$active": false, as: "label"
|
|
111
|
+
React.createElement(MenuButton, { "$active": false, as: "label" },
|
|
121
112
|
React.createElement("div", { onClick: () => imageRef.current?.click() },
|
|
122
113
|
React.createElement("input", { accept: "image/*", ref: imageRef, style: { display: 'none' }, type: "file" }),
|
|
123
114
|
React.createElement(Image, { size: 24, color: "grey-5" })))),
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare const ImageElement: React.ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
3
|
+
element: import("@udecode/slate").TElement;
|
|
4
|
+
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
5
|
+
as?: React.ElementType<any> | undefined;
|
|
6
|
+
asChild?: boolean | undefined;
|
|
7
|
+
} & React.RefAttributes<any> & {
|
|
8
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<any>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
import { cn, withRef } from '@udecode/cn';
|
|
3
|
+
import { PlateElement, withHOC } from '@udecode/plate-common';
|
|
4
|
+
import { ELEMENT_IMAGE, Image, useMediaState } from '@udecode/plate-media';
|
|
5
|
+
import { ResizableProvider } from '@udecode/plate-resizable';
|
|
6
|
+
import { MediaPopover } from './media-popover';
|
|
7
|
+
import { mediaResizeHandleVariants, Resizable, ResizeHandle, } from './resizable';
|
|
8
|
+
import { EditorContext } from '../../context';
|
|
9
|
+
export const ImageElement = withHOC(ResizableProvider, withRef(({ className, children, element, nodeProps, ...props }, ref) => {
|
|
10
|
+
const { imageSrcLoader } = React.useContext(EditorContext);
|
|
11
|
+
const { readOnly, focused, selected, align = 'center' } = useMediaState();
|
|
12
|
+
const { id, url, ...restElement } = element;
|
|
13
|
+
const [src, setSrc] = React.useState(null);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
if (!id || !imageSrcLoader)
|
|
17
|
+
return;
|
|
18
|
+
const source = await imageSrcLoader(id);
|
|
19
|
+
if (source)
|
|
20
|
+
setSrc(source);
|
|
21
|
+
})();
|
|
22
|
+
}, [id, imageSrcLoader]);
|
|
23
|
+
return (React.createElement(MediaPopover, { pluginKey: ELEMENT_IMAGE },
|
|
24
|
+
React.createElement(PlateElement, { ref: ref, className: cn('py-2.5', className), element: restElement, ...props },
|
|
25
|
+
!src ? null : (React.createElement("figure", { className: "group relative m-0", contentEditable: false },
|
|
26
|
+
React.createElement(Resizable, { align: align, options: {
|
|
27
|
+
align,
|
|
28
|
+
readOnly,
|
|
29
|
+
} },
|
|
30
|
+
React.createElement(ResizeHandle, { options: { direction: 'left' }, className: mediaResizeHandleVariants({ direction: 'left' }) }),
|
|
31
|
+
React.createElement(Image, { className: cn('block w-full max-w-full cursor-pointer object-cover px-0', 'rounded-sm', focused && selected && 'ring-2 ring-ring ring-offset-2'), alt: "", ...nodeProps, src: src }),
|
|
32
|
+
React.createElement(ResizeHandle, { options: { direction: 'right' }, className: mediaResizeHandleVariants({
|
|
33
|
+
direction: 'right',
|
|
34
|
+
}) })))),
|
|
35
|
+
children)));
|
|
36
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { isSelectionExpanded, useEditorSelector, useElement, useRemoveNodeButton, } from '@udecode/plate-common';
|
|
3
|
+
import { floatingMediaActions, useFloatingMediaSelectors, } from '@udecode/plate-media';
|
|
4
|
+
import { useReadOnly, useSelected } from 'slate-react';
|
|
5
|
+
import { Button } from './plate-button';
|
|
6
|
+
import { Popover, PopoverAnchor, PopoverContent } from './popover';
|
|
7
|
+
import { Link, Trash } from 'lucide-react';
|
|
8
|
+
export function MediaPopover({ children }) {
|
|
9
|
+
const readOnly = useReadOnly();
|
|
10
|
+
const selected = useSelected();
|
|
11
|
+
const selectionCollapsed = useEditorSelector((editor) => !isSelectionExpanded(editor), []);
|
|
12
|
+
const isOpen = !readOnly && selected && selectionCollapsed;
|
|
13
|
+
const isEditing = useFloatingMediaSelectors().isEditing();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!isOpen && isEditing) {
|
|
16
|
+
floatingMediaActions.isEditing(false);
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [isOpen]);
|
|
20
|
+
const element = useElement();
|
|
21
|
+
const { props: buttonProps } = useRemoveNodeButton({ element });
|
|
22
|
+
if (readOnly)
|
|
23
|
+
return React.createElement(React.Fragment, null, children);
|
|
24
|
+
return (React.createElement(Popover, { open: isOpen, modal: false },
|
|
25
|
+
React.createElement(PopoverAnchor, null, children),
|
|
26
|
+
React.createElement(PopoverContent, { className: "w-auto p-1", onOpenAutoFocus: (e) => e.preventDefault() }, isEditing ? (React.createElement("div", { className: "flex w-[330px] flex-col" },
|
|
27
|
+
React.createElement("div", { className: "flex items-center" },
|
|
28
|
+
React.createElement("div", { className: "flex items-center pl-3 text-muted-foreground" },
|
|
29
|
+
React.createElement(Link, { className: "h-4 w-4" }))))) : (React.createElement("div", { className: "box-content flex h-9 items-center gap-1" },
|
|
30
|
+
React.createElement(Button, { variant: "ghost", size: "sms", ...buttonProps },
|
|
31
|
+
React.createElement(Trash, { className: "h-4 w-4" })))))));
|
|
32
|
+
}
|
|
@@ -29,7 +29,14 @@ export declare const plateUI: {
|
|
|
29
29
|
} & {
|
|
30
30
|
variant: "ol" | "ul";
|
|
31
31
|
}, "ref"> & import("react").RefAttributes<any>>;
|
|
32
|
-
img: (
|
|
32
|
+
img: import("react").ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
33
|
+
element: import("@udecode/slate").TElement;
|
|
34
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
35
|
+
as?: import("react").ElementType<any> | undefined;
|
|
36
|
+
asChild?: boolean | undefined;
|
|
37
|
+
} & import("react").RefAttributes<any> & {
|
|
38
|
+
elementToAttributes?: ((element: import("@udecode/slate").TElement) => any) | undefined;
|
|
39
|
+
} & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<unknown>>;
|
|
33
40
|
button: import("react").ForwardRefExoticComponent<Omit<import("@udecode/plate-utils").PlateElementProps, "ref"> & import("react").RefAttributes<any>>;
|
|
34
41
|
table: import("react").ForwardRefExoticComponent<Omit<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderElementProps, "element"> & {
|
|
35
42
|
element: import("@udecode/slate").TElement;
|
|
@@ -71,4 +78,22 @@ export declare const plateUI: {
|
|
|
71
78
|
} & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
|
|
72
79
|
hideBorder?: boolean | undefined;
|
|
73
80
|
} & import("react").RefAttributes<any>>;
|
|
81
|
+
subscript: import("react").ForwardRefExoticComponent<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderLeafProps, "text" | "leaf"> & {
|
|
82
|
+
leaf: import("@udecode/slate").TText;
|
|
83
|
+
text: import("@udecode/slate").TText;
|
|
84
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
85
|
+
as?: import("react").ElementType<any> | undefined;
|
|
86
|
+
asChild?: boolean | undefined;
|
|
87
|
+
} & import("react").RefAttributes<any> & {
|
|
88
|
+
leafToAttributes?: ((leaf: import("@udecode/slate").TText) => any) | undefined;
|
|
89
|
+
} & import("react").RefAttributes<HTMLSpanElement>, "ref"> & import("react").RefAttributes<any>>;
|
|
90
|
+
superscript: import("react").ForwardRefExoticComponent<Omit<import("@udecode/plate-core").PlateRenderNodeProps<import("@udecode/slate").Value, import("@udecode/plate-core").PlateEditor<import("@udecode/slate").Value>> & Omit<import("slate-react").RenderLeafProps, "text" | "leaf"> & {
|
|
91
|
+
leaf: import("@udecode/slate").TText;
|
|
92
|
+
text: import("@udecode/slate").TText;
|
|
93
|
+
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
94
|
+
as?: import("react").ElementType<any> | undefined;
|
|
95
|
+
asChild?: boolean | undefined;
|
|
96
|
+
} & import("react").RefAttributes<any> & {
|
|
97
|
+
leafToAttributes?: ((leaf: import("@udecode/slate").TText) => any) | undefined;
|
|
98
|
+
} & import("react").RefAttributes<HTMLSpanElement>, "ref"> & import("react").RefAttributes<any>>;
|
|
74
99
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withProps } from '@udecode/cn';
|
|
2
|
+
import { PlateLeaf } from '@udecode/plate-common';
|
|
2
3
|
import { BlockquoteElement } from './blocks/blockquote';
|
|
3
4
|
import { Button } from './blocks/buttons';
|
|
4
5
|
import { ImageElement } from './blocks/image';
|
|
@@ -31,4 +32,6 @@ export const plateUI = {
|
|
|
31
32
|
[Elements.ELEMENT_TD]: TableCellElement,
|
|
32
33
|
[Elements.ELEMENT_TH]: TableCellHeaderElement,
|
|
33
34
|
[Elements.ELEMENT_TR]: TableRowElement,
|
|
35
|
+
[Elements.MARK_SUBSCRIPT]: withProps(PlateLeaf, { as: 'sub' }),
|
|
36
|
+
[Elements.MARK_SUPERSCRIPT]: withProps(PlateLeaf, { as: 'sup' }),
|
|
34
37
|
};
|
|
@@ -16,13 +16,14 @@ export interface AvatarProps extends NativeProps {
|
|
|
16
16
|
title?: React.ReactNode;
|
|
17
17
|
tooltipContent?: React.ReactElement;
|
|
18
18
|
tooltipSx?: string;
|
|
19
|
+
fallbackImg?: string;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
*
|
|
22
23
|
* Avatar
|
|
23
24
|
*/
|
|
24
25
|
declare const Avatar: {
|
|
25
|
-
({ as, href, image, size, status, subtitle, sx, textPosition, title, tooltipContent, tooltipSx, ...rest }: AvatarProps): React.JSX.Element;
|
|
26
|
+
({ as, href, image, fallbackImg, size, status, subtitle, sx, textPosition, title, tooltipContent, tooltipSx, ...rest }: AvatarProps): React.JSX.Element;
|
|
26
27
|
displayName: string;
|
|
27
28
|
Group: {
|
|
28
29
|
({ children, numDisplayed, total }: AvatarGroupProps): React.JSX.Element;
|
|
@@ -4,6 +4,7 @@ import Image from 'next/image';
|
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { Box, H, P } from '../../';
|
|
6
6
|
import { Approved, Busy, Declined, Default, Focus, Locked, Offline, Online, Subscribed, } from './icons';
|
|
7
|
+
import DefaultAvatar from './assets/default_avatar.png';
|
|
7
8
|
/**
|
|
8
9
|
* Lookup tables for sizes
|
|
9
10
|
*/
|
|
@@ -58,7 +59,7 @@ const iconOffsetY = {
|
|
|
58
59
|
*
|
|
59
60
|
* Avatar
|
|
60
61
|
*/
|
|
61
|
-
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, tooltipSx, ...rest }) => {
|
|
62
|
+
const Avatar = ({ as = 'button', href, image, fallbackImg = DefaultAvatar, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, tooltipSx, ...rest }) => {
|
|
62
63
|
const [displayDefault, setDisplayDefault] = React.useState(false);
|
|
63
64
|
const Icon = iconReference?.[status ?? 'none'];
|
|
64
65
|
return (React.createElement(Box, { "$align": "center", "$gap": 18, sx: `
|
|
@@ -71,7 +72,7 @@ const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, t
|
|
|
71
72
|
${sx}
|
|
72
73
|
`, ...rest },
|
|
73
74
|
React.createElement(Container, { as: as, "$size": size, href: href },
|
|
74
|
-
!displayDefault && (React.createElement(Image, { alt: "avatar image", height: size, onError: () => setDisplayDefault(true), quality: 100, sizes: "96 | 72 | 64 | 56 | 48 | 40 | 36 | 32 | 24 | 16", src: image ??
|
|
75
|
+
!displayDefault && (React.createElement(Image, { alt: "avatar image", height: size, onError: () => setDisplayDefault(true), quality: 100, sizes: "96 | 72 | 64 | 56 | 48 | 40 | 36 | 32 | 24 | 16", src: image ?? fallbackImg, width: size })),
|
|
75
76
|
displayDefault && React.createElement(Default, null),
|
|
76
77
|
React.createElement("div", null,
|
|
77
78
|
React.createElement(Icon, null))),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
2
|
+
import { AvatarGroupProps, AvatarProps } from './avatar';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export declare const Default: StoryFn<AvatarProps>;
|
|
5
|
+
export declare const Group: StoryFn<AvatarGroupProps>;
|
|
6
|
+
export declare const WithTooltip: StoryFn<AvatarProps>;
|
|
7
|
+
export default meta;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export const Default = () => (React.createElement("svg", {
|
|
3
|
-
React.createElement("
|
|
4
|
-
React.createElement("path", { d: "M114.6 114C107.381 114 101.202 111.43 96.0609 106.289C90.9203 101.148 88.35 94.9688 88.35 87.75C88.35 80.5312 90.9203 74.3516 96.0609 69.2109C101.202 64.0703 107.381 61.5 114.6 61.5C121.819 61.5 127.998 64.0703 133.139 69.2109C138.28 74.3516 140.85 80.5312 140.85 87.75C140.85 94.9688 138.28 101.148 133.139 106.289C127.998 111.43 121.819 114 114.6 114ZM62.1 166.5V148.125C62.1 144.406 63.0581 140.987 64.9744 137.868C66.8862 134.753 69.4281 132.375 72.6 130.734C79.3812 127.344 86.2719 124.8 93.2719 123.102C100.272 121.409 107.381 120.562 114.6 120.562C121.819 120.562 128.928 121.409 135.928 123.102C142.928 124.8 149.819 127.344 156.6 130.734C159.772 132.375 162.314 134.753 164.226 137.868C166.142 140.987 167.1 144.406 167.1 148.125V166.5H62.1ZM75.225 153.375H153.975V148.125C153.975 146.922 153.675 145.828 153.076 144.844C152.472 143.859 151.678 143.094 150.694 142.547C144.787 139.594 138.827 137.378 132.811 135.899C126.795 134.425 120.725 133.688 114.6 133.688C108.475 133.688 102.405 134.425 96.389 135.899C90.3734 137.378 84.4125 139.594 78.5062 142.547C77.5219 143.094 76.73 143.859 76.1306 144.844C75.5269 145.828 75.225 146.922 75.225 148.125V153.375ZM114.6 100.875C118.209 100.875 121.3 99.5887 123.873 97.0162C126.441 94.4481 127.725 91.3594 127.725 87.75C127.725 84.1406 126.441 81.0519 123.873 78.4837C121.3 75.9112 118.209 74.625 114.6 74.625C110.991 74.625 107.902 75.9112 105.334 78.4837C102.761 81.0519 101.475 84.1406 101.475 87.75C101.475 91.3594 102.761 94.4481 105.334 97.0162C107.902 99.5887 110.991 100.875 114.6 100.875Z", fill: "#D4E7FA" })));
|
|
2
|
+
export const Default = () => (React.createElement("svg", { version: "1.0", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 228.000000 228.000000", preserveAspectRatio: "xMidYMid meet" },
|
|
3
|
+
React.createElement("g", { transform: "translate(0.000000,228.000000) scale(0.100000,-0.100000)", fill: "#000000", stroke: "none" })));
|
|
@@ -13,6 +13,7 @@ export type Props = {
|
|
|
13
13
|
name?: string;
|
|
14
14
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
15
15
|
onMultipleChange?: (values: string[]) => void;
|
|
16
|
+
onSubmit?: React.FormEventHandler<HTMLInputElement>;
|
|
16
17
|
placeholder?: string;
|
|
17
18
|
size?: TextInputSize;
|
|
18
19
|
sx?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface PlaylistItemProps {
|
|
3
|
-
duration
|
|
3
|
+
duration?: number;
|
|
4
4
|
onClick: () => void;
|
|
5
5
|
playable?: boolean;
|
|
6
6
|
progress?: number;
|
|
7
|
-
shortDescription
|
|
7
|
+
shortDescription?: string;
|
|
8
8
|
thumbnail: string;
|
|
9
9
|
title: string;
|
|
10
10
|
}
|
|
@@ -4,17 +4,17 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { Box } from '../../atoms/box';
|
|
5
5
|
import { SecToDuration } from '../../atoms/seconds_to_duration';
|
|
6
6
|
import { P } from '../../atoms/typography';
|
|
7
|
-
import { PlaySolid } from '../../../icons
|
|
7
|
+
import { Lock, PlaySolid } from '../../../icons';
|
|
8
8
|
export const PlaylistItem = ({ duration, onClick, playable, progress = 0, shortDescription, thumbnail, title, }) => {
|
|
9
9
|
return (React.createElement(Wrapper, { onClick: playable ? onClick : undefined, "$playable": playable },
|
|
10
|
-
React.createElement(PlaySolid, { color: "white", size: 16, sx: "position: absolute; left: 8px; bottom: 4px;" }),
|
|
10
|
+
playable ? (React.createElement(PlaySolid, { color: "white", size: 16, sx: "position: absolute; left: 8px; bottom: 4px;" })) : (React.createElement(Lock, { color: "white", size: 16, sx: "position: absolute; left: 8px; bottom: 4px;" })),
|
|
11
11
|
React.createElement(Image, { alt: `thumbnail for ${title}`, height: 75, quality: 100, src: thumbnail, width: 133 }),
|
|
12
|
-
React.createElement(ProgressBar, { progressPercent: progress / duration }),
|
|
12
|
+
progress && duration && (React.createElement(ProgressBar, { progressPercent: progress / duration })),
|
|
13
13
|
React.createElement(Box, { "$dir": "column", "$gap": 4, sx: "margin-left: 16px; margin-right: auto; flex: 0 1 auto; flex-basis: content;" },
|
|
14
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 }))));
|
|
15
|
+
shortDescription && (React.createElement(P, { "$color": "grey-9", "$fontSize": 14, "$lineHeight": 20, "$textClampLines": 2, sx: "max-width: min(500px, 75%);" }, shortDescription))),
|
|
16
|
+
duration && (React.createElement(P, { "$color": "grey-8", "$fontSize": 14, "$lineHeight": 20, sx: "flex-shrink: 0;" },
|
|
17
|
+
React.createElement(SecToDuration, { seconds: duration })))));
|
|
18
18
|
};
|
|
19
19
|
const Wrapper = styled.div `
|
|
20
20
|
width: 100%;
|