diff --git a/components/layout/floating-controls.tsx b/components/layout/floating-controls.tsx index 5b69e97..b3f05ec 100644 --- a/components/layout/floating-controls.tsx +++ b/components/layout/floating-controls.tsx @@ -1,8 +1,8 @@ "use client"; import { AnimatePresence, motion, useReducedMotion } from "framer-motion"; -import { ShieldCheck, SlidersHorizontal, X } from "lucide-react"; -import { useTranslations } from "next-intl"; +import { Plus, ShieldCheck } from "lucide-react"; +import { useLocale, useTranslations } from "next-intl"; import { useState, type ReactNode } from "react"; import { LocaleToggle } from "@/components/layout/locale-toggle"; @@ -19,12 +19,10 @@ type FloatingControlsProps = { }; const pill = - "flex h-11 w-11 items-center justify-center rounded-full border border-border/60 bg-background/80 text-foreground/80 shadow-panel backdrop-blur-chrome transition-colors hover:bg-accent hover:text-foreground"; + "flex h-11 w-11 items-center justify-center rounded-full border border-border/60 bg-background/85 text-foreground/80 shadow-panel backdrop-blur-chrome transition-colors hover:bg-accent hover:text-foreground"; -const itemVariants = { - hidden: { opacity: 0, y: 12, scale: 0.8 }, - show: { opacity: 1, y: 0, scale: 1 }, -}; +/** Radius (px) of the arc the items fan out along. */ +const RADIUS = 92; export function FloatingControls({ locale, @@ -33,6 +31,8 @@ export function FloatingControls({ }: FloatingControlsProps) { const [open, setOpen] = useState(false); const t = useTranslations("navigation"); + const activeLocale = useLocale(); + const isRtl = activeLocale === "ar"; const reducedMotion = useReducedMotion(); const controls: ReactNode[] = [ @@ -65,50 +65,85 @@ export function FloatingControls({ ); } - return ( -
- - {open ? ( - - {controls.map((control, index) => ( - - {control} - - ))} - - ) : null} - + const count = controls.length; + // Fan the items across a quarter arc from "up" (90°) to "sideways" (180°), + // mirrored for RTL so they always spread away from the corner into the page. + const startAngle = 94; + const endAngle = 176; + const positionFor = (index: number) => { + const angle = count === 1 ? 135 : startAngle + ((endAngle - startAngle) * index) / (count - 1); + const radians = (angle * Math.PI) / 180; + return { + x: (isRtl ? -1 : 1) * Math.cos(radians) * RADIUS, + y: -Math.sin(radians) * RADIUS, + }; + }; - + + + + +
); }