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 <tukon479@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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 = ({
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-menu select-none items-center rounded-[5px] px-2.5 py-1.5 outline-none focus:bg-theme-selection-active focus:text-theme-selection-foreground data-[state=open]:bg-theme-selection-active data-[state=open]:text-theme-selection-foreground",
|
||||
"flex cursor-menu select-none items-center rounded-[5px] px-2.5 py-1.5 outline-none focus:bg-accent/30 data-[state=open]:bg-accent/30",
|
||||
inset && "pl-8",
|
||||
"center gap-2",
|
||||
className,
|
||||
@@ -75,15 +88,26 @@ const DropdownMenuSubContent = ({
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"bg-material-medium text-body text-text backdrop-blur-background",
|
||||
"text-body text-text",
|
||||
"min-w-32 overflow-hidden",
|
||||
"rounded-[6px] border p-1",
|
||||
"shadow-context-menu",
|
||||
"rounded-[6px] p-1",
|
||||
"backdrop-blur-2xl",
|
||||
"z-[61]",
|
||||
"relative",
|
||||
"dark:border dark:border-border/50",
|
||||
className,
|
||||
)}
|
||||
style={styles.content}
|
||||
{...props}
|
||||
/>
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-[6px]"
|
||||
style={styles.innerGlow}
|
||||
/>
|
||||
{/* Content wrapper */}
|
||||
<div className="relative">{props.children}</div>
|
||||
</DropdownMenuPrimitive.SubContent>
|
||||
</RootPortal>
|
||||
)
|
||||
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 */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-[6px]"
|
||||
style={styles.innerGlow}
|
||||
/>
|
||||
{/* Content wrapper */}
|
||||
<div className="relative">{props.children}</div>
|
||||
</DropdownMenuPrimitive.Content>
|
||||
</RootPortal>
|
||||
)
|
||||
}
|
||||
@@ -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<React.ElementRef<typeof DropdownMenuPrimitive.Item> | null> }) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-menu select-none items-center rounded-[5px] px-2.5 py-1 outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"focus-within:outline-transparent",
|
||||
highlightColor === "accent"
|
||||
? "focus:bg-theme-selection-active focus:text-theme-selection-foreground data-[highlighted]:bg-theme-selection-hover data-[highlighted]:text-theme-selection-foreground"
|
||||
: "focus:bg-theme-item-active data-[highlighted]:bg-theme-item-hover",
|
||||
|
||||
"relative flex cursor-menu select-none items-center rounded-[5px] px-2.5 py-1 outline-none focus:bg-accent/30 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"focus-within:outline-transparent data-[highlighted]:bg-mix-background/accent-5/1",
|
||||
"h-[28px]",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
@@ -187,7 +219,7 @@ const DropdownMenuCheckboxItem = ({
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-checkbox select-none items-center rounded-[5px] px-8 py-1.5 outline-none focus:bg-theme-selection-active focus:text-theme-selection-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"relative flex cursor-checkbox select-none items-center rounded-[5px] px-8 py-1.5 outline-none focus:bg-accent/30 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"focus-within:outline-transparent",
|
||||
"h-[28px]",
|
||||
className,
|
||||
|
||||
@@ -338,15 +338,20 @@ export const ModalInternal = memo(function Modal({
|
||||
|
||||
<m.div
|
||||
ref={modalElementRef}
|
||||
style={modalStyle}
|
||||
style={{
|
||||
...modalStyle,
|
||||
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)",
|
||||
}}
|
||||
{...modalMontionConfig}
|
||||
animate={animateController}
|
||||
className={cn(
|
||||
"relative flex flex-col overflow-hidden rounded-xl px-2 pt-1",
|
||||
"bg-background",
|
||||
"shadow-modal [transform-style:preserve-3d]",
|
||||
"backdrop-blur-2xl [transform-style:preserve-3d]",
|
||||
max ? "h-[90vh] w-[90vw]" : "max-h-[90vh]",
|
||||
"border border-border",
|
||||
"dark:border dark:border-border/50",
|
||||
modalClassName,
|
||||
)}
|
||||
tabIndex={-1}
|
||||
@@ -364,14 +369,22 @@ export const ModalInternal = memo(function Modal({
|
||||
cursor: "grabbing",
|
||||
}}
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-xl"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to bottom right, hsl(var(--fo-a) / 0.05), transparent, hsl(var(--fo-a) / 0.05))",
|
||||
}}
|
||||
/>
|
||||
<ResizeSwitch
|
||||
// enable={resizableOnly("bottomRight")}
|
||||
onResizeStart={handleResizeStart}
|
||||
onResizeStop={handleResizeStop}
|
||||
defaultSize={resizeDefaultSize}
|
||||
className="flex grow flex-col"
|
||||
className="relative z-10 flex grow flex-col"
|
||||
>
|
||||
<div className={"relative z-10 flex flex-col bg-background"}>
|
||||
<div className={"relative flex flex-col"}>
|
||||
<div className={"flex items-center"}>
|
||||
<Dialog.Title
|
||||
className="flex w-0 max-w-full grow items-center gap-2 px-2 pb-1 pt-2 text-base font-medium text-text"
|
||||
|
||||
@@ -42,7 +42,7 @@ export const FeedClaimModalContent: FC<{
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="center h-32 lg:w-[650px]">
|
||||
<div className="center h-32 w-[650px]">
|
||||
<LoadingCircle size="large" />
|
||||
</div>
|
||||
)
|
||||
@@ -53,7 +53,7 @@ export const FeedClaimModalContent: FC<{
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto w-full max-w-[650px]">
|
||||
<div className="mx-auto w-[650px]">
|
||||
<Card className="mb-2">
|
||||
<CardHeader>
|
||||
<FollowSummary feed={feed} />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = ({
|
||||
<ContextMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"cursor-menu focus:bg-theme-selection-active focus:text-theme-selection-foreground data-[state=open]:bg-theme-selection-active data-[state=open]:text-theme-selection-foreground flex select-none items-center rounded-[5px] px-2.5 py-1.5 outline-none",
|
||||
"cursor-menu focus:bg-accent/30 data-[state=open]:bg-accent/30 flex select-none items-center rounded-[5px] px-2.5 py-1.5 outline-none",
|
||||
inset && "pl-8",
|
||||
"center gap-2",
|
||||
className,
|
||||
@@ -48,15 +61,26 @@ const ContextMenuSubContent = ({
|
||||
<ContextMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"bg-material-medium backdrop-blur-background text-text text-body",
|
||||
"text-text text-body",
|
||||
"min-w-32 overflow-hidden",
|
||||
"rounded-[6px] border p-1",
|
||||
"shadow-context-menu",
|
||||
"rounded-[6px] p-1",
|
||||
"backdrop-blur-2xl",
|
||||
"z-[61]",
|
||||
"relative",
|
||||
"dark:border-border/50 dark:border",
|
||||
className,
|
||||
)}
|
||||
style={styles.content}
|
||||
{...props}
|
||||
/>
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-[6px]"
|
||||
style={styles.innerGlow}
|
||||
/>
|
||||
{/* Content wrapper */}
|
||||
<div className="relative">{props.children}</div>
|
||||
</ContextMenuPrimitive.SubContent>
|
||||
</RootPortal>
|
||||
)
|
||||
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
||||
@@ -72,12 +96,24 @@ const ContextMenuContent = ({
|
||||
<ContextMenuPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"bg-material-medium backdrop-blur-background text-text shadow-context-menu z-[60] min-w-32 overflow-hidden rounded-[6px] border p-1",
|
||||
"text-text z-[60] min-w-32 overflow-hidden rounded-[6px] p-1",
|
||||
"backdrop-blur-2xl",
|
||||
"motion-scale-in-75 motion-duration-150 text-body lg:animate-none",
|
||||
"relative",
|
||||
"dark:border-border/50 dark:border",
|
||||
className,
|
||||
)}
|
||||
style={styles.content}
|
||||
{...props}
|
||||
/>
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-[6px]"
|
||||
style={styles.innerGlow}
|
||||
/>
|
||||
{/* Content wrapper */}
|
||||
<div className="relative">{props.children}</div>
|
||||
</ContextMenuPrimitive.Content>
|
||||
</RootPortal>
|
||||
)
|
||||
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
||||
@@ -93,8 +129,8 @@ const ContextMenuItem = ({
|
||||
<ContextMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"cursor-menu focus:bg-theme-selection-active focus:text-theme-selection-foreground relative flex select-none items-center rounded-[5px] px-2.5 py-1 outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"data-[highlighted]:bg-theme-selection-hover focus-within:outline-transparent",
|
||||
"cursor-menu focus:bg-accent/30 relative flex select-none items-center rounded-[5px] px-2.5 py-1 outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"data-[highlighted]:bg-mix-background/accent-5/1 focus-within:outline-transparent",
|
||||
"h-[28px]",
|
||||
inset && "pl-8",
|
||||
className,
|
||||
@@ -116,7 +152,7 @@ const ContextMenuCheckboxItem = ({
|
||||
<ContextMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"cursor-checkbox focus:bg-theme-selection-active focus:text-theme-selection-foreground relative flex select-none items-center rounded-[5px] px-8 py-1.5 outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"cursor-checkbox focus:bg-accent/30 relative flex select-none items-center rounded-[5px] px-8 py-1.5 outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
"focus-within:outline-transparent",
|
||||
"h-[28px]",
|
||||
className,
|
||||
|
||||
@@ -345,9 +345,8 @@ export const Kbd: FC<{
|
||||
const KbdElement = (
|
||||
<kbd
|
||||
className={cn(
|
||||
"kbd text-text box-border h-5 space-x-1 font-sans text-[0.7rem] tabular-nums transition-[border] duration-200",
|
||||
|
||||
wrapButton && (isKeyPressed ? "" : "border-b-2 hover:border-b"),
|
||||
"kbd text-text box-border h-5 space-x-1 font-sans text-[0.7rem] tabular-nums transition-all duration-200",
|
||||
wrapButton && isKeyPressed && "scale-95 opacity-80",
|
||||
className,
|
||||
)}
|
||||
{...(abbr && { title: abbr })}
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
||||
import { m } from "motion/react"
|
||||
import * as React from "react"
|
||||
|
||||
import { tooltipStyle } from "./styles"
|
||||
import { tooltipStyle, tooltipStyles } from "./styles"
|
||||
|
||||
const TooltipProvider = TooltipPrimitive.Provider
|
||||
const TooltipRoot = TooltipPrimitive.Root
|
||||
@@ -36,10 +36,19 @@ const TooltipContent = ({
|
||||
initial={{ opacity: 0.82, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
transition={Spring.snappy(0.1)}
|
||||
style={tooltipStyles.container}
|
||||
>
|
||||
{/* Inner glow layer */}
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 rounded-lg"
|
||||
style={tooltipStyles.innerGlow}
|
||||
/>
|
||||
{/* https://github.com/radix-ui/primitives/discussions/868 */}
|
||||
<TooltipPrimitive.Arrow className="z-50 fill-white [clip-path:inset(0_-10px_-10px_-10px)] dark:fill-neutral-950 dark:drop-shadow-[0_0_1px_theme(colors.white/0.5)]" />
|
||||
{props.children}
|
||||
<TooltipPrimitive.Arrow
|
||||
className="z-50 [clip-path:inset(0_-10px_-10px_-10px)]"
|
||||
style={tooltipStyles.arrow}
|
||||
/>
|
||||
<div className="relative">{props.children}</div>
|
||||
</m.div>
|
||||
</TooltipPrimitive.Content>
|
||||
)
|
||||
|
||||
@@ -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)",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user