From 92f3bf7ff4401fabd47d9d7f6c7ad5d136cc4fe8 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 18 Nov 2025 17:16:31 +0800 Subject: [PATCH] refactor: enhance UI components with improved styling and layout - Introduced gradient backgrounds and box shadows for dropdown menus and context menus for a more modern appearance. - Updated modal styles to include backdrop blur and inner glow effects for better visual depth. - Adjusted component layouts for consistency and improved user experience across modals and context menus. - Refined keyboard component styles for better interaction feedback. Signed-off-by: Innei --- AGENTS.md | 1 + .../ui/dropdown-menu/dropdown-menu.tsx | 64 ++++++++++++++----- .../src/components/ui/modal/stacked/modal.tsx | 25 ++++++-- .../src/modules/claim/feed-claim-modal.tsx | 4 +- .../configs/tailwindcss/tailwind-extend.css | 21 ++++-- .../src/ui/context-menu/context-menu.tsx | 56 +++++++++++++--- .../internal/components/src/ui/kbd/Kbd.tsx | 5 +- .../components/src/ui/tooltip/index.tsx | 15 ++++- .../components/src/ui/tooltip/styles.ts | 30 +++++++-- 9 files changed, 173 insertions(+), 48 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ea4602fea..3df25f522 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,6 +58,7 @@ pnpm run test - Prefer CSS transitions/animations for simple UI interactions. Use JS-driven motion only when necessary to avoid frame drops. - Imports: use `pathe` instead of `node:path` for cross‑platform paths. - Organize shared, reusable UI in `packages/internal/components`; app-specific UI stays in its app. +- **Style extraction**: Avoid inline styles in JSX. Extract complex styles (especially those using CSS variables, gradients, or multiple properties) to external style objects similar to React Native's `StyleSheet.create`. Place style objects in a `styles.ts` file alongside the component, using `CSSProperties` type for type safety. ## Team preferences diff --git a/apps/desktop/layer/renderer/src/components/ui/dropdown-menu/dropdown-menu.tsx b/apps/desktop/layer/renderer/src/components/ui/dropdown-menu/dropdown-menu.tsx index 5d949b7c8..94b0cc244 100644 --- a/apps/desktop/layer/renderer/src/components/ui/dropdown-menu/dropdown-menu.tsx +++ b/apps/desktop/layer/renderer/src/components/ui/dropdown-menu/dropdown-menu.tsx @@ -9,6 +9,19 @@ import * as React from "react" import { HotkeyScope } from "~/constants" +const styles = { + content: { + backgroundImage: + "linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))", + boxShadow: + "0 6px 20px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.04), 0 4px 16px hsl(var(--fo-a) / 0.06), 0 2px 8px hsl(var(--fo-a) / 0.04), 0 1px 3px rgba(0, 0, 0, 0.03)", + } as React.CSSProperties, + innerGlow: { + background: + "linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))", + } as React.CSSProperties, +} + const DropdownMenu: typeof DropdownMenuPrimitive.Root = (props) => { const setGlobalFocusableScope = useSetGlobalFocusableScope() return ( @@ -50,7 +63,7 @@ const DropdownMenuSubTrigger = ({ + > + {/* Inner glow layer */} +
+ {/* Content wrapper */} +
{props.children}
+ ) DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName @@ -102,12 +126,24 @@ const DropdownMenuContent = ({ ref={ref} sideOffset={sideOffset} className={cn( - "shadow-context-menu z-[60] min-w-32 overflow-hidden rounded-[6px] border bg-material-medium p-1 text-text backdrop-blur-background", + "z-[60] min-w-32 overflow-hidden rounded-[6px] p-1 text-text", + "backdrop-blur-2xl", "text-body motion-scale-in-75 motion-duration-150 lg:animate-none", + "relative", + "dark:border dark:border-border/50", className, )} + style={styles.content} {...props} - /> + > + {/* Inner glow layer */} +
+ {/* Content wrapper */} +
{props.children}
+ ) } @@ -119,7 +155,7 @@ const DropdownMenuItem = ({ inset, icon, active, - highlightColor = "accent", + shortcut, checked, ...props @@ -127,19 +163,15 @@ const DropdownMenuItem = ({ inset?: boolean icon?: React.ReactNode | ((props?: { isActive?: boolean }) => React.ReactNode) active?: boolean - highlightColor?: "accent" | "gray" + shortcut?: string checked?: boolean } & { ref?: React.Ref | null> }) => ( + {/* Inner glow layer */} +
-
+
+
) @@ -53,7 +53,7 @@ export const FeedClaimModalContent: FC<{ } return ( -
+
diff --git a/packages/configs/tailwindcss/tailwind-extend.css b/packages/configs/tailwindcss/tailwind-extend.css index 83f7df217..d5187f095 100644 --- a/packages/configs/tailwindcss/tailwind-extend.css +++ b/packages/configs/tailwindcss/tailwind-extend.css @@ -87,15 +87,28 @@ /* KBD */ @layer components { .kbd { - background-color: oklch(0.984625 0.001706 247.839); - /* @apply shadow-[0px_2px_0px_0px_rgba(255,255,255,0.5)] dark:shadow-[0px_2px_0px_0px_rgba(0,0,0,0.6)]; */ + background-image: linear-gradient( + to bottom right, + rgba(var(--color-background) / 0.95), + rgba(var(--color-background) / 0.92) + ); + backdrop-filter: blur(12px); @apply rounded-[4px] px-1 text-[0.5em]; - @apply border border-zinc-300 font-mono dark:border-neutral-700; @apply inline-flex items-center justify-center; + box-shadow: + 0 2px 8px rgba(0, 0, 0, 0.06), + 0 1px 4px rgba(0, 0, 0, 0.04), + 0 1px 6px hsl(var(--fo-a) / 0.04), + 0 0 2px rgba(0, 0, 0, 0.02); } [data-theme="dark"] .kbd { - background-color: oklch(0.232607 0.013807 253.101); + border: 1px solid hsl(var(--border) / 0.5); + box-shadow: + 0 2px 8px rgba(0, 0, 0, 0.12), + 0 1px 4px rgba(0, 0, 0, 0.08), + 0 1px 6px hsl(var(--fo-a) / 0.06), + 0 0 2px rgba(0, 0, 0, 0.04); } } diff --git a/packages/internal/components/src/ui/context-menu/context-menu.tsx b/packages/internal/components/src/ui/context-menu/context-menu.tsx index 0747bdbb9..fc6573dae 100644 --- a/packages/internal/components/src/ui/context-menu/context-menu.tsx +++ b/packages/internal/components/src/ui/context-menu/context-menu.tsx @@ -5,6 +5,19 @@ import * as React from "react" import { Divider } from "../divider/Divider.js" import { RootPortal } from "../portal/index.jsx" +const styles = { + content: { + backgroundImage: + "linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))", + boxShadow: + "0 6px 20px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.04), 0 4px 16px hsl(var(--fo-a) / 0.06), 0 2px 8px hsl(var(--fo-a) / 0.04), 0 1px 3px rgba(0, 0, 0, 0.03)", + } as React.CSSProperties, + innerGlow: { + background: + "linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))", + } as React.CSSProperties, +} + const ContextMenu = ContextMenuPrimitive.Root const ContextMenuTrigger = ContextMenuPrimitive.Trigger const ContextMenuGroup = ContextMenuPrimitive.Group @@ -23,7 +36,7 @@ const ContextMenuSubTrigger = ({ + > + {/* Inner glow layer */} +
+ {/* Content wrapper */} +
{props.children}
+ ) ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName @@ -72,12 +96,24 @@ const ContextMenuContent = ({ + > + {/* Inner glow layer */} +
+ {/* Content wrapper */} +
{props.children}
+ ) ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName @@ -93,8 +129,8 @@ const ContextMenuItem = ({ + {/* Inner glow layer */} +
{/* https://github.com/radix-ui/primitives/discussions/868 */} - - {props.children} + +
{props.children}
) diff --git a/packages/internal/components/src/ui/tooltip/styles.ts b/packages/internal/components/src/ui/tooltip/styles.ts index 83d22f751..f2e8d05c4 100644 --- a/packages/internal/components/src/ui/tooltip/styles.ts +++ b/packages/internal/components/src/ui/tooltip/styles.ts @@ -1,10 +1,32 @@ +import type { CSSProperties } from "react" + export const tooltipStyle = { content: [ - "relative z-[101] bg-white px-2 py-1 text-text dark:bg-neutral-950", + "relative z-[101] px-2 py-1 text-text", "data-[state=closed]:animate-out data-[state=closed]:fade-out-0", - "rounded-lg text-sm", + "rounded-lg text-sm backdrop-blur-2xl", "max-w-[75ch] select-text", - "drop-shadow data-[side=top]:shadow-tooltip-bottom data-[side=bottom]:shadow-tooltip-top", - tw`dark:drop-shadow-[0_0_1px_theme(colors.white/0.5)]`, + "border border-solid", ], } + +export const tooltipStyles: { + container: CSSProperties + innerGlow: CSSProperties + arrow: CSSProperties +} = { + container: { + backgroundImage: + "linear-gradient(to bottom right, rgba(var(--color-background) / 0.98), rgba(var(--color-background) / 0.95))", + borderColor: "hsl(var(--fo-a) / 0.2)", + boxShadow: + "0 4px 16px hsl(var(--fo-a) / 0.08), 0 2px 8px hsl(var(--fo-a) / 0.06), 0 1px 4px rgba(0, 0, 0, 0.1)", + }, + innerGlow: { + background: + "linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))", + }, + arrow: { + fill: "hsl(var(--fo-a) / 0.2)", + }, +}