feat(webui): refine day-night themes and interaction continuity

This commit is contained in:
Xubin Ren committed 2026-11-07 23:19:32 +08:00
1 parent 12c7d116a0
commit e8544a79a6
32 files changed
+613 -29

No files matched your search

+8 -2
View File
@@ -182,7 +182,7 @@ export function Sidebar(props: SidebarProps) {
onClick={collapsed ? props.onExpand : undefined}
tabIndex={collapsed ? 0 : -1}
className={cn(
"host-no-drag flex h-8 w-8 shrink-0 items-center justify-center rounded-control transition-colors",
"host-no-drag relative flex h-8 w-8 shrink-0 items-center justify-center rounded-control transition-colors",
props.hostChromeInset && "mt-5",
!collapsed && "pointer-events-none",
)}
@@ -190,7 +190,13 @@ export function Sidebar(props: SidebarProps) {
<img
src="/brand/nanobot_mark.svg"
alt=""
className="h-8 w-8 select-none object-contain"
className="theme-art h-8 w-8 select-none object-contain dark:opacity-0"
draggable={false}
/>
<img
src="/brand/nanobot_mark_night.svg"
alt=""
className="theme-art absolute inset-0 h-8 w-8 select-none object-contain opacity-0 dark:opacity-100"
draggable={false}
/>
</button>
+5
View File
@@ -1,3 +1,8 @@
:root.dark .star-prompt-dialog {
background-color: hsl(220 16% 17%);
border-color: hsl(220 14% 28%);
}
.star-prompt-decoration {
position: absolute;
top: -12px;
+8 -3
View File
@@ -3,6 +3,7 @@ import { ExternalLink, Sparkle, Star, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import starInvitation from "@/assets/star-invitation.webp";
import starInvitationNight from "@/assets/star-invitation-night.webp";
import { Button } from "@/components/ui/button";
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
@@ -57,13 +58,17 @@ export function StarPromptView({ open, saving, error, starError = false, onOpenC
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent showCloseButton={false}
className="flex max-h-[calc(100dvh-32px)] max-w-[520px] flex-col gap-0 overflow-y-auto overscroll-contain p-5 pb-2.5 outline-none max-[480px]:p-4 max-[480px]:pb-2"
className="star-prompt-dialog flex max-h-[calc(100dvh-32px)] max-w-[520px] flex-col gap-0 overflow-y-auto overscroll-contain p-5 pb-2.5 outline-none max-[480px]:p-4 max-[480px]:pb-2"
onOpenAutoFocus={(event) => {
event.preventDefault();
titleRef.current?.focus({ preventScroll: true });
}} onCloseAutoFocus={onCloseAutoFocus}>
<img src={starInvitation} alt="" width={1672} height={941} draggable={false}
className="aspect-[1672/941] w-full shrink-0 select-none rounded-control bg-muted object-cover" />
<div className="star-prompt-art relative aspect-[1672/941] w-full shrink-0 overflow-hidden rounded-control bg-muted">
<img src={starInvitation} alt="" width={1672} height={941} draggable={false}
className="theme-art absolute inset-0 h-full w-full select-none object-cover dark:opacity-0" />
<img src={starInvitationNight} alt="" width={1672} height={941} draggable={false}
className="theme-art absolute inset-0 h-full w-full select-none object-cover opacity-0 dark:opacity-100" />
</div>
<DialogClose aria-label={t("common.close")}
className="absolute right-[23px] top-[23px] grid h-11 w-11 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-white max-[480px]:right-[18px] max-[480px]:top-[18px]">
<span className="grid h-[30px] w-[30px] place-items-center rounded-full bg-black/40 text-white backdrop-blur-sm transition-colors hover:bg-black/60 motion-reduce:transition-none">
@@ -10,7 +10,7 @@ export function AboutSettingsLayout({ versionCheck, links, starLink }: {
starLink: ReactNode;
}) {
return <div className="flex flex-1 flex-col gap-5">
<div className="flex flex-col items-center gap-3 py-6 text-center">
<div className="brand-atmosphere flex flex-col items-center gap-3 py-6 text-center">
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16 select-none" draggable={false} />
<h1><img src="/brand/nanobot_wordmark.svg" alt="nanobot" width={800} height={164} className="h-auto w-40 select-none dark:brightness-150" draggable={false} /></h1>
</div>
@@ -40,6 +40,7 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
<span className="appearance-theme-miniature" data-mode={value} aria-hidden>
<span className="appearance-mini-sidebar"><span /><span /><span /></span>
<span className="appearance-mini-main"><span /><span /><span /><span /></span>
<span className="appearance-mini-sky"><Sun /><Moon /></span>
</span>
<span className="appearance-theme-label text-ui-label">
<span className="flex min-w-0 items-center gap-1.5"><Icon className="h-3.5 w-3.5 shrink-0" aria-hidden /><span>{label}</span></span>
@@ -104,7 +104,11 @@ export function ReadingSettings({ preferences, onChange }: {
if (!commitDraft()) event.preventDefault();
}}
onKeyDown={(event) => {
if (event.key === "Enter") event.currentTarget.blur();
if (event.key === "Enter") {
event.preventDefault();
// Keep an invalid edit focused so hover/blur dismissal cannot hide its feedback.
if (commitDraft()) event.currentTarget.blur();
}
if (event.key === "Escape") {
event.preventDefault();
event.stopPropagation();
@@ -7,17 +7,27 @@
.appearance-theme-option input:focus-visible + .appearance-theme-card { outline: 2px solid hsl(var(--ring) / 0.65); outline-offset: 3px; }
.appearance-theme-check { opacity: 0; }
.appearance-theme-option input:checked + .appearance-theme-card .appearance-theme-check { opacity: 1; }
.appearance-theme-option input:checked + .appearance-theme-card { border-color: hsl(var(--foreground) / 0.5); }
.appearance-theme-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 8px 4px 2px; min-height: 36px; }
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; position: relative; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
.appearance-theme-miniature[data-mode="dark"] { --mini-paper: #303030; --mini-sidebar: #383838; --mini-line: #656565; }
.appearance-theme-miniature[data-mode="system"] { --mini-paper: linear-gradient(110deg, #fff calc(50% - 0.5px), #303030 calc(50% + 0.5px)); --mini-sidebar: #f1f0ec; --mini-line: #969590; }
.appearance-mini-sidebar { width: 24%; display: flex; flex-direction: column; gap: 6px; padding: 11px 7px; background: var(--mini-sidebar); }
.appearance-mini-sidebar::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: #d7834c; margin-bottom: 6px; }
.appearance-mini-sidebar::before { content: ""; width: 11px; height: 11px; background: url('/brand/nanobot_mark.svg') center / contain no-repeat; margin-bottom: 3px; }
.appearance-mini-sidebar span { height: 3px; border-radius: 3px; background: var(--mini-line); }
.appearance-mini-main { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; padding: 16px 12px 10px; }
.appearance-mini-main span { height: 3px; width: 80%; border-radius: 3px; background: var(--mini-line); }
.appearance-mini-main span:first-child { width: 46%; height: 5px; margin-bottom: 4px; }
.appearance-mini-main span:last-child { width: 100%; height: 13px; margin-top: auto; border: 1px solid var(--mini-line); background: transparent; border-radius: 5px; }
.appearance-mini-sky { position: absolute; inset: 0 0 0 24%; pointer-events: none; background: radial-gradient(ellipse at 80% 15%, rgb(252 204 110 / 0.2), transparent 65%); }
.appearance-mini-sky svg { position: absolute; top: 10px; right: 10px; width: 12px; height: 12px; color: #b87522; stroke-width: 1.5; }
.appearance-mini-sky svg + svg { display: none; color: #b4c6e8; }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky { background: radial-gradient(ellipse at 80% 15%, rgb(103 147 220 / 0.2), transparent 65%); }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky svg:first-child { display: none; }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky svg + svg { display: block; }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky { background: linear-gradient(110deg, rgb(252 204 110 / 0.12) 40%, rgb(103 147 220 / 0.12) 60%); }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky svg:first-child { right: 56%; }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky svg + svg { display: block; }
.appearance-reading-card { overflow: hidden; border-radius: var(--radius-panel); background: hsl(var(--settings-surface)); }
.appearance-reading-controls { padding: 20px var(--settings-inset, 16px); }
.appearance-size-options { display: flex; align-items: center; gap: 12px; max-width: 100%; }
+1 -1
View File
@@ -1471,7 +1471,7 @@ export function ThreadShell({
const emptyState = initialHistoryLoading ? (
<ThreadLoadingSkeleton />
) : (
<div className="flex w-full flex-col items-center text-center animate-in fade-in-0 slide-in-from-bottom-2 [animation-duration:220ms] motion-reduce:animate-none">
<div className="brand-atmosphere brand-atmosphere-welcome flex w-full flex-col items-center text-center animate-in fade-in-0 slide-in-from-bottom-2 [animation-duration:220ms] motion-reduce:animate-none">
<HeroGreeting text={t(heroGreetingKey)} />
</div>
);
+2 -2
View File
@@ -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",
+2 -2
View File
@@ -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}
+8 -1
View File
@@ -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";
+1 -1
View File
@@ -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}
+19 -6
View File
@@ -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`,