feat(ui):resize connection indicator and add pulse effect for all use cases.

This commit is contained in:
killianlarcher
2026-01-17 20:06:01 +01:00
parent cddb0a7e05
commit 12112afa37
@@ -1,19 +1,17 @@
import { cn } from "@/lib/utils"; import {cn} from "@/lib/utils";
export type ConnectionIndicatorProps = { export type ConnectionIndicatorProps = {
date?: Date | null; date?: Date | null;
}; };
export const ConnectionIndicator = ({ date }: ConnectionIndicatorProps) => { export const ConnectionIndicator = ({date}: ConnectionIndicatorProps) => {
let style = "bg-gray-300"; let style = "bg-gray-300";
let active = false;
if (date instanceof Date && !isNaN(date.getTime())) { if (date instanceof Date && !isNaN(date.getTime())) {
const intervalSeconds = (Date.now() - date.getTime()) / 1000; const intervalSeconds = (Date.now() - date.getTime()) / 1000;
if (intervalSeconds < 55) { if (intervalSeconds < 55) {
style = "bg-green-500"; style = "bg-green-500";
active = true;
} else if (intervalSeconds <= 60) { } else if (intervalSeconds <= 60) {
style = "bg-orange-400"; style = "bg-orange-400";
} else { } else {
@@ -22,8 +20,8 @@ export const ConnectionIndicator = ({ date }: ConnectionIndicatorProps) => {
} }
return ( return (
<div className="relative w-4 h-4"> <div className="relative w-3 h-3">
{active && (
<span <span
className={cn( className={cn(
"absolute -inset-0.25 rounded-full opacity-60 animate-ping", "absolute -inset-0.25 rounded-full opacity-60 animate-ping",
@@ -33,10 +31,10 @@ export const ConnectionIndicator = ({ date }: ConnectionIndicatorProps) => {
animationDuration: "2s", animationDuration: "2s",
}} }}
/> />
)}
<div <div
className={cn( className={cn(
"relative w-4 h-4 rounded-full shadow-sm animate-pulse", "relative w-3 h-3 rounded-full shadow-sm animate-pulse",
style style
)} )}
style={{ style={{