aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/components/LRCPlayer.tsx
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-02-11 00:18:45 -0800
committerPinapelz <yukais@pinapelz.com>2024-02-11 00:18:45 -0800
commitc8537ee711a61e1953c16f4115f8aea14d4413b1 (patch)
tree70d02678616f5595d1d639cf037a65a5c4f2058f /src/app/components/LRCPlayer.tsx
parentf2d30dd57c5909c2c3e1aeba465fd5fe367b0630 (diff)
chore: bump dependencies
Diffstat (limited to 'src/app/components/LRCPlayer.tsx')
-rw-r--r--src/app/components/LRCPlayer.tsx57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/app/components/LRCPlayer.tsx b/src/app/components/LRCPlayer.tsx
new file mode 100644
index 0000000..c561ee8
--- /dev/null
+++ b/src/app/components/LRCPlayer.tsx
@@ -0,0 +1,57 @@
+import React, { CSSProperties, useCallback } from 'react';
+import { Lrc, LrcLine } from 'react-lrc';
+import styled from 'styled-components';
+import css from 'styled-components';
+
+const Line = styled.div<{ $active: boolean; $next: boolean }>`
+ min-height: 10px;
+ padding: 14px 30px;
+
+ font-size: 40px;
+ font-family: "Roboto", sans-serif;
+ font-weight: 500;
+ text-align: center;
+ color: rgb(72,72,72);
+
+ background: linear-gradient(to right, rgba(0,0,0,0) 50%, rgb(200, 190, 190) 50%);
+ background-size: 200% 100%;
+ background-position: right bottom;
+ transition: color 1s ease-out, background-position 1s ease-out;
+
+ ${({ $active }: { $active: boolean }) => $active ? `
+ color: black;
+ font-weight: 700;
+ ` : ''}
+`;
+const lrcStyle: CSSProperties = {
+ flex: 1,
+ minHeight: 0,
+ overflow: 'hidden !important'
+};
+
+interface LRCPlayerProps {
+ currentMillisecond: number;
+ lrc: string;
+}
+
+const LRCPlayer: React.FC<LRCPlayerProps> = ({ currentMillisecond, lrc }) => {
+ const lineRenderer = useCallback(
+ ({ active, line: { content } }: { active: boolean; line: LrcLine }) => {
+ const next = active && content === '';
+ return <Line $active={active} $next={next}>{content}</Line>;
+ },
+ []
+ );
+
+ return (
+ <Lrc
+ lrc={lrc}
+ lineRenderer={lineRenderer}
+ currentMillisecond={currentMillisecond}
+ style={lrcStyle}
+ recoverAutoScrollInterval={0}
+ />
+ );
+};
+
+export default LRCPlayer;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage