import { useCurrentFrame, useVideoConfig } from "remotion"; import { StyleAndClass } from "@asius/base"; import { ProgressbarProps } from "@asius/base"; import { useColors } from "../useColors"; export const defaultProgressbarProps: ProgressbarProps = { comp: "progressbar", barWidth: 30, topRight: false, color: "#ff00ffff", bg: "#0000FFFF", type: "square", height: 100, width: 100, }; export const Progressbar = ({ color, bg, style, className, height = 0, width = 0, ...props }: ProgressbarProps & StyleAndClass) => { const frame = useCurrentFrame(); const { durationInFrames } = useVideoConfig(); const progress = (frame / durationInFrames) * 100; const getColor = useColors(); if (props.type === "line") return (
); if (props.type === "spotify") return (
); if (props.type === "circle") { const size = Math.min(width, height); const radius = (size - (props.barWidth || 1)) / 2; const circumference = 2 * Math.PI * radius; const dash = circumference * (progress / 100); return ( ); } if (props.type === "square") return (
{[1, 2, 3, 4].map((n) => { const horizontal = n % 2 === 0; const left = props.topRight ? n < 3 : n > 2; const top = n < 3; return (
); })}
); return null; };