feat(webui): refine day-night themes and interaction continuity
This commit is contained in:
1 parent
12c7d116a0
commit
e8544a79a6
32 files changed
+613
-29
No files matched your search
@@ -24,7 +24,7 @@ const DialogOverlay = React.forwardRef<
|
||||
ref={ref}
|
||||
className={cn(
|
||||
modalOverlayClassName,
|
||||
"duration-200 motion-reduce:animate-none",
|
||||
"duration-200 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
@@ -209,7 +209,7 @@ const DialogContent = React.forwardRef<
|
||||
}}
|
||||
className={cn(
|
||||
modalSurfaceClassName,
|
||||
"relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none",
|
||||
"relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none",
|
||||
placement === "bottom"
|
||||
? "mt-auto max-h-[85dvh] overflow-y-auto overscroll-contain rounded-t-modal pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-bottom-full ease-[cubic-bezier(0.2,0,0,1)] duration-300"
|
||||
: "my-auto origin-center rounded-modal data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
||||
|
||||
@@ -37,7 +37,7 @@ const DropdownMenuContent = React.forwardRef<
|
||||
className={cn(
|
||||
floatingSurfaceClassName,
|
||||
floatingSurfaceMotionClassName,
|
||||
"max-h-[min(var(--radix-dropdown-menu-content-available-height),28rem)] min-w-[10rem]",
|
||||
"origin-[var(--radix-dropdown-menu-content-transform-origin)] max-h-[min(var(--radix-dropdown-menu-content-available-height),28rem)] min-w-[10rem]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
@@ -147,7 +147,7 @@ const DropdownMenuSubContent = React.forwardRef<
|
||||
className={cn(
|
||||
floatingSurfaceClassName,
|
||||
floatingSurfaceMotionClassName,
|
||||
"max-h-[min(var(--radix-dropdown-menu-content-available-height),22rem)] min-w-[11rem] overflow-y-auto",
|
||||
"origin-[var(--radix-dropdown-menu-content-transform-origin)] max-h-[min(var(--radix-dropdown-menu-content-available-height),22rem)] min-w-[11rem] overflow-y-auto",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -19,7 +19,14 @@ export const floatingSurfaceClassName =
|
||||
`${floatingSurfaceVisualClassName} z-50 overflow-x-hidden overflow-y-auto overscroll-contain scrollbar-thin`;
|
||||
|
||||
export const floatingSurfaceMotionClassName =
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0";
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 " +
|
||||
"data-[state=open]:zoom-in-[0.98] data-[state=closed]:zoom-out-[0.98] " +
|
||||
"data-[side=bottom]:slide-in-from-top-1 data-[side=bottom]:slide-out-to-top-1 " +
|
||||
"data-[side=top]:slide-in-from-bottom-1 data-[side=top]:slide-out-to-bottom-1 " +
|
||||
"data-[side=right]:slide-in-from-left-1 data-[side=right]:slide-out-to-left-1 " +
|
||||
"data-[side=left]:slide-in-from-right-1 data-[side=left]:slide-out-to-right-1 " +
|
||||
"transition-none data-[state=open]:duration-150 data-[state=closed]:duration-100 ease-out " +
|
||||
"motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none";
|
||||
|
||||
export const floatingItemClassName =
|
||||
"relative flex min-h-8 select-none items-center gap-2 rounded-control px-2.5 py-2 text-[13px] outline-none transition-colors [&>svg]:h-4 [&>svg]:w-4 [&>svg]:shrink-0";
|
||||
|
||||
@@ -30,7 +30,7 @@ const PopoverContent = React.forwardRef<
|
||||
className={cn(
|
||||
floatingSurfaceClassName,
|
||||
floatingSurfaceMotionClassName,
|
||||
"max-h-[min(var(--radix-popover-content-available-height),28rem)]",
|
||||
"origin-[var(--radix-popover-content-transform-origin)] max-h-[min(var(--radix-popover-content-available-height),28rem)]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { createContext, forwardRef, useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
|
||||
import { useReducedMotion } from "motion/react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface SidebarPanelProps extends HTMLAttributes<HTMLElement> {
|
||||
@@ -18,13 +17,25 @@ export const SidebarPanel = forwardRef<HTMLElement, SidebarPanelProps>(function
|
||||
open = true, isClosing, ...props
|
||||
}, ref) {
|
||||
const [present, setPresent] = useState(open);
|
||||
const reducedMotion = useReducedMotion();
|
||||
const panel = useRef<HTMLElement | null>(null);
|
||||
const setPanel = useCallback((node: HTMLElement | null) => {
|
||||
panel.current = node;
|
||||
if (typeof ref === "function") ref(node);
|
||||
else if (ref) ref.current = node;
|
||||
}, [ref]);
|
||||
useEffect(() => {
|
||||
if (open) { setPresent(true); return; }
|
||||
const timer = window.setTimeout(() => setPresent(false), reducedMotion ? 0 : 300);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [open, reducedMotion]);
|
||||
return open || present ? <SidebarPanelContent {...props} ref={ref} isClosing={isClosing || !open} /> : null;
|
||||
// Only the slot and its surface own the exit. Descendant activity may loop forever.
|
||||
const animations = [panel.current, panel.current?.firstElementChild]
|
||||
.flatMap((element) => element?.getAnimations?.() ?? []);
|
||||
if (!animations.length) { setPresent(false); return; }
|
||||
let cancelled = false;
|
||||
void Promise.allSettled(animations.map((animation) => animation.finished)).then(() => {
|
||||
if (!cancelled) setPresent(false);
|
||||
});
|
||||
return () => { cancelled = true; };
|
||||
}, [open]);
|
||||
return open || present ? <SidebarPanelContent {...props} ref={setPanel} isClosing={isClosing || !open} /> : null;
|
||||
});
|
||||
|
||||
/** Shared nonmodal side slot. Contents keep their final width while the slot opens. */
|
||||
@@ -46,6 +57,8 @@ const SidebarPanelContent = forwardRef<HTMLElement, SidebarPanelProps>(function
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, []);
|
||||
return <aside {...props} ref={setPanel} data-closing={isClosing || undefined}
|
||||
aria-hidden={isClosing ? true : props["aria-hidden"]}
|
||||
{...(isClosing ? { inert: "" } : {})}
|
||||
style={{
|
||||
"--file-preview-width": `${width}px`,
|
||||
"--file-preview-slot-width": isClosing ? "0px" : !entered ? "var(--sidebar-enter-width, 0px)" : `${width}px`,
|
||||
|
||||
Reference in new issue
Block a user