From 5c54176456e097cffe8efa47dfcdbd89db94b134 Mon Sep 17 00:00:00 2001 From: Durgesh <84910181+Durgesh-babu@users.noreply.github.com> Date: Sun, 1 Feb 2026 19:33:10 +0530 Subject: [PATCH 1/4] feat(fuselage): implement loading state in AudioPlayer with spinner animation --- .../AudioPlayer/AudioPlayer.styles.scss | 16 ++++++++++++ .../components/AudioPlayer/AudioPlayer.tsx | 25 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 packages/fuselage/src/components/AudioPlayer/AudioPlayer.styles.scss diff --git a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.styles.scss b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.styles.scss new file mode 100644 index 0000000000..436ba3c8df --- /dev/null +++ b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.styles.scss @@ -0,0 +1,16 @@ +.rcx-audio-player { + &--loading { + .rcx-icon--name-loading { + animation: spin-animation 0.8s linear infinite; + } + } +} + +@keyframes spin-animation { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} \ No newline at end of file diff --git a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx index 61b44839f8..1028e1aefe 100644 --- a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx +++ b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx @@ -4,6 +4,7 @@ import { useState, useRef, forwardRef } from 'react'; import { Box, Button, IconButton, Margins } from '../..'; import { Slider } from '../Slider'; +import './AudioPlayer.styles.scss'; const getMaskTime = (durationTime: number) => new Date(durationTime * 1000) @@ -73,6 +74,16 @@ export type AudioPlayerProps = { trackProps?: TrackHTMLAttributes; }; +const getIcon = (isLoading: boolean, isPlaying: boolean) => { + if (isLoading) { + return 'loading'; + } + if (isPlaying) { + return 'pause-shape-filled'; + } + return 'play-shape-filled'; +}; + const AudioPlayer = forwardRef( ( { @@ -93,6 +104,7 @@ const AudioPlayer = forwardRef( ) => { const audioRef = useRef(null); const refs = useMergedRefs(ref, audioRef); + const [isLoading, setIsLoading] = useState(true); const [isPlaying, setIsPlaying] = useState(false); const [currentTime, setCurrentTime] = useState(0); const [durationTime, setDurationTime] = useState(0); @@ -128,6 +140,8 @@ const AudioPlayer = forwardRef( return ( ( medium onClick={handlePlay} aria-label={isPlaying ? pauseLabel : playLabel} - icon={isPlaying ? 'pause-shape-filled' : 'play-shape-filled'} + icon={getIcon(isLoading, isPlaying)} + disabled={isLoading} /> @@ -160,6 +175,7 @@ const AudioPlayer = forwardRef( showOutput={false} value={currentTime} maxValue={durationTime} + disabled={isLoading} onChange={(value) => { if (audioRef.current) { audioRef.current.currentTime = value; @@ -171,6 +187,7 @@ const AudioPlayer = forwardRef(