refactor(ui): enhance Button and variants for improved styling and interaction
- Updated Button component animations for tap and hover states to provide a more responsive feel. - Adjusted padding and margin in button variants for better alignment and visual consistency. - Enhanced hover and active states with additional shadow effects for improved user feedback. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -17,11 +17,12 @@ export interface BaseButtonProps {
|
||||
const motionBaseMap = {
|
||||
pc: {
|
||||
whileFocus: { scale: 1.02 },
|
||||
whileTap: { scale: 0.95 },
|
||||
whileTap: { scale: 0.97 },
|
||||
whileHover: { translateY: -1 },
|
||||
},
|
||||
mobile: {
|
||||
whileFocus: { opacity: 0.8 },
|
||||
whileTap: { opacity: 0.2 },
|
||||
whileTap: { opacity: 0.6 },
|
||||
},
|
||||
} as const
|
||||
export const MotionButtonBase = ({
|
||||
@@ -83,7 +84,6 @@ export const Button = ({
|
||||
status: isLoading || disabled ? "disabled" : undefined,
|
||||
size,
|
||||
}),
|
||||
|
||||
buttonClassName,
|
||||
)}
|
||||
disabled={isLoading || disabled}
|
||||
@@ -93,12 +93,15 @@ export const Button = ({
|
||||
<span className="contents">
|
||||
{typeof isLoading === "boolean" && (
|
||||
<m.span
|
||||
className="center"
|
||||
className="center overflow-hidden"
|
||||
animate={{
|
||||
width: isLoading ? "auto" : "0px",
|
||||
width: isLoading ? "1.2em" : "0px",
|
||||
marginRight: isLoading ? "0.5rem" : "0",
|
||||
opacity: isLoading ? 1 : 0,
|
||||
}}
|
||||
transition={{ duration: 0.2 }}
|
||||
>
|
||||
{isLoading && <LoadingCircle size="small" className="center mr-2" />}
|
||||
{isLoading && <LoadingCircle size="small" className="center" />}
|
||||
</m.span>
|
||||
)}
|
||||
<span className={cn("center", textClassName)}>{props.children}</span>
|
||||
@@ -124,7 +127,7 @@ export const IconButton = ({
|
||||
styledButtonVariant({
|
||||
variant: "ghost",
|
||||
}),
|
||||
"bg-accent/10 hover:bg-accent dark:bg-accent/20 dark:hover:bg-accent/60 group relative gap-2 px-4",
|
||||
"bg-accent/10 hover:bg-accent/20 active:bg-accent/30 dark:bg-accent/20 dark:hover:bg-accent/30 dark:active:bg-accent/40 group relative gap-2 px-4 transition-all duration-300",
|
||||
rest.className,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -36,9 +36,9 @@ export const styledButtonVariant = cva(
|
||||
],
|
||||
variants: {
|
||||
size: {
|
||||
sm: "px-2 py-1 rounded-md text-xs",
|
||||
default: "px-3 py-1.5 rounded-lg text-sm",
|
||||
lg: "px-4 py-2 rounded-lg text-base",
|
||||
sm: "px-3 py-1 rounded-md text-xs",
|
||||
default: "px-4 py-1.5 rounded-lg text-sm",
|
||||
lg: "px-5 py-2 rounded-lg text-base",
|
||||
},
|
||||
|
||||
status: {
|
||||
@@ -47,24 +47,30 @@ export const styledButtonVariant = cva(
|
||||
variant: {
|
||||
primary: cn(
|
||||
"bg-accent",
|
||||
"hover:contrast-[1.10] active:contrast-125",
|
||||
"hover:contrast-[1.10] hover:shadow-md hover:shadow-accent/20 active:contrast-125 active:shadow-none",
|
||||
"font-semibold",
|
||||
"disabled:bg-theme-disabled disabled:dark:text-zinc-50",
|
||||
"disabled:bg-theme-disabled disabled:dark:text-zinc-50 disabled:shadow-none",
|
||||
"text-zinc-100",
|
||||
"focus:border-accent/80 focus:outline-none focus:ring-2",
|
||||
"transition-all duration-300",
|
||||
),
|
||||
|
||||
outline: cn(
|
||||
"bg-theme-background font-semibold transition-colors duration-200",
|
||||
"border border-border hover:bg-zinc-50 dark:bg-neutral-900/30 dark:hover:bg-neutral-900/80",
|
||||
"focus:border-accent/80",
|
||||
"border border-border hover:border-accent/50 hover:bg-zinc-50/80 dark:bg-neutral-900/30 dark:hover:bg-neutral-900/80",
|
||||
"focus:border-accent/80 focus:ring-1 focus:ring-accent/30",
|
||||
"hover:shadow-sm",
|
||||
),
|
||||
text: cn(
|
||||
"font-semibold text-accent",
|
||||
"hover:contrast-[1.10] active:contrast-125",
|
||||
"hover:contrast-[1.10] active:contrast-125 hover:bg-accent/10",
|
||||
tw`focus:text-accent focus:outline-none p-0 inline align-baseline`,
|
||||
),
|
||||
ghost: cn("px-1.5 font-semibold", "hover:bg-material-ultra-thick"),
|
||||
ghost: cn(
|
||||
"px-2 font-semibold",
|
||||
"hover:bg-material-ultra-thick",
|
||||
"transition-all duration-200",
|
||||
),
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user