refactor(ui): enhance component className structure for better readability and maintainability
This commit is contained in:
parent
9cb378f197
commit
573c3053b6
9 changed files with 553 additions and 24 deletions
|
@ -42,7 +42,38 @@ function DropdownMenuContent({
|
|||
data-slot='dropdown-menu-content'
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
'bg-popover text-text 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-50 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',
|
||||
/* Text */
|
||||
'text-text',
|
||||
/* Background */
|
||||
'bg-popover',
|
||||
/* Border */
|
||||
'border rounded-md',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'',
|
||||
/* Shadow */
|
||||
'shadow-md',
|
||||
/* Opacity */
|
||||
'',
|
||||
/* Scaling */
|
||||
'max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem]',
|
||||
/* Spacing */
|
||||
'p-1',
|
||||
/* Alignment */
|
||||
'z-50 origin-(--radix-dropdown-menu-content-transform-origin)',
|
||||
/* Miscellaneous */
|
||||
'overflow-x-hidden overflow-y-auto',
|
||||
'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',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
@ -74,7 +105,38 @@ function DropdownMenuItem({
|
|||
data-inset={inset}
|
||||
data-variant={variant}
|
||||
className={cn(
|
||||
"focus:bg-popover-hover focus:text-text data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
/* Text */
|
||||
'text-sm focus:text-text data-[variant=destructive]:text-destructive',
|
||||
'data-[variant=destructive]:focus:text-destructive',
|
||||
'data-[variant=destructive]:*:[svg]:!text-destructive',
|
||||
"[&_svg:not([class*='text-'])]:text-muted-foreground",
|
||||
/* Background */
|
||||
'focus:bg-popover-hover data-[variant=destructive]:focus:bg-destructive/10',
|
||||
'dark:data-[variant=destructive]:focus:bg-destructive/20',
|
||||
/* Border */
|
||||
'rounded-sm',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'cursor-default data-[disabled]:pointer-events-none data-[inset]:pl-8',
|
||||
'[&_svg]:pointer-events-none',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'outline-hidden',
|
||||
/* Shadow */
|
||||
'',
|
||||
/* Opacity */
|
||||
'data-[disabled]:opacity-50',
|
||||
/* Scaling */
|
||||
" [&_svg:not([class*='size-'])]:size-4",
|
||||
/* Spacing */
|
||||
'gap-2 px-2 py-1.5',
|
||||
/* Alignment */
|
||||
'relative flex items-center [&_svg]:shrink-0',
|
||||
/* Miscellaneous */
|
||||
'select-none',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
@ -92,7 +154,35 @@ function DropdownMenuCheckboxItem({
|
|||
<DropdownMenuPrimitive.CheckboxItem
|
||||
data-slot='dropdown-menu-checkbox-item'
|
||||
className={cn(
|
||||
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
' ',
|
||||
/* Text */
|
||||
'focus:text-accent-foreground text-sm',
|
||||
/* Background */
|
||||
'focus:bg-accent',
|
||||
/* Border */
|
||||
'rounded-sm',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'cursor-default select-none data-[disabled]:pointer-events-none',
|
||||
'[&_svg]:pointer-events-none',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'outline-hidden',
|
||||
/* Shadow */
|
||||
'',
|
||||
/* Opacity */
|
||||
'data-[disabled]:opacity-50',
|
||||
/* Scaling */
|
||||
"[&_svg:not([class*='size-'])]:size-4",
|
||||
/* Spacing */
|
||||
'gap-2 py-1.5 pr-2 pl-8',
|
||||
/* Alignment */
|
||||
'relative flex items-center [&_svg]:shrink-0',
|
||||
/* Miscellaneous */
|
||||
'',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
|
@ -128,7 +218,33 @@ function DropdownMenuRadioItem({
|
|||
<DropdownMenuPrimitive.RadioItem
|
||||
data-slot='dropdown-menu-radio-item'
|
||||
className={cn(
|
||||
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
/* Text */
|
||||
'focus:text-accent-foreground text-sm',
|
||||
/* Background */
|
||||
'focus:bg-accent',
|
||||
/* Border */
|
||||
'rounded-sm',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'cursor-default select-none data-[disabled]:pointer-events-none [&_svg]:pointer-events-none',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'outline-hidden',
|
||||
/* Shadow */
|
||||
'',
|
||||
/* Opacity */
|
||||
'data-[disabled]:opacity-50',
|
||||
/* Scaling */
|
||||
"[&_svg:not([class*='size-'])]:size-4",
|
||||
/* Spacing */
|
||||
'gap-2 py-1.5 pr-2 pl-8',
|
||||
/* Alignment */
|
||||
'relative flex items-center [&_svg]:shrink-0',
|
||||
/* Miscellaneous */
|
||||
'',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
@ -211,7 +327,34 @@ function DropdownMenuSubTrigger({
|
|||
data-slot='dropdown-menu-sub-trigger'
|
||||
data-inset={inset}
|
||||
className={cn(
|
||||
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8',
|
||||
' ',
|
||||
/* Text */
|
||||
'text-sm focus:text-accent-foreground data-[state=open]:text-accent-foreground',
|
||||
/* Background */
|
||||
'focus:bg-accent data-[state=open]:bg-accent',
|
||||
/* Border */
|
||||
'rounded-sm',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'cursor-default select-none',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'outline-hidden',
|
||||
/* Shadow */
|
||||
'',
|
||||
/* Opacity */
|
||||
'',
|
||||
/* Scaling */
|
||||
'',
|
||||
/* Spacing */
|
||||
'px-2 py-1.5 data-[inset]:pl-8',
|
||||
/* Alignment */
|
||||
'flex items-center',
|
||||
/* Miscellaneous */
|
||||
'',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
@ -230,7 +373,38 @@ function DropdownMenuSubContent({
|
|||
<DropdownMenuPrimitive.SubContent
|
||||
data-slot='dropdown-menu-sub-content'
|
||||
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-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
||||
' ',
|
||||
/* Text */
|
||||
'text-popover-foreground',
|
||||
/* Background */
|
||||
'bg-popover',
|
||||
/* Border */
|
||||
'border rounded-md',
|
||||
/* Font */
|
||||
'',
|
||||
/* Cursor */
|
||||
'',
|
||||
/* Ring */
|
||||
'',
|
||||
/* Outline */
|
||||
'',
|
||||
/* Shadow */
|
||||
'shadow-lg',
|
||||
/* Opacity */
|
||||
'',
|
||||
/* Scaling */
|
||||
'min-w-[8rem]',
|
||||
/* Spacing */
|
||||
'p-1',
|
||||
/* Alignment */
|
||||
'z-50 origin-(--radix-dropdown-menu-content-transform-origin)',
|
||||
/* Miscellaneous */
|
||||
'overflow-hidden',
|
||||
'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',
|
||||
/* ////////// */
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue