From f5a60263b2eb606e511d3b76959e64d058a27f31 Mon Sep 17 00:00:00 2001 From: johnnyjoygh Date: Sun, 21 Jun 2026 09:17:04 +0800 Subject: [PATCH] chore(ui): align frontend on shadcn kit Design system: - add semantic --success/--warning OKLCH tokens across themes; replace hardcoded green/amber feedback colors and their manual dark: overrides - drop the unused @emotion dependency Kit usage: - migrate raw +
diff --git a/web/src/components/CreateWebhookDialog.tsx b/web/src/components/CreateWebhookDialog.tsx index ed63104a..d578aa83 100644 --- a/web/src/components/CreateWebhookDialog.tsx +++ b/web/src/components/CreateWebhookDialog.tsx @@ -211,7 +211,7 @@ function CreateWebhookDialog({ open, onOpenChange, webhookName, onSuccess }: Pro disabled={!state.signingSecret} aria-label={t("setting.webhook.create-dialog.copy-secret")} > - {secretCopied ? : } + {secretCopied ? : }
{filteredLocales.map((locale) => ( - +
))} {filteredLocales.length === 0 && (
diff --git a/web/src/components/MemoContent/Mention.tsx b/web/src/components/MemoContent/Mention.tsx index bb7c4424..49a3b8c6 100644 --- a/web/src/components/MemoContent/Mention.tsx +++ b/web/src/components/MemoContent/Mention.tsx @@ -29,7 +29,7 @@ export const Mention: React.FC = ({ return ( {url}
+ + +
); })} diff --git a/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx b/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx index 79c38a5e..5903a887 100644 --- a/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx +++ b/web/src/components/MemoMetadata/Attachment/AttachmentListEditor.tsx @@ -4,6 +4,7 @@ import type { AttachmentItem, LocalFile } from "@/components/MemoEditor/types/at import { getAudioRecordingTimeLabel, toAttachmentItems } from "@/components/MemoEditor/types/attachment"; import MetadataSection from "@/components/MemoMetadata/MetadataSection"; import PreviewImageDialog from "@/components/PreviewImageDialog"; +import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb"; import { formatFileSize, getFileTypeLabel } from "@/utils/format"; @@ -33,56 +34,50 @@ const AttachmentItemActions: FC<{ return (
{onMoveUp && ( - + )} {onMoveDown && ( - + )} {onRemove && ( - + )}
); @@ -141,8 +136,7 @@ const AttachmentItemCard: FC<{
{(category === "image" || category === "motion") && thumbnailUrl ? ( - +
) : isVoiceNote ? ( <> +
); }; diff --git a/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx b/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx index adbd868b..20492b1b 100644 --- a/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx +++ b/web/src/components/MemoMetadata/Attachment/AudioAttachmentItem.tsx @@ -1,5 +1,6 @@ import { PauseIcon, PlayIcon } from "lucide-react"; import { useEffect, useRef, useState } from "react"; +import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { formatFileSize, getFileTypeLabel } from "@/utils/format"; import { formatAudioTime } from "./attachmentHelpers"; @@ -134,14 +135,14 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
- +
@@ -157,14 +158,14 @@ const AudioAttachmentItem = ({ filename, sourceUrl, mimeType, size, title, compa
{timeLabel}
- +
diff --git a/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx b/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx index 23b2a4ae..1e1979b4 100644 --- a/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx +++ b/web/src/components/MemoMetadata/Location/LocationDisplayEditor.tsx @@ -1,5 +1,6 @@ import { MapPinIcon, XIcon } from "lucide-react"; import type { FC } from "react"; +import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import type { Location } from "@/types/proto/api/v1/memo_service_pb"; import { getLocationCoordinatesText, getLocationDisplayText } from "./locationHelpers"; @@ -30,15 +31,9 @@ const LocationDisplayEditor: FC = ({ location, onRem {onRemove && ( - + )} ); diff --git a/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx b/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx index a853c996..b9d65594 100644 --- a/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx +++ b/web/src/components/MemoMetadata/Location/LocationDisplayView.tsx @@ -1,17 +1,16 @@ import { MapPinIcon } from "lucide-react"; import { useState } from "react"; import { LazyLocationPicker } from "@/components/map/LazyLocationPicker"; +import { Button } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; -import { cn } from "@/lib/utils"; import type { Location } from "@/types/proto/api/v1/memo_service_pb"; import { getLocationCoordinatesText, getLocationDisplayText } from "./locationHelpers"; interface LocationDisplayViewProps { location?: Location; - className?: string; } -const LocationDisplayView = ({ location, className }: LocationDisplayViewProps) => { +const LocationDisplayView = ({ location }: LocationDisplayViewProps) => { const [popoverOpen, setPopoverOpen] = useState(false); if (!location) { @@ -23,20 +22,13 @@ const LocationDisplayView = ({ location, className }: LocationDisplayViewProps) return ( - +
diff --git a/web/src/components/MemoMetadata/SectionHeader.tsx b/web/src/components/MemoMetadata/SectionHeader.tsx index e753e8a0..b4189170 100644 --- a/web/src/components/MemoMetadata/SectionHeader.tsx +++ b/web/src/components/MemoMetadata/SectionHeader.tsx @@ -1,4 +1,5 @@ import type { LucideIcon } from "lucide-react"; +import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; export interface SectionHeaderTab { @@ -25,16 +26,17 @@ const SectionHeader = ({ icon: Icon, title, count, tabs }: SectionHeaderProps) =
{tabs.map((tab, idx) => (
- + {idx < tabs.length - 1 && /}
))} diff --git a/web/src/components/MemoView/components/MemoBody.tsx b/web/src/components/MemoView/components/MemoBody.tsx index a3142240..29ddfa11 100644 --- a/web/src/components/MemoView/components/MemoBody.tsx +++ b/web/src/components/MemoView/components/MemoBody.tsx @@ -12,12 +12,9 @@ const BlurOverlay: React.FC<{ onClick?: () => void }> = ({ onClick }) => { const t = useTranslate(); return (
- +
); }; diff --git a/web/src/components/MemoView/components/MemoHeader.tsx b/web/src/components/MemoView/components/MemoHeader.tsx index 7ecb5381..e87bcb75 100644 --- a/web/src/components/MemoView/components/MemoHeader.tsx +++ b/web/src/components/MemoView/components/MemoHeader.tsx @@ -45,7 +45,10 @@ const MemoHeader: React.FC = ({ showCreator, showVisibility, sh ); const timeTooltip = { createdAt: createTime ? `${t("common.created-at")}: ${createTime.toLocaleString(i18n.language)}` : undefined, - updatedAt: updateTime ? `${t("common.last-updated-at")}: ${updateTime.toLocaleString(i18n.language)}` : undefined, + updatedAt: + updateTime && (!createTime || updateTime.getTime() !== createTime.getTime()) + ? `${t("common.last-updated-at")}: ${updateTime.toLocaleString(i18n.language)}` + : undefined, }; return ( @@ -122,13 +125,12 @@ const CreatorDisplay: React.FC = ({ creator, displayTime, t {creator.displayName || creator.username} - +
@@ -157,13 +159,12 @@ interface TimeDisplayProps { const TimeDisplay: React.FC = ({ displayTime, timeTooltip, onGotoDetail }) => ( - + ); diff --git a/web/src/components/SearchBar.tsx b/web/src/components/SearchBar.tsx index 5fdb0ebd..4a8684c1 100644 --- a/web/src/components/SearchBar.tsx +++ b/web/src/components/SearchBar.tsx @@ -1,7 +1,6 @@ import { SearchIcon } from "lucide-react"; import { useRef, useState } from "react"; import { useMemoFilterContext } from "@/contexts/MemoFilterContext"; -import { cn } from "@/lib/utils"; import { useTranslate } from "@/utils/i18n"; import MemoDisplaySettingMenu from "./MemoDisplaySettingMenu"; @@ -36,7 +35,7 @@ const SearchBar = () => {
{ const chip = ( {label} {value} diff --git a/web/src/components/Settings/MemoRelatedSettings.tsx b/web/src/components/Settings/MemoRelatedSettings.tsx index de38e8f4..4a39ac6f 100644 --- a/web/src/components/Settings/MemoRelatedSettings.tsx +++ b/web/src/components/Settings/MemoRelatedSettings.tsx @@ -127,14 +127,14 @@ const MemoRelatedSettings = () => { {memoRelatedSetting.reactions.map((reactionType) => ( {reactionType} - + ))}
diff --git a/web/src/components/StatisticsView/MonthNavigator.tsx b/web/src/components/StatisticsView/MonthNavigator.tsx index 60d8184a..6feb85ae 100644 --- a/web/src/components/StatisticsView/MonthNavigator.tsx +++ b/web/src/components/StatisticsView/MonthNavigator.tsx @@ -70,22 +70,10 @@ export const MonthNavigator = memo(({ visibleMonth, onMonthChange, activityStats diff --git a/web/src/components/map/LocationPicker.tsx b/web/src/components/map/LocationPicker.tsx index 6fd269e7..58c167e7 100644 --- a/web/src/components/map/LocationPicker.tsx +++ b/web/src/components/map/LocationPicker.tsx @@ -69,11 +69,9 @@ const GlassButton = ({ icon, onClick, ariaLabel, title }: GlassButtonProps) => { aria-label={ariaLabel} title={title} className={cn( - "h-8 w-8 flex items-center justify-center rounded-lg", - "cursor-pointer transition-all duration-200", + "inline-flex items-center justify-center h-8 w-8 rounded-lg", "border border-border/80 bg-background/88 text-foreground shadow-sm backdrop-blur-md", "hover:scale-105 hover:bg-background hover:shadow-md active:scale-95", - "focus:outline-none focus:ring-2 focus:ring-ring/60", )} > {icon} diff --git a/web/src/components/ui/README.md b/web/src/components/ui/README.md new file mode 100644 index 00000000..f8ed310c --- /dev/null +++ b/web/src/components/ui/README.md @@ -0,0 +1,50 @@ +# UI Kit (`components/ui`) + +shadcn/ui primitives ("new-york" style, zinc base, lucide icons, CSS variables). +This folder is the **single source of styling truth**. Read this before adding a +component or reaching for `className` on a kit component. + +## The one rule: use props, not `className` + +Consumers style kit components through **`variant` / `size` / `shape` props only** +— do **not** pass `className` to add colors, sizing, borders, or hover states. + +- Need a look that no prop provides, but it recurs? **Add a variant here.** +- Need layout/positioning (margins, absolute)? Put it on a **wrapper** element. +- The element is genuinely bespoke (data-driven background, glass/blur, a + contextual one-off)? Don't fight the kit — use a **raw HTML element** with its + own classes. It is not a kit component. + +Color comes from the semantic OKLCH tokens documented in +[`../../themes/COLOR_GUIDE.md`](../../themes/COLOR_GUIDE.md) (`--primary`, +`--muted-foreground`, `--success`, `--warning`, …). Never hardcode `gray-500` / +`amber-50` palette classes. + +## Variant catalog + +| Component | variant | size / shape | Notes | +| --- | --- | --- | --- | +| **Button** | default · destructive · outline · secondary · ghost · link | size: default · sm · lg · icon · **icon-sm** | `icon-sm` (`size-6`) is local — for dense/compact icon buttons. Auto-sizes unsized `svg` children to `size-4`. | +| **Badge** | default · secondary · destructive · outline · **warning** | shape: default · **pill** | `warning` + `shape` are local additions. `pill` = `rounded-full`. | +| **Tabs** | — | variant: **segmented** · **underline** | Local component (not upstream shadcn). Context-based `Tabs`/`TabsList`/`TabsTrigger`, no Radix. `underline` relies on the consumer's own divider. | +| **Dialog** | — | size: sm · default · lg · xl · 2xl · full | Local `size` variants + auto-focus prevention on open. | +| **Select** | — | size: xs · sm · default | Local `size` prop on the trigger. | +| **DropdownMenu** | item: default · destructive | — | Local destructive item variant + a sub-menu hover-delay hook. | + +Each cva component also exports its variant types, e.g. `ButtonVariant`, +`ButtonSize`, `BadgeVariant`, `BadgeShape`, `TabsVariant` — use these instead of +re-deriving `VariantProps`. + +## Layering (z-index tiers) + +Defined once as Tailwind tokens in `themes/default.css` (`--z-index-*`) and used +by the primitives — do not hardcode `z-[60]`-style literals: + +| Utility | Value | Used by | +| --- | --- | --- | +| `z-overlay` | 50 | Dialog / Sheet overlay + content | +| `z-dropdown` | 60 | Select / DropdownMenu / Popover content | +| `z-tooltip` | 70 | Tooltip content + arrow | + +A dropdown inside a dialog needs `z-dropdown` (already the default) so it renders +above the overlay; a tooltip sits above everything. diff --git a/web/src/components/ui/badge.tsx b/web/src/components/ui/badge.tsx index 2710bfef..19c199dd 100644 --- a/web/src/components/ui/badge.tsx +++ b/web/src/components/ui/badge.tsx @@ -12,10 +12,16 @@ const badgeVariants = cva( secondary: "border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90", destructive: "border-transparent bg-destructive text-destructive-foreground [a&]:hover:bg-destructive/90", outline: "text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground", + warning: "border-warning/40 bg-warning/10 text-warning", + }, + shape: { + default: "", + pill: "rounded-full", }, }, defaultVariants: { variant: "default", + shape: "default", }, }, ); @@ -23,12 +29,15 @@ const badgeVariants = cva( function Badge({ className, variant, + shape, asChild = false, ...props }: React.ComponentProps<"span"> & VariantProps & { asChild?: boolean }) { const Comp = asChild ? Slot : "span"; - return ; + return ; } export { Badge, badgeVariants }; +export type BadgeVariant = VariantProps["variant"]; +export type BadgeShape = VariantProps["shape"]; diff --git a/web/src/components/ui/button.tsx b/web/src/components/ui/button.tsx index 13fc5d82..112c65c7 100644 --- a/web/src/components/ui/button.tsx +++ b/web/src/components/ui/button.tsx @@ -20,6 +20,7 @@ const buttonVariants = cva( sm: "h-7 rounded-md gap-1 px-2 has-[>svg]:px-2", lg: "h-9 rounded-md px-4", icon: "size-8", + "icon-sm": "size-6", }, }, defaultVariants: { @@ -43,3 +44,5 @@ const Button = React.forwardRef< Button.displayName = "Button"; export { Button, buttonVariants }; +export type ButtonVariant = VariantProps["variant"]; +export type ButtonSize = VariantProps["size"]; diff --git a/web/src/components/ui/dialog.tsx b/web/src/components/ui/dialog.tsx index 9181909e..f44e4503 100644 --- a/web/src/components/ui/dialog.tsx +++ b/web/src/components/ui/dialog.tsx @@ -20,7 +20,7 @@ const DialogOverlay = React.forwardRef< ref={ref} data-slot="dialog-overlay" className={cn( - "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-foreground/50", + "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-overlay bg-foreground/50", className, )} {...props} @@ -29,7 +29,7 @@ const DialogOverlay = React.forwardRef< DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const dialogContentVariants = cva( - "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex flex-col translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200 max-h-[calc(100vh-2rem)] sm:max-h-[calc(100vh-3rem)] md:max-h-[calc(100vh-4rem)]", + "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-overlay flex flex-col translate-x-[-50%] translate-y-[-50%] rounded-lg border shadow-lg duration-200 max-h-[calc(100vh-2rem)] sm:max-h-[calc(100vh-3rem)] md:max-h-[calc(100vh-4rem)]", { variants: { size: { diff --git a/web/src/components/ui/dropdown-menu.tsx b/web/src/components/ui/dropdown-menu.tsx index 542cfeba..6d19f715 100644 --- a/web/src/components/ui/dropdown-menu.tsx +++ b/web/src/components/ui/dropdown-menu.tsx @@ -31,7 +31,7 @@ const DropdownMenuContent = React.forwardRef< data-slot="dropdown-menu-content" sideOffset={sideOffset} className={cn( - "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[60] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md", + "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-dropdown max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md", className, )} {...props} @@ -188,7 +188,7 @@ function DropdownMenuSubContent({ className, ...props }: React.ComponentProps void; + variant: TabsVariant; +} + +const TabsContext = createContext(null); + +const useTabsContext = () => { + const context = useContext(TabsContext); + if (!context) { + throw new Error("Tabs.* components must be rendered within "); + } + return context; +}; + +const tabsListVariants = cva("flex flex-row", { + variants: { + variant: { + segmented: "gap-1", + underline: "gap-1", + }, + }, + defaultVariants: { variant: "segmented" }, +}); + +const tabsTriggerVariants = cva( + "inline-flex items-center justify-center gap-1.5 whitespace-nowrap text-sm font-medium transition-colors cursor-pointer disabled:pointer-events-none disabled:opacity-50 [&_svg]:shrink-0", + { + variants: { + variant: { + segmented: "rounded-md px-3 py-1.5", + underline: "rounded-t-lg rounded-b-none border-b-2 px-3 py-2", + }, + active: { true: "", false: "" }, + }, + compoundVariants: [ + { variant: "segmented", active: true, className: "bg-background text-foreground shadow-sm" }, + { variant: "segmented", active: false, className: "text-muted-foreground hover:bg-background/50 hover:text-foreground" }, + { variant: "underline", active: true, className: "border-primary bg-primary/5 text-primary" }, + { + variant: "underline", + active: false, + className: "border-transparent text-muted-foreground hover:bg-muted/50 hover:text-foreground", + }, + ], + defaultVariants: { variant: "segmented", active: false }, + }, +); + +interface TabsProps extends Omit, "onChange"> { + value: string; + onValueChange: (value: string) => void; + variant?: TabsVariant; +} + +function Tabs({ value, onValueChange, variant = "segmented", children, ...props }: TabsProps) { + return ( + +
{children}
+
+ ); +} + +function TabsList({ className, ...props }: React.ComponentProps<"div">) { + const { variant } = useTabsContext(); + return
; +} + +interface TabsTriggerProps extends Omit, "value"> { + value: string; +} + +function TabsTrigger({ value, className, onClick, ...props }: TabsTriggerProps) { + const { value: activeValue, onValueChange, variant } = useTabsContext(); + const active = activeValue === value; + return ( + - - -
+ setFilter(value as typeof filter)} variant="segmented"> + + + {t("common.all")} ({allNotifications.length}) + + + + {t("inbox.unread")} ({unreadCount}) + + + + {t("common.archived")} ({archivedCount}) + + + {/* Notifications List */} diff --git a/web/src/pages/Shortcuts.tsx b/web/src/pages/Shortcuts.tsx index 5e9850eb..bb4c37f6 100644 --- a/web/src/pages/Shortcuts.tsx +++ b/web/src/pages/Shortcuts.tsx @@ -153,10 +153,9 @@ const ShortcutGuide = ({ onUseExample }: ShortcutGuideProps) => { {shortcutExamples.map((example) => { const Icon = example.icon; return ( - + ); })} diff --git a/web/src/pages/UserProfile.tsx b/web/src/pages/UserProfile.tsx index a04fe8c0..8f61d782 100644 --- a/web/src/pages/UserProfile.tsx +++ b/web/src/pages/UserProfile.tsx @@ -1,5 +1,5 @@ import copy from "copy-to-clipboard"; -import { ExternalLinkIcon, LayoutListIcon, type LucideIcon, MapIcon } from "lucide-react"; +import { ExternalLinkIcon, LayoutListIcon, MapIcon } from "lucide-react"; import { lazy, Suspense } from "react"; import { toast } from "react-hot-toast"; import { useParams, useSearchParams } from "react-router-dom"; @@ -7,9 +7,9 @@ import MemoView from "@/components/MemoView"; import PagedMemoList from "@/components/PagedMemoList"; import UserAvatar from "@/components/UserAvatar"; import { Button } from "@/components/ui/button"; +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { useMemoFilters, useMemoSorting } from "@/hooks"; import { useUser } from "@/hooks/useUserQueries"; -import { cn } from "@/lib/utils"; import { State } from "@/types/proto/api/v1/common_pb"; import { Memo } from "@/types/proto/api/v1/memo_service_pb"; import { useTranslate } from "@/utils/i18n"; @@ -18,32 +18,6 @@ type TabView = "memos" | "map"; const UserMemoMap = lazy(() => import("@/components/UserMemoMap")); -const TabButton = ({ - icon: Icon, - label, - isActive, - onClick, -}: { - icon: LucideIcon; - label: string; - isActive: boolean; - onClick: () => void; -}) => ( - -); - interface User { name: string; username: string; @@ -117,13 +91,18 @@ const UserProfile = () => {
- toggleTab("memos")} - /> - toggleTab("map")} /> + toggleTab(value as TabView)} variant="underline"> + + + + {t("common.memos")} + + + + {t("common.map")} + + +
diff --git a/web/src/themes/COLOR_GUIDE.md b/web/src/themes/COLOR_GUIDE.md index 4197c858..aa0fdf9d 100644 --- a/web/src/themes/COLOR_GUIDE.md +++ b/web/src/themes/COLOR_GUIDE.md @@ -92,17 +92,25 @@ The color system supports both light and dark themes automatically through CSS c ### ⚠️ Feedback Colors -| Variable | Light Theme | Dark Theme | Usage | -| -------------------------- | ----------- | ---------- | ------------------------------- | -| `--destructive` | Very dark | Red | Error states, dangerous actions | -| `--destructive-foreground` | White | White | Text on destructive backgrounds | +| Variable | Light Theme | Dark Theme | Usage | +| -------------------------- | ----------- | ------------- | ---------------------------------- | +| `--destructive` | Very dark | Red | Error states, dangerous actions | +| `--destructive-foreground` | White | White | Text on destructive backgrounds | +| `--success` | Green | Brighter green| Confirmation states (copied, saved)| +| `--success-foreground` | Near white | Near black | Text on success backgrounds | +| `--warning` | Amber | Brighter amber| Caution states (unused, deprecated)| +| `--warning-foreground` | Dark | Dark | Text on warning backgrounds | **When to use:** -- Error messages -- Delete buttons -- Warning alerts -- Validation failures +- Error messages, delete buttons, validation failures → `--destructive` +- Success confirmations (e.g. "copied ✓", saved) → `--success` +- Non-critical caution (e.g. unused attachments) → `--warning` + +For tinted treatments (badges, panels), pair the token with an opacity modifier +the same way `--destructive` is used, e.g. `border-warning/30 bg-warning/10 text-warning`. +This auto-adapts across themes — never hardcode `amber-*` / `green-*` palette classes +or add manual `dark:` overrides for feedback states. ### 📊 Data Visualization @@ -260,39 +268,27 @@ To ensure proper contrast and accessibility: ## Z-Index Hierarchy -The application uses a structured z-index hierarchy to ensure proper layering of UI components: +The layering tiers are defined once as Tailwind tokens in `default.css` +(`--z-index-overlay/dropdown/tooltip`) and consumed via named utilities — do not +hardcode `z-[60]`-style literals. -| Component Type | Z-Index | Usage | -| ----------------- | -------- | ------------------------------------- | -| **Base Content** | `z-0` | Normal page content | -| **Overlays** | `z-50` | Dialog/Sheet backgrounds | -| **Modal Content** | `z-50` | Dialog/Sheet content | -| **Dropdowns** | `z-[60]` | Select, DropdownMenu, Popover content | -| **Tooltips** | `z-[70]` | Tooltip content (highest priority) | +| Component Type | Utility | Value | Usage | +| ----------------- | ------------- | ----- | ------------------------------------- | +| **Base Content** | `z-0` | 0 | Normal page content | +| **Overlays** | `z-overlay` | 50 | Dialog/Sheet backgrounds | +| **Modal Content** | `z-overlay` | 50 | Dialog/Sheet content | +| **Dropdowns** | `z-dropdown` | 60 | Select, DropdownMenu, Popover content | +| **Tooltips** | `z-tooltip` | 70 | Tooltip content (highest priority) | ### Rules -1. **Dialog/Sheet**: Use `z-50` for both overlay and content -2. **Interactive Elements**: Use `z-[60]` for dropdowns inside dialogs -3. **Tooltips**: Use `z-[70]` to appear above all other elements +1. **Dialog/Sheet**: Use `z-overlay` for both overlay and content +2. **Interactive Elements**: Use `z-dropdown` for dropdowns inside dialogs +3. **Tooltips**: Use `z-tooltip` to appear above all other elements 4. **Always test**: Ensure Select/DropdownMenu works inside Dialog/Sheet -### Example - -```tsx -// ✅ Correct: Select inside Dialog will appear above dialog content - - - - - -``` +These are already the defaults baked into the `ui/` primitives, so a `Select` +inside a `Dialog` renders above the overlay without any extra `z-*` class. --- diff --git a/web/src/themes/default-dark.css b/web/src/themes/default-dark.css index fa700550..b9c44990 100644 --- a/web/src/themes/default-dark.css +++ b/web/src/themes/default-dark.css @@ -30,6 +30,12 @@ --destructive: oklch(0.64 0.18 24); --destructive-foreground: oklch(0.98 0.004 255); + /* Feedback - success (green) and warning (amber), tuned brighter for dark surfaces */ + --success: oklch(0.7 0.15 155); + --success-foreground: oklch(0.2 0.03 155); + --warning: oklch(0.78 0.14 75); + --warning-foreground: oklch(0.25 0.03 75); + /* Borders - --border for layout dividers, --input for form field borders */ --border: oklch(0.38 0.01 255); --input: oklch(0.42 0.011 255); diff --git a/web/src/themes/default.css b/web/src/themes/default.css index 670d2517..3ec5ecee 100644 --- a/web/src/themes/default.css +++ b/web/src/themes/default.css @@ -15,6 +15,10 @@ --accent-foreground: oklch(0.2671 0.0196 98.939); --destructive: oklch(0.5 0.12 25); --destructive-foreground: oklch(1 0 0); + --success: oklch(0.55 0.13 150); + --success-foreground: oklch(0.98 0.01 150); + --warning: oklch(0.62 0.12 70); + --warning-foreground: oklch(0.25 0.03 75); --border: oklch(0.8847 0.0069 97.3627); --input: oklch(0.7621 0.0156 98.3528); --ring: oklch(0.45 0.08 250); @@ -56,6 +60,10 @@ --color-accent-foreground: var(--accent-foreground); --color-destructive: var(--destructive); --color-destructive-foreground: var(--destructive-foreground); + --color-success: var(--success); + --color-success-foreground: var(--success-foreground); + --color-warning: var(--warning); + --color-warning-foreground: var(--warning-foreground); --color-border: var(--border); --color-input: var(--input); --color-ring: var(--ring); @@ -80,4 +88,10 @@ --shadow-lg: var(--shadow-lg); --shadow-xl: var(--shadow-xl); --shadow-2xl: var(--shadow-2xl); + + /* Layering tiers — keep overlays/dropdowns/tooltips stacked consistently. + Used by the ui/ primitives via z-overlay / z-dropdown / z-tooltip. */ + --z-index-overlay: 50; + --z-index-dropdown: 60; + --z-index-tooltip: 70; } diff --git a/web/src/themes/paper.css b/web/src/themes/paper.css index b57f97e4..291c9675 100644 --- a/web/src/themes/paper.css +++ b/web/src/themes/paper.css @@ -15,6 +15,10 @@ --accent-foreground: oklch(0.25 0.02 65); --destructive: oklch(0.48 0.15 25); --destructive-foreground: oklch(0.98 0.008 80); + --success: oklch(0.55 0.13 150); + --success-foreground: oklch(0.98 0.01 150); + --warning: oklch(0.6 0.12 65); + --warning-foreground: oklch(0.25 0.03 70); --border: oklch(0.85 0.025 72); --input: oklch(0.8 0.03 75); --ring: oklch(0.45 0.08 45);