From 9b93e82979ca0e963deadb913294223a25d065ed Mon Sep 17 00:00:00 2001 From: Etesam913 Date: Thu, 4 May 2023 01:09:42 -0400 Subject: [PATCH 1/8] :bulb: Added comments to util functions * Helps with readability of codebase --- packages/custoplayer/src/lib/utils.tsx | 52 ++++++++++++++++++-------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/packages/custoplayer/src/lib/utils.tsx b/packages/custoplayer/src/lib/utils.tsx index 6e19ed4..b0686dd 100644 --- a/packages/custoplayer/src/lib/utils.tsx +++ b/packages/custoplayer/src/lib/utils.tsx @@ -12,7 +12,7 @@ import Color from 'color'; export const debounce = (fn: (...args: any[]) => void, ms = 300) => { let timeoutId: ReturnType; - return function (this: any, ...args: any[]) { + return function(this: any, ...args: any[]) { clearTimeout(timeoutId); timeoutId = setTimeout(() => fn.apply(this, args), ms); }; @@ -34,7 +34,7 @@ export const throttle = (fn: (...args: any[]) => void, ms = 300) => { isThrottled = true; - setTimeout(function () { + setTimeout(function() { isThrottled = false; if (savedArgs) { wrapper.apply(savedThis, savedArgs); @@ -79,6 +79,11 @@ export function isFullscreenButton( return (curItem as FullscreenItem).id.startsWith('fullscreenButton'); } +/** + Changes the play state of the video. + This is ran when the user clicks the video + or presses the spacebar or k key +*/ export function handlePlayState(video: HTMLVideoElement | null) { if (video === null) return; const isPlaying = !video.paused && !video.ended && video.currentTime > 0; @@ -116,18 +121,9 @@ export function handleKeyPress( } } -export function getSvgPath(path: string, strokeWidth = '1.8') { - return ( - - ); -} - +/** + Clamps val in between min and max +*/ export function clamp(val: number, min: number, max: number) { return Math.min(Math.max(val, min), max); } @@ -154,7 +150,14 @@ function getMousePos( } } -export function barMouseEvent( +/** + Runs when the user mousedown/touchstart on the + progress or volume bar. + + The function runs sthe mouseMoveCallback function + when the mouse moves while the mouse is down as well +*/ +export function barMouseDown( e: BarMouseEvent, mouseMoveCallback: MouseMoveCallback, videoContainer: HTMLDivElement | null, @@ -163,6 +166,7 @@ export function barMouseEvent( | ((update: SetStateAction) => void), isTouchscreen: boolean, ) { + mouseMove(e); e.stopPropagation(); @@ -192,6 +196,10 @@ export function barMouseEvent( } } +/** + Formats time for currentTime and duration components. + ex: 120 -> 2:00 +*/ export function formatTime(durationInSeconds: number) { const hours = Math.floor(durationInSeconds / 3600); const minutes = Math.floor((durationInSeconds - hours * 3600) / 60); @@ -252,12 +260,22 @@ export function getLargestProgressBarMousePos( ]; } +/** + Used to determine if the device is a + touchscreen by checking if TouchEvent + exists +*/ export function isTouchscreenFunc( event: BarMouseEvent, ): event is React.TouchEvent { return (event as React.TouchEvent).touches !== undefined; } +/** + Used to determine if the device is not a + touchscreen by checking if MouseEvent + exists +*/ export function isMouseFunc( event: BarMouseEvent, ): event is React.MouseEvent { @@ -272,6 +290,10 @@ export function isTouchscreen() { return false; } +/** + Lightens a color by using the Color.js library + Used for setting default progressColor on progressBar +*/ export function lightenColor(color: string | undefined) { const lightenedColor = Color(color).lighten(0.3); return lightenedColor; From 3461d18b77719a9f8b8f262983773e11c600dd72 Mon Sep 17 00:00:00 2001 From: Etesam913 Date: Thu, 4 May 2023 01:44:02 -0400 Subject: [PATCH 2/8] :truck: Moved code from progressBar index to utils.tsx Moved the code to utils so that it can be used by topProgressBar --- .../src/lib/components/ControlsBar.tsx | 3 +- .../src/lib/components/ProgressBars/index.tsx | 121 +++++------------- .../src/lib/components/VolumeButtons.tsx | 6 +- packages/custoplayer/src/lib/utils.tsx | 114 ++++++++++++++++- 4 files changed, 150 insertions(+), 94 deletions(-) diff --git a/packages/custoplayer/src/lib/components/ControlsBar.tsx b/packages/custoplayer/src/lib/components/ControlsBar.tsx index 20367d2..44c60ff 100644 --- a/packages/custoplayer/src/lib/components/ControlsBar.tsx +++ b/packages/custoplayer/src/lib/components/ControlsBar.tsx @@ -26,6 +26,7 @@ import { controlsBarMovementAnimation, controlsBarOpacityAnimation, } from '@root/lib/variants'; +import ProgressBar1 from './ProgressBars/ProgressBar1'; function extractColor(curItem: CustoplayerItem) { if ( @@ -68,7 +69,7 @@ function ControlsBar() { return ( - {(isProgressDragging || isVolumeDragging || isControlsBarShowing) && ( + {(true || isVolumeDragging || isControlsBarShowing) && ( modifiedUpperBound) { - hoverPos = modifiedUpperBound - previewTooltipWidth / 2; - } - hoverPos = clamp(hoverPos, minHoverPos, maxHoverPos); - setPreviewTooltipPosition(hoverPos); - - const leftDist = progressBarRef.current.getBoundingClientRect().left; - const timePos = xPos - leftDist; - if (videoElem && videoElem.duration) { - const ratio = clamp(timePos / progressBarRef.current.clientWidth, 0, 1); - const currentTime = videoElem.duration * ratio; - setTooltipStr(formatTime(currentTime)); - } } // Handles play state when progress bar is being dragged @@ -151,9 +90,9 @@ function ProgressBars({ item }: ProgressBarsProps) { isDragging={isProgressDragging} onTouchStart={(e) => { setIsHovered(true); - barMouseEvent( + barMouseDown( e, - handleProgressMouseMove, + handleProgressBarMouseMoveWrapper, videoContainer, setIsProgressDragging, true, @@ -161,12 +100,22 @@ function ProgressBars({ item }: ProgressBarsProps) { }} onTouchEnd={() => setIsHovered(false)} onMouseEnter={() => setIsHovered(true)} - onMouseMove={handleMouseMove} + onMouseMove={(e) => + showPreviewThumbnail( + e, + isProgressDragging, + progressBarRef, + videoContainer, + videoElem, + setTooltipStr, + setPreviewTooltipPosition, + ) + } onMouseLeave={() => setIsHovered(false)} onMouseDown={(e) => - barMouseEvent( + barMouseDown( e, - handleProgressMouseMove, + handleProgressBarMouseMoveWrapper, videoContainer, setIsProgressDragging, false, diff --git a/packages/custoplayer/src/lib/components/VolumeButtons.tsx b/packages/custoplayer/src/lib/components/VolumeButtons.tsx index 3d56450..7d7b960 100644 --- a/packages/custoplayer/src/lib/components/VolumeButtons.tsx +++ b/packages/custoplayer/src/lib/components/VolumeButtons.tsx @@ -12,12 +12,12 @@ import { volumeAtom, } from '@root/lib/atoms'; import { - barMouseEvent, clamp, BarMouseEvent, isTouchscreenFunc, isMouseFunc, isTouchscreen, + barMouseDown, } from '@root/lib/utils'; import VolumeBars from './VolumeBars'; import { motion, AnimatePresence } from 'framer-motion'; @@ -170,7 +170,7 @@ function VolumeButtons({ item }: VolumeButtonsProps) { onMouseEnter={() => setIsBarHovered(true)} onMouseLeave={() => setIsBarHovered(false)} onMouseDown={(e) => - barMouseEvent( + barMouseDown( e, handleProgressMouse, videoContainer, @@ -180,7 +180,7 @@ function VolumeButtons({ item }: VolumeButtonsProps) { } onTouchStart={(e) => { setIsBarHovered(true); - barMouseEvent( + barMouseDown( e, handleProgressMouse, videoContainer, diff --git a/packages/custoplayer/src/lib/utils.tsx b/packages/custoplayer/src/lib/utils.tsx index b0686dd..ccb942c 100644 --- a/packages/custoplayer/src/lib/utils.tsx +++ b/packages/custoplayer/src/lib/utils.tsx @@ -7,12 +7,12 @@ import { VolumeItem, } from '@root/lib/types'; import { SetStateAction } from 'react'; -import { isVolumeDraggingType } from '@root/lib/atoms'; +import { isVolumeDraggingType, previewTooltipWidth } from '@root/lib/atoms'; import Color from 'color'; export const debounce = (fn: (...args: any[]) => void, ms = 300) => { let timeoutId: ReturnType; - return function(this: any, ...args: any[]) { + return function (this: any, ...args: any[]) { clearTimeout(timeoutId); timeoutId = setTimeout(() => fn.apply(this, args), ms); }; @@ -34,7 +34,7 @@ export const throttle = (fn: (...args: any[]) => void, ms = 300) => { isThrottled = true; - setTimeout(function() { + setTimeout(function () { isThrottled = false; if (savedArgs) { wrapper.apply(savedThis, savedArgs); @@ -166,7 +166,6 @@ export function barMouseDown( | ((update: SetStateAction) => void), isTouchscreen: boolean, ) { - mouseMove(e); e.stopPropagation(); @@ -196,6 +195,113 @@ export function barMouseDown( } } +export function handleProgressBarMouseMove( + e: BarMouseEvent, + videoContainerRect: DOMRect, + isProgressDragging: boolean, + progressBarRef: React.MutableRefObject, + videoContainer: HTMLDivElement | null, + videoElem: HTMLVideoElement | null, + setProgress: (update: SetStateAction) => void, + setIsProgressDragging: (update: SetStateAction) => void, + setTooltipStr: (update: SetStateAction) => void, + setPreviewTooltipPosition: (update: SetStateAction) => void, +) { + setIsProgressDragging(true); + if (progressBarRef && progressBarRef.current) { + let xPos = 0; + if (isTouchscreenFunc(e)) xPos = e.touches[0].clientX; + else if (isMouseFunc(e)) xPos = e.clientX; + const progressBarRect = progressBarRef.current.getBoundingClientRect(); + const [largestProgressBarMousePos, distLeftOfProgressBar, _] = + getLargestProgressBarMousePos(videoContainerRect, progressBarRect); + + const updatedMousePos = xPos - videoContainerRect.left; + + showPreviewThumbnail( + e, + isProgressDragging, + progressBarRef, + videoContainer, + videoElem, + setTooltipStr, + setPreviewTooltipPosition, + ); + const adjustedMousePos = updatedMousePos - distLeftOfProgressBar; + const clampedMousePos = clamp( + adjustedMousePos, + 0, + largestProgressBarMousePos, + ); + + const ratio = clampedMousePos / progressBarRef.current.clientWidth; + if (videoElem && videoElem.duration) { + const currentTime = videoElem.duration * ratio; + videoElem.currentTime = currentTime; + setTooltipStr(formatTime(currentTime)); + } + + setProgress(ratio); + } +} + +/** + Shows the preview thumbnail when mouse is over progress bar +*/ +export function showPreviewThumbnail( + e: BarMouseEvent, + isProgressDragging: boolean, + progressBarRef: React.MutableRefObject, + videoContainer: HTMLDivElement | null, + videoElem: HTMLVideoElement | null, + setTooltipStr: (update: SetStateAction) => void, + setPreviewTooltipPosition: (update: SetStateAction) => void, +) { + if ( + isProgressDragging || + !progressBarRef || + !progressBarRef.current || + !videoContainer + ) + return; + let xPos = 0; + if (isTouchscreenFunc(e)) xPos = e.touches[0].clientX; + else if (isMouseFunc(e)) xPos = e.clientX; + const progressBarRect = progressBarRef.current.getBoundingClientRect(); + const widthOfItemsToLeftOfProgressBar = + progressBarRef.current.getBoundingClientRect().left - + videoContainer?.getBoundingClientRect().left; + const widthOfItemsToRightOfProgressBar = + videoContainer?.getBoundingClientRect().right - + progressBarRef.current.getBoundingClientRect().right; + const defaultHoverPos = xPos - progressBarRect.left; + let hoverPos = xPos - progressBarRect.left - previewTooltipWidth / 2; + const modifiedUpperBound = + progressBarRef.current?.clientWidth - + previewTooltipWidth / 2 + + widthOfItemsToRightOfProgressBar; + const maxHoverPos = + progressBarRef.current.clientWidth - previewTooltipWidth / 2; + const minHoverPos = Math.max( + (-1 * previewTooltipWidth) / 2, + -1 * widthOfItemsToLeftOfProgressBar, + ); + + if (defaultHoverPos > modifiedUpperBound) { + hoverPos = modifiedUpperBound - previewTooltipWidth / 2; + } + hoverPos = clamp(hoverPos, minHoverPos, maxHoverPos); + setPreviewTooltipPosition(hoverPos); + + const leftDist = progressBarRef.current.getBoundingClientRect().left; + const timePos = xPos - leftDist; + if (videoElem && videoElem.duration) { + const ratio = clamp(timePos / progressBarRef.current.clientWidth, 0, 1); + const currentTime = videoElem.duration * ratio; + setTooltipStr(formatTime(currentTime)); + } +} + /** Formats time for currentTime and duration components. ex: 120 -> 2:00 From a8b8bac83f2400fb985f7941fe43a12e548ad6c6 Mon Sep 17 00:00:00 2001 From: Etesam913 Date: Thu, 4 May 2023 20:05:45 -0400 Subject: [PATCH 3/8] :sparkles: Added the ability to add a topProgressBar This can be done by specifying the topProgressBar object --- packages/custoplayer/src/App.tsx | 2 ++ .../src/lib/components/ControlsBar.tsx | 15 +++++++++++++++ .../lib/components/ProgressBars/ProgressBar2.tsx | 4 ++-- .../lib/components/ProgressBars/ProgressBar3.tsx | 5 +++-- .../src/lib/components/ProgressBars/index.tsx | 10 ++++++---- packages/custoplayer/src/lib/types.ts | 10 +++++++++- 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/packages/custoplayer/src/App.tsx b/packages/custoplayer/src/App.tsx index 76db25c..bd61c37 100644 --- a/packages/custoplayer/src/App.tsx +++ b/packages/custoplayer/src/App.tsx @@ -31,6 +31,8 @@ function App() { id: 'currentTime', hideOnMobile: true, }, + + item4: { id: 'progressBar1', progressColor: '#6a994e', diff --git a/packages/custoplayer/src/lib/components/ControlsBar.tsx b/packages/custoplayer/src/lib/components/ControlsBar.tsx index 44c60ff..d23855e 100644 --- a/packages/custoplayer/src/lib/components/ControlsBar.tsx +++ b/packages/custoplayer/src/lib/components/ControlsBar.tsx @@ -27,6 +27,7 @@ import { controlsBarOpacityAnimation, } from '@root/lib/variants'; import ProgressBar1 from './ProgressBars/ProgressBar1'; +import ProgressBars from './ProgressBars/index'; function extractColor(curItem: CustoplayerItem) { if ( @@ -82,6 +83,12 @@ function ControlsBar() { exit='exit' data-cy='controlsBar' > + {videoValues.topProgressBar && + + + + } + ` } `; +export const TopProgressBarContainer = styled.div` + width: 100%; + height: 3rem; + display: flex; + flex-direction: column; + justify-content: flex-end; +`; + export default ControlsBar; diff --git a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar2.tsx b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar2.tsx index 1af23b3..3e3b119 100644 --- a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar2.tsx +++ b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar2.tsx @@ -55,11 +55,11 @@ const ProgressBar2 = forwardRef((props, ref) => { ); }); -const Bar2 = styled(motion.div)<{ barColor: string | undefined }>` +const Bar2 = styled(motion.div) <{ barColor: string | undefined }>` display: flex; background-color: ${(props) => (props.barColor ? props.barColor : '#f2f2f2')}; width: 100%; - height: 65%; + height: 1.25rem; justify-content: flex-start; position: relative; `; diff --git a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx index e83bcec..02fa807 100644 --- a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx +++ b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx @@ -49,6 +49,7 @@ const ProgressBar3 = forwardRef((props, ref) => { }} progressColor={props.item.progressColor} /> + {values.previewTooltip && ( ((props, ref) => { ); }); -const Bar3 = styled(motion.div)<{ +const Bar3 = styled(motion.div) <{ barColor: string | undefined; barBorderColor: string | undefined; }>` @@ -68,7 +69,7 @@ const Bar3 = styled(motion.div)<{ background-color: ${(props) => props.barColor ? props.barColor : 'transparent'}; width: 100%; - height: 65%; + height: 1.25rem; justify-content: flex-start; border-radius: 1rem; align-items: center; diff --git a/packages/custoplayer/src/lib/components/ProgressBars/index.tsx b/packages/custoplayer/src/lib/components/ProgressBars/index.tsx index ebcd79c..7a806a2 100644 --- a/packages/custoplayer/src/lib/components/ProgressBars/index.tsx +++ b/packages/custoplayer/src/lib/components/ProgressBars/index.tsx @@ -21,13 +21,14 @@ import styled from 'styled-components'; import { useProgressDragging } from '../../hooks'; import ProgressBar1 from './ProgressBar1'; import ProgressBar2 from './ProgressBar2'; -import ProgressBar3 from '@root/lib/components/ProgressBars/ProgressBar3'; +import ProgressBar3 from './ProgressBar3'; interface ProgressBarsProps { item: ProgressBarItem; + onTop?: boolean; } -function ProgressBars({ item }: ProgressBarsProps) { +function ProgressBars({ item, onTop = false }: ProgressBarsProps) { const progressBarRef = useRef(null); const [isHovered, setIsHovered] = useState(false); const videoElem = useAtomValue(videoElemAtom, myScope); @@ -86,6 +87,7 @@ function ProgressBars({ item }: ProgressBarsProps) { return ( { @@ -158,11 +160,11 @@ function ProgressBars({ item }: ProgressBarsProps) { ); } -const ProgressBarContainer = styled.div<{ isDragging: boolean }>` +const ProgressBarContainer = styled.div<{ isDragging: boolean, onTop: boolean }>` height: 100%; width: 100%; display: flex; - align-items: center; + align-items: ${props => props.onTop ? "flex-end" : "center"}; cursor: ${(props) => (props.isDragging ? 'col-resize' : 'pointer')}; `; diff --git a/packages/custoplayer/src/lib/types.ts b/packages/custoplayer/src/lib/types.ts index f7088da..ce3a5b4 100644 --- a/packages/custoplayer/src/lib/types.ts +++ b/packages/custoplayer/src/lib/types.ts @@ -45,6 +45,13 @@ export interface CustoplayerValues { animate: "movement" } */ controlsBar?: ControlsBarItem; + /** You can define your progress bar to be on top of your controls bar here: + @example + topProgressBar: { + id: 'progressBar1', + progressColor: 'rgb(137, 178, 245)' + } */ + topProgressBar?: ProgressBarItem, // playIndicator?: { // id?: number; // color?: string; @@ -76,7 +83,8 @@ export interface CustoplayerValues { @example item3: { id: 'progressBar1', - progressColor: 'rgb(137, 178, 245)' + progressColor: 'rgb(137, 178, 245)', + barColor: "white" } */ item3?: CustoplayerItem; /** You can define a component in this item container. This container is the fourth container from the left. From c96a8e98f691c88ae4d1e4ec52741b033cf88113 Mon Sep 17 00:00:00 2001 From: Etesam913 Date: Thu, 4 May 2023 20:12:57 -0400 Subject: [PATCH 4/8] :white_check_mark: Added unit tests for topProgressBar --- .../custoplayer/cypress/component/ProgressBars.cy.tsx | 9 +++++++++ packages/custoplayer/src/App.tsx | 1 - packages/custoplayer/src/lib/components/ControlsBar.tsx | 7 +++---- .../src/lib/components/ProgressBars/ProgressBar2.tsx | 2 +- .../src/lib/components/ProgressBars/ProgressBar3.tsx | 2 +- .../src/lib/components/ProgressBars/index.tsx | 7 +++++-- packages/custoplayer/src/lib/types.ts | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/custoplayer/cypress/component/ProgressBars.cy.tsx b/packages/custoplayer/cypress/component/ProgressBars.cy.tsx index 05528dd..d803adc 100644 --- a/packages/custoplayer/cypress/component/ProgressBars.cy.tsx +++ b/packages/custoplayer/cypress/component/ProgressBars.cy.tsx @@ -10,6 +10,15 @@ describe('ProgressBars.cy.tsx', () => { cy.dataCy('progressBar3').should('exist'); }); + it("renders topProgressBars", () => { + cy.mount(); + cy.dataCy('progressBar1').should('exist').should('have.css', 'align-items', 'flex-end'); + cy.mount(); + cy.dataCy('progressBar2').should('exist').should('have.css', 'align-items', 'flex-end'); + cy.mount(); + cy.dataCy('progressBar3').should('exist').should('have.css', 'align-items', 'flex-end'); + }) + it('renders progressBars buffered color', () => { let bufferedColor = 'rgb(82, 158, 233)' cy.mount( diff --git a/packages/custoplayer/src/App.tsx b/packages/custoplayer/src/App.tsx index bd61c37..76b5333 100644 --- a/packages/custoplayer/src/App.tsx +++ b/packages/custoplayer/src/App.tsx @@ -32,7 +32,6 @@ function App() { hideOnMobile: true, }, - item4: { id: 'progressBar1', progressColor: '#6a994e', diff --git a/packages/custoplayer/src/lib/components/ControlsBar.tsx b/packages/custoplayer/src/lib/components/ControlsBar.tsx index d23855e..2cbc855 100644 --- a/packages/custoplayer/src/lib/components/ControlsBar.tsx +++ b/packages/custoplayer/src/lib/components/ControlsBar.tsx @@ -26,7 +26,6 @@ import { controlsBarMovementAnimation, controlsBarOpacityAnimation, } from '@root/lib/variants'; -import ProgressBar1 from './ProgressBars/ProgressBar1'; import ProgressBars from './ProgressBars/index'; function extractColor(curItem: CustoplayerItem) { @@ -70,7 +69,7 @@ function ControlsBar() { return ( - {(true || isVolumeDragging || isControlsBarShowing) && ( + {(isProgressDragging || isVolumeDragging || isControlsBarShowing) && ( - {videoValues.topProgressBar && + {videoValues.topProgressBar && ( - } + )} ((props, ref) => { ); }); -const Bar2 = styled(motion.div) <{ barColor: string | undefined }>` +const Bar2 = styled(motion.div)<{ barColor: string | undefined }>` display: flex; background-color: ${(props) => (props.barColor ? props.barColor : '#f2f2f2')}; width: 100%; diff --git a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx index 02fa807..0e070b8 100644 --- a/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx +++ b/packages/custoplayer/src/lib/components/ProgressBars/ProgressBar3.tsx @@ -61,7 +61,7 @@ const ProgressBar3 = forwardRef((props, ref) => { ); }); -const Bar3 = styled(motion.div) <{ +const Bar3 = styled(motion.div)<{ barColor: string | undefined; barBorderColor: string | undefined; }>` diff --git a/packages/custoplayer/src/lib/components/ProgressBars/index.tsx b/packages/custoplayer/src/lib/components/ProgressBars/index.tsx index 7a806a2..9de0304 100644 --- a/packages/custoplayer/src/lib/components/ProgressBars/index.tsx +++ b/packages/custoplayer/src/lib/components/ProgressBars/index.tsx @@ -160,11 +160,14 @@ function ProgressBars({ item, onTop = false }: ProgressBarsProps) { ); } -const ProgressBarContainer = styled.div<{ isDragging: boolean, onTop: boolean }>` +const ProgressBarContainer = styled.div<{ + isDragging: boolean; + onTop: boolean; +}>` height: 100%; width: 100%; display: flex; - align-items: ${props => props.onTop ? "flex-end" : "center"}; + align-items: ${(props) => (props.onTop ? 'flex-end' : 'center')}; cursor: ${(props) => (props.isDragging ? 'col-resize' : 'pointer')}; `; diff --git a/packages/custoplayer/src/lib/types.ts b/packages/custoplayer/src/lib/types.ts index ce3a5b4..efe0f95 100644 --- a/packages/custoplayer/src/lib/types.ts +++ b/packages/custoplayer/src/lib/types.ts @@ -51,7 +51,7 @@ export interface CustoplayerValues { id: 'progressBar1', progressColor: 'rgb(137, 178, 245)' } */ - topProgressBar?: ProgressBarItem, + topProgressBar?: ProgressBarItem; // playIndicator?: { // id?: number; // color?: string; From d1b0f9230cc7b8efaecc3008c5f79f9c9e64868b Mon Sep 17 00:00:00 2001 From: Etesam913 Date: Thu, 4 May 2023 20:35:24 -0400 Subject: [PATCH 5/8] :memo: Added documentation on progressBars Added demo video of progressBar2, progressBar3, and topProgressBar --- packages/custoplayer/src/App.tsx | 2 +- .../src/lib/components/ControlsBar.tsx | 4 +- .../docs/components/progress-bars.mdx | 44 +++++++++++++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/packages/custoplayer/src/App.tsx b/packages/custoplayer/src/App.tsx index 76b5333..bde120a 100644 --- a/packages/custoplayer/src/App.tsx +++ b/packages/custoplayer/src/App.tsx @@ -28,7 +28,7 @@ function App() { hideOnMobile: true, }, item3: { - id: 'currentTime', + id: 'duration', hideOnMobile: true, }, diff --git a/packages/custoplayer/src/lib/components/ControlsBar.tsx b/packages/custoplayer/src/lib/components/ControlsBar.tsx index 2cbc855..c616de5 100644 --- a/packages/custoplayer/src/lib/components/ControlsBar.tsx +++ b/packages/custoplayer/src/lib/components/ControlsBar.tsx @@ -69,7 +69,7 @@ function ControlsBar() { return ( - {(isProgressDragging || isVolumeDragging || isControlsBarShowing) && ( + {(true || isVolumeDragging || isControlsBarShowing) && ( {videoValues.topProgressBar && ( - + )} diff --git a/sites/custoplayer-docs/docs/components/progress-bars.mdx b/sites/custoplayer-docs/docs/components/progress-bars.mdx index 4a9aa48..6572bcd 100644 --- a/sites/custoplayer-docs/docs/components/progress-bars.mdx +++ b/sites/custoplayer-docs/docs/components/progress-bars.mdx @@ -1,13 +1,24 @@ # Progress Bars -There is currently one progress bar component +There are currently three progress bar components 1. `"progressBar1"` +2. `"progressBar2"` +3. `"progressBar3"` ## Demo of `progressBar1`