feat: tab slide animation, hover feedback, snapshot toast
CD — Kai-Sa-Cam Deployment / deploy (push) Successful in 10s

This commit is contained in:
2026-10-30 20:50:31 +01:00
parent 841dd6e8a9
commit 2856eb80e7
4 changed files with 66 additions and 40 deletions
+65 -39
View File
@@ -19,6 +19,7 @@ export function App() {
const [snapshots, setSnapshots] = useState<string[]>([]);
const [sessionExpired, setSessionExpired] = useState(false);
const [streamKey, setStreamKey] = useState(0);
const [toast, setToast] = useState<string | null>(null);
const {
startRecording,
@@ -70,8 +71,12 @@ export function App() {
if (!res.ok) throw new Error("Snapshot failed");
const data = await res.json();
setSnapshots((prev) => [data.filename, ...prev]);
setToast("Capture d'écran prise");
setTimeout(() => setToast(null), 2000);
} catch (e) {
console.error("Snapshot error:", e);
setToast("Erreur lors de la capture");
setTimeout(() => setToast(null), 2000);
}
};
@@ -103,23 +108,33 @@ export function App() {
</div>
)}
<main className="flex-1 flex flex-col min-h-0">
<nav className="mx-auto mt-[1vh] sm:mt-[1.5vh] flex gap-2 trans-bloc p-1 rounded-[50px] w-fit shrink-0">
<main className="flex-1 flex flex-col min-h-0 relative">
{toast && (
<div className="absolute top-2 right-2 z-50 glass-card px-4 py-2 rounded-[50px] text-sm animate-fade-in">
{toast}
</div>
)}
<nav className="mx-auto mt-[1vh] sm:mt-[1.5vh] flex gap-2 trans-bloc p-1 rounded-[50px] w-fit shrink-0 relative overflow-hidden">
<div
className={`absolute top-1 bottom-1 w-[calc(50%-4px)] rounded-[50px] glass-button transition-transform duration-300 ease-in-out ${
activeTab === "media" ? "translate-x-[calc(100%+4px)]" : "translate-x-0"
}`}
/>
<button
className={`px-6 sm:px-8 md:px-10 py-1.5 sm:py-2 md:py-2.5 rounded-[50px] text-sm sm:text-base md:text-lg transition-all active:scale-95 ${
className={`relative z-10 px-6 sm:px-8 md:px-10 py-1.5 sm:py-2 md:py-2.5 rounded-[50px] text-sm sm:text-base md:text-lg transition-all active:scale-95 ${
activeTab === "live"
? "glass-button font-medium"
: "bg-transparent hover:opacity-80"
? "font-medium"
: "hover:bg-white/5"
}`}
onClick={() => setActiveTab("live")}
>
Live
</button>
<button
className={`px-6 sm:px-8 md:px-10 py-1.5 sm:py-2 md:py-2.5 rounded-[50px] text-sm sm:text-base md:text-lg transition-all active:scale-95 ${
className={`relative z-10 px-6 sm:px-8 md:px-10 py-1.5 sm:py-2 md:py-2.5 rounded-[50px] text-sm sm:text-base md:text-lg transition-all active:scale-95 ${
activeTab === "media"
? "glass-button font-medium"
: "bg-transparent hover:opacity-80"
? "font-medium"
: "hover:bg-white/5"
}`}
onClick={() => setActiveTab("media")}
>
@@ -127,40 +142,51 @@ export function App() {
</button>
</nav>
{activeTab === "live" ? (
<div className="flex-1 flex flex-col items-center gap-2 sm:gap-3 md:gap-4 mt-2 sm:mt-3 px-1 sm:px-2 min-h-0">
<div className="w-full flex-1 min-h-0 rounded-[20px] sm:rounded-[30px] overflow-hidden glass-card animate-fade-in">
{/* Même origine => même session Access, plus de stream.esiah.dev.
Le key force le rechargement du flux après une reconnexion. */}
<VideoPlayer
key={streamKey}
streamUrl="/go2rtc/stream.html?src=webcam&mode=mse"
/>
</div>
<div className="w-full max-w-6xl shrink-0">
<Controls
isRecording={isRecording}
recordingTime={recordingTime}
isTalking={isTalking}
gain={gain}
onGainChange={setGain}
onRecord={handleRecord}
onSnapshot={handleSnapshot}
onTalk={handleTalk}
disabled={Boolean(recError || talkError)}
/>
</div>
{(recError || talkError) && (
<div className="text-red-400 text-xs sm:text-sm text-center px-4 error-message animate-fade-in shrink-0">
{recError || talkError}
<div className="flex-1 min-h-0 relative overflow-hidden">
<div
className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-in-out ${
activeTab === "live" ? "translate-x-0" : "-translate-x-full"
}`}
>
<div className="flex-1 flex flex-col items-center gap-2 sm:gap-3 md:gap-4 mt-2 sm:mt-3 px-1 sm:px-2 min-h-0">
<div className="w-full flex-1 min-h-0 rounded-[20px] sm:rounded-[30px] overflow-hidden glass-card animate-fade-in">
{/* Même origine => même session Access, plus de stream.esiah.dev.
Le key force le rechargement du flux après une reconnexion. */}
<VideoPlayer
key={streamKey}
streamUrl="/go2rtc/stream.html?src=webcam&mode=mse"
/>
</div>
)}
<div className="w-full max-w-6xl shrink-0">
<Controls
isRecording={isRecording}
recordingTime={recordingTime}
isTalking={isTalking}
gain={gain}
onGainChange={setGain}
onRecord={handleRecord}
onSnapshot={handleSnapshot}
onTalk={handleTalk}
disabled={Boolean(recError || talkError)}
/>
</div>
{(recError || talkError) && (
<div className="text-red-400 text-xs sm:text-sm text-center px-4 error-message animate-fade-in shrink-0">
{recError || talkError}
</div>
)}
</div>
</div>
) : (
<div className="flex-1 flex flex-col mt-2 sm:mt-3 px-1 sm:px-2 min-h-0 overflow-auto no-scrollbar">
<MediaGallery />
<div
className={`absolute inset-0 flex flex-col transition-transform duration-300 ease-in-out ${
activeTab === "media" ? "translate-x-0" : "translate-x-full"
}`}
>
<div className="flex-1 flex flex-col mt-2 sm:mt-3 px-1 sm:px-2 min-h-0 overflow-auto no-scrollbar">
<MediaGallery />
</div>
</div>
)}
</div>
</main>
</section>
</div>
+1 -1
View File
@@ -32,7 +32,7 @@ body {
"Helvetica Neue",
Arial,
sans-serif;
background-image: url(/background_img.png);
background-image: url(/background_img.jpeg);
background-size: cover;
background-position: center;
background-attachment: fixed;