From c48243360bf8f58896e2440acce843c1905d8201 Mon Sep 17 00:00:00 2001 From: Prayas Lashkari Date: Thu, 12 Mar 2026 17:15:18 -0400 Subject: [PATCH] refactor: improve icon handling and formatting in LaunchWindow component --- src/components/launch/LaunchWindow.tsx | 104 ++++++++++++++++++------- 1 file changed, 75 insertions(+), 29 deletions(-) diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx index f565d1e..73f0432 100644 --- a/src/components/launch/LaunchWindow.tsx +++ b/src/components/launch/LaunchWindow.tsx @@ -3,7 +3,14 @@ import { BsRecordCircle } from "react-icons/bs"; import { FaRegStopCircle } from "react-icons/fa"; import { FaFolderOpen } from "react-icons/fa6"; import { FiMinus, FiX } from "react-icons/fi"; -import { MdMic, MdMicOff, MdMonitor, MdVideoFile, MdVolumeOff, MdVolumeUp } from "react-icons/md"; +import { + MdMic, + MdMicOff, + MdMonitor, + MdVideoFile, + MdVolumeOff, + MdVolumeUp, +} from "react-icons/md"; import { RxDragHandleDots2 } from "react-icons/rx"; import { useAudioLevelMeter } from "../../hooks/useAudioLevelMeter"; import { useMicrophoneDevices } from "../../hooks/useMicrophoneDevices"; @@ -11,6 +18,30 @@ import { useScreenRecorder } from "../../hooks/useScreenRecorder"; import { AudioLevelMeter } from "../ui/audio-level-meter"; import styles from "./LaunchWindow.module.css"; +const ICON_SIZE = 16; + +const ICON_CONFIG = { + drag: { icon: RxDragHandleDots2, size: ICON_SIZE }, + monitor: { icon: MdMonitor, size: ICON_SIZE }, + volumeOn: { icon: MdVolumeUp, size: ICON_SIZE }, + volumeOff: { icon: MdVolumeOff, size: ICON_SIZE }, + micOn: { icon: MdMic, size: ICON_SIZE }, + micOff: { icon: MdMicOff, size: ICON_SIZE }, + stop: { icon: FaRegStopCircle, size: ICON_SIZE }, + record: { icon: BsRecordCircle, size: ICON_SIZE }, + videoFile: { icon: MdVideoFile, size: ICON_SIZE }, + folder: { icon: FaFolderOpen, size: ICON_SIZE }, + minimize: { icon: FiMinus, size: ICON_SIZE }, + close: { icon: FiX, size: ICON_SIZE }, +} as const; + +type IconName = keyof typeof ICON_CONFIG; + +function getIcon(name: IconName, className?: string) { + const { icon: Icon, size } = ICON_CONFIG[name]; + return ; +} + export function LaunchWindow() { const { recording, @@ -132,7 +163,9 @@ export function LaunchWindow() { return (
-
+
{/* Mic controls panel */} {showMicControls && (
{/* Drag handle */}
- + {getIcon("drag", "text-white/30")}
{/* Source selector */} @@ -180,7 +214,7 @@ export function LaunchWindow() { disabled={recording} title={selectedSource} > - + {getIcon("monitor", "text-white/80")} {selectedSource} @@ -190,27 +224,31 @@ export function LaunchWindow() {
@@ -223,16 +261,16 @@ export function LaunchWindow() { > {recording ? ( <> - + {getIcon("stop", "text-red-400")} {formatTime(elapsed)} ) : ( - + getIcon( + "record", + hasSelectedSource ? "text-white/80" : "text-white/30", + ) )} @@ -243,7 +281,7 @@ export function LaunchWindow() { disabled={recording} title="Open video file" > - + {getIcon("videoFile", "text-white/60")} {/* Open project */} @@ -253,16 +291,24 @@ export function LaunchWindow() { disabled={recording} title="Open project" > - + {getIcon("folder", "text-white/60")} {/* Window controls */}
- -