Commit 1843f214 authored by lynn's avatar lynn Committed by GitHub

fix: hover button states (#5553)

* init but this looks wrong based on figma

* init

* fix props

* add back children
parent c098ad1f
...@@ -7,14 +7,26 @@ import { RowBetween } from '../Row' ...@@ -7,14 +7,26 @@ import { RowBetween } from '../Row'
type ButtonProps = Omit<ButtonPropsOriginal, 'css'> type ButtonProps = Omit<ButtonPropsOriginal, 'css'>
export const BaseButton = styled(RebassButton)< const ButtonOverlay = styled.div`
{ background-color: transparent;
bottom: 0;
border-radius: 16px;
height: 100%;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: 150ms ease background-color;
width: 100%;
`
type BaseButtonProps = {
padding?: string padding?: string
width?: string width?: string
$borderRadius?: string $borderRadius?: string
altDisabledStyle?: boolean altDisabledStyle?: boolean
} & ButtonProps } & ButtonProps
>`
export const BaseButton = styled(RebassButton)<BaseButtonProps>`
padding: ${({ padding }) => padding ?? '16px'}; padding: ${({ padding }) => padding ?? '16px'};
width: ${({ width }) => width ?? '100%'}; width: ${({ width }) => width ?? '100%'};
font-weight: 500; font-weight: 500;
...@@ -86,7 +98,7 @@ export const SmallButtonPrimary = styled(ButtonPrimary)` ...@@ -86,7 +98,7 @@ export const SmallButtonPrimary = styled(ButtonPrimary)`
border-radius: 12px; border-radius: 12px;
` `
export const ButtonLight = styled(BaseButton)` const BaseButtonLight = styled(BaseButton)`
background-color: ${({ theme }) => theme.accentActionSoft}; background-color: ${({ theme }) => theme.accentActionSoft};
color: ${({ theme }) => theme.accentAction}; color: ${({ theme }) => theme.accentAction};
font-size: 20px; font-size: 20px;
...@@ -103,6 +115,19 @@ export const ButtonLight = styled(BaseButton)` ...@@ -103,6 +115,19 @@ export const ButtonLight = styled(BaseButton)`
box-shadow: 0 0 0 1pt ${({ theme, disabled }) => !disabled && theme.accentActionSoft}; box-shadow: 0 0 0 1pt ${({ theme, disabled }) => !disabled && theme.accentActionSoft};
background-color: ${({ theme, disabled }) => !disabled && theme.accentActionSoft}; background-color: ${({ theme, disabled }) => !disabled && theme.accentActionSoft};
} }
:hover {
${ButtonOverlay} {
background-color: ${({ theme }) => theme.stateOverlayHover};
}
}
:active {
${ButtonOverlay} {
background-color: ${({ theme }) => theme.stateOverlayPressed};
}
}
:disabled { :disabled {
opacity: 0.4; opacity: 0.4;
:hover { :hover {
...@@ -369,18 +394,6 @@ export function ButtonRadioChecked({ active = false, children, ...rest }: { acti ...@@ -369,18 +394,6 @@ export function ButtonRadioChecked({ active = false, children, ...rest }: { acti
} }
} }
const ButtonOverlay = styled.div`
background-color: transparent;
bottom: 0;
border-radius: 16px;
height: 100%;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: 150ms ease background-color;
width: 100%;
`
export enum ButtonSize { export enum ButtonSize {
small, small,
medium, medium,
...@@ -395,7 +408,7 @@ export enum ButtonEmphasis { ...@@ -395,7 +408,7 @@ export enum ButtonEmphasis {
warning, warning,
destructive, destructive,
} }
interface BaseButtonProps { interface BaseThemeButtonProps {
size: ButtonSize size: ButtonSize
emphasis: ButtonEmphasis emphasis: ButtonEmphasis
} }
...@@ -474,7 +487,7 @@ function pickThemeButtonTextColor({ theme, emphasis }: { theme: DefaultTheme; em ...@@ -474,7 +487,7 @@ function pickThemeButtonTextColor({ theme, emphasis }: { theme: DefaultTheme; em
} }
} }
const BaseThemeButton = styled.button<BaseButtonProps>` const BaseThemeButton = styled.button<BaseThemeButtonProps>`
align-items: center; align-items: center;
background-color: ${pickThemeButtonBackgroundColor}; background-color: ${pickThemeButtonBackgroundColor};
border-radius: 16px; border-radius: 16px;
...@@ -513,7 +526,7 @@ const BaseThemeButton = styled.button<BaseButtonProps>` ...@@ -513,7 +526,7 @@ const BaseThemeButton = styled.button<BaseButtonProps>`
} }
` `
interface ThemeButtonProps extends React.ComponentPropsWithoutRef<'button'>, BaseButtonProps {} interface ThemeButtonProps extends React.ComponentPropsWithoutRef<'button'>, BaseThemeButtonProps {}
export const ThemeButton = ({ children, ...rest }: ThemeButtonProps) => { export const ThemeButton = ({ children, ...rest }: ThemeButtonProps) => {
return ( return (
...@@ -523,3 +536,12 @@ export const ThemeButton = ({ children, ...rest }: ThemeButtonProps) => { ...@@ -523,3 +536,12 @@ export const ThemeButton = ({ children, ...rest }: ThemeButtonProps) => {
</BaseThemeButton> </BaseThemeButton>
) )
} }
export const ButtonLight = ({ children, ...rest }: BaseButtonProps) => {
return (
<BaseButtonLight {...rest}>
<ButtonOverlay />
{children}
</BaseButtonLight>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment