From 29d5fe3b70a19a0804e0d4d77158385b7810799f Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sat, 15 Feb 2025 14:56:58 -0800 Subject: [PATCH] frontend: Start working on song table --- frontend/src/components/App.tsx | 77 ++------------------------- frontend/src/components/SongTable.tsx | 71 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 frontend/src/components/SongTable.tsx diff --git a/frontend/src/components/App.tsx b/frontend/src/components/App.tsx index 7b4e595..f306f9b 100644 --- a/frontend/src/components/App.tsx +++ b/frontend/src/components/App.tsx @@ -1,4 +1,5 @@ -import React, { HTMLAttributes, useState, useRef, useEffect } from 'react'; +import React, { HTMLAttributes, useState } from 'react'; +import SongTable from './SongTable'; import classNames from 'classnames'; import { FaPlay, FaPause, FaStepForward, FaStepBackward } from 'react-icons/fa'; @@ -37,87 +38,17 @@ const NowPlaying: React.FC = (props) => { ); }; -const SongTable: React.FC = () => { - const songs = Array.from({ length: 20 }, (_, index) => `Song ${index + 1}`); - - const SongRow: React.FC<{ song: string }> = ({ song }) => { - const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); - const buttonRef = useRef(null); - - useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { - if (buttonRef.current && !buttonRef.current.contains(event.target as Node)) { - setShowDeleteConfirm(false); - } - }; - - if (showDeleteConfirm) { - document.addEventListener('click', handleClickOutside); - } - - return () => { - document.removeEventListener('click', handleClickOutside); - }; - }, [showDeleteConfirm]); - - return ( -
-
- -
- -
-
- {song} -
-
- -
- - - -
-
- ); - }; - - return ( -
- {songs.map((song, index) => ( - - ))} -
- ); -}; const App: React.FC = () => { const [isPlaying, setIsPlaying] = useState(false); - const [songName, setSongName] = useState('Song Name'); - const [fileName, setFileName] = useState('Song Name.mp3'); return (
setIsPlaying(!isPlaying)} onStepForward={() => {}} diff --git a/frontend/src/components/SongTable.tsx b/frontend/src/components/SongTable.tsx new file mode 100644 index 0000000..3cdb93d --- /dev/null +++ b/frontend/src/components/SongTable.tsx @@ -0,0 +1,71 @@ +import React, { useEffect, useRef, useState } from "react"; +import { FaPlay } from 'react-icons/fa'; + +const SongRow: React.FC<{ song: string }> = ({ song }) => { + const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); + const buttonRef = useRef(null); + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (buttonRef.current && !buttonRef.current.contains(event.target as Node)) { + setShowDeleteConfirm(false); + } + }; + + if (showDeleteConfirm) { + document.addEventListener('click', handleClickOutside); + } + + return () => { + document.removeEventListener('click', handleClickOutside); + }; + }, [showDeleteConfirm]); + + return ( +
+
+ +
+ +
+
+ {song} +
+
+ +
+ +
+
+ ); +}; + +const SongTable: React.FC = () => { + const songs = Array.from({ length: 20 }, (_, index) => `Song ${index + 1}`); + + return ( +
+ {songs.map((song, index) => ( + + ))} +
+ ); +}; + +export default SongTable; \ No newline at end of file