diff --git a/src/assets/icons/tag-stroke.svg b/src/assets/icons/tag-stroke.svg new file mode 100644 index 00000000..72047dd6 --- /dev/null +++ b/src/assets/icons/tag-stroke.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/stories/player/_types.tsx b/src/stories/player/_types.tsx index fb97dae5..2aab26f6 100644 --- a/src/stories/player/_types.tsx +++ b/src/stories/player/_types.tsx @@ -9,6 +9,12 @@ export interface PlayerArgs extends HTMLAttributes { isCutting?: boolean; bookmarks?: IBookmark[]; handleBookmarkUpdate?: (bookmark: IBookmark) => void; + i18n?: PlayerI18n; +} + +export interface PlayerI18n { + beforeHighlight?: string; + onHighlight?: string; } export interface IBookmark { diff --git a/src/stories/player/index.stories.tsx b/src/stories/player/index.stories.tsx index 6b612304..f28d63a0 100644 --- a/src/stories/player/index.stories.tsx +++ b/src/stories/player/index.stories.tsx @@ -129,7 +129,6 @@ WithBookmarks.args = { label: "110s - 160s", }, ], - handleBookmarkUpdate: (bookmark: IBookmark) => { console.log("Bookmark updated", bookmark); }, diff --git a/src/stories/player/index.tsx b/src/stories/player/index.tsx index b63825e1..e04156b5 100644 --- a/src/stories/player/index.tsx +++ b/src/stories/player/index.tsx @@ -73,6 +73,7 @@ const PlayerCore = forwardRef( bookmarks={bookmarks} isCutting={isCutting} onBookMarkUpdated={props.handleBookmarkUpdate} + i18n={props.i18n} /> diff --git a/src/stories/player/parts/bookmark.tsx b/src/stories/player/parts/bookmark.tsx index 4160822a..5ce1b185 100644 --- a/src/stories/player/parts/bookmark.tsx +++ b/src/stories/player/parts/bookmark.tsx @@ -5,41 +5,24 @@ import { IBookmark } from "../_types"; import { useProgressContext } from "./progressContext"; import { ReactComponent as GripIcon } from "../../../assets/icons/grip.svg"; -const activeBookMark = css` - height: 250%; - transform: translateY(-30%); -`; - -const Rect = styled.div<{ hue?: string; isActive?: boolean }>` - position: absolute; - height: 110%; - background-color: ${({ hue, theme }) => hue || theme.palette.grey[800]}; - z-index: 1; - border-radius: 3px; - &:hover { - ${activeBookMark} - } - color: white; - ${({ isActive }) => isActive && activeBookMark} -`; - const StyledGrabber = styled.div<{ isEnd?: boolean }>` position: absolute; + display: none; ${({ isEnd }) => isEnd ? ` right: 0; - border-top-right-radius: 3px; - border-bottom-right-radius: 3px; + border-top-right-radius: 2px; + border-bottom-right-radius: 2px; ` : ` left: 0; - border-top-left-radius: 3px; - border-bottom-left-radius: 3px; + border-top-left-radius: 2px; + border-bottom-left-radius: 2px; `} height: 100%; - width: 6px; - background-color: ${({ theme }) => theme.palette.grey[800]}; + width: 8px; + background-color: white; z-index: 2; cursor: ew-resize; @@ -49,14 +32,39 @@ const StyledGrabber = styled.div<{ isEnd?: boolean }>` align-items: center; height: 100%; width: 100%; + color: ${({ theme }) => theme.palette.grey[500]}; svg { width: auto; height: 50%; - fill: ${({ theme }) => theme.palette.grey[200]}; } } `; +const activeBookMark = css` + height: 250%; + transform: translateY(-30%); + + ${StyledGrabber} { + display: block; + } +`; + +const Rect = styled.div<{ hue?: string; isActive?: boolean }>` + position: absolute; + height: 110%; + background-color: ${({ hue, theme }) => hue || theme.palette.grey[800]}; + z-index: 1; + border-radius: 2px; + &:hover { + ${activeBookMark} + border-radius: 4px; + } + color: white; + ${({ isActive }) => isActive && activeBookMark} + + transition: width 0.1s ease; +`; + const Grabber = (props: { observation: IBookmark; isEnd?: boolean; @@ -101,11 +109,7 @@ export const Bookmark = (props: IBookmark) => { if (start > videoEnd || start < videoStart) return null; return ( - + ` position: absolute; @@ -53,12 +54,14 @@ export const Controls = ({ bookmarks, isCutting, onBookMarkUpdated, + i18n, }: { container: HTMLDivElement | null; onCutHandler?: (time: number) => void; bookmarks?: IBookmark[]; isCutting?: boolean; onBookMarkUpdated?: (bookmark: IBookmark) => void; + i18n?: PlayerI18n; }) => { const [progress, setProgress] = useState(0); const [tooltipMargin, setTooltipMargin] = useState(0); @@ -209,12 +212,14 @@ export const Controls = ({ - + + diff --git a/src/stories/player/parts/controlsCenterGroup.tsx b/src/stories/player/parts/controlsCenterGroup.tsx index 5844559c..c1a15f34 100644 --- a/src/stories/player/parts/controlsCenterGroup.tsx +++ b/src/stories/player/parts/controlsCenterGroup.tsx @@ -15,13 +15,7 @@ const StyledDiv = styled.div` align-items: center; `; -export const ControlsGroupCenter = ({ - onCutHandler, - isCutting, -}: { - onCutHandler?: (time: number) => void; - isCutting?: boolean; -}) => { +export const ControlsGroupCenter = () => { const [playBackRate, setPlayBackRate] = useState(1); const { context, togglePlay } = useVideoContext(); @@ -101,19 +95,6 @@ export const ControlsGroupCenter = ({ {playBackRate}x - {onCutHandler && ( - { - if (videoRef) { - onCutHandler(videoRef.currentTime); - } - e.stopPropagation(); - }} - > - {isCutting ? '🛑': '✂️'} - - )} ); }; diff --git a/src/stories/player/parts/cutterButton.tsx b/src/stories/player/parts/cutterButton.tsx new file mode 100644 index 00000000..3b4dbee9 --- /dev/null +++ b/src/stories/player/parts/cutterButton.tsx @@ -0,0 +1,41 @@ +import { useVideoContext } from "@appquality/stream-player"; +import { ReactComponent as TagIcon } from "../../../assets/icons/tag-stroke.svg"; +import { Button } from "../../buttons/button"; +import { PlayerI18n } from "../_types"; + +export const Cutter = ({ + onCutHandler, + isCutting, + i18n, +}: { + onCutHandler?: (time: number) => void; + isCutting?: boolean; + i18n?: PlayerI18n; +}) => { + const { context } = useVideoContext(); + + const videoRef = context.player?.ref.current; + + if (!onCutHandler) return null; + + return ( + + ); +}; diff --git a/src/stories/player/parts/progress.tsx b/src/stories/player/parts/progress.tsx index c5318b7c..4c1e9c64 100644 --- a/src/stories/player/parts/progress.tsx +++ b/src/stories/player/parts/progress.tsx @@ -15,7 +15,7 @@ interface ProgressProps { const StyledProgress = styled(Progress)` width: 100%; border-radius: 0; - color: ${({ theme }) => theme.palette.kale[700]}; + color: ${({ theme }) => theme.palette.grey[700]}; cursor: pointer; > div { border-radius: 0;