import React from 'react' import styled, { css } from 'styled-components/macro' import { darken } from 'polished' import { RowBetween } from '../Row' import { ChevronDown, Check } from 'react-feather' import { Button as RebassButton, ButtonProps } from 'rebass/styled-components' import useTheme from '../../hooks/useTheme' interface BaseProps extends ButtonProps { altDisabledStyle?: boolean borderRadius?: string padding?: string width?: string } export const BaseCSS = css` align-items: center; border-radius: ${({ borderRadius }) => borderRadius && borderRadius}; border-radius: 20px; border: 1px solid transparent; color: white; cursor: pointer; display: flex; flex-wrap: nowrap; font-weight: 500; justify-content: center; outline: none; padding: ${({ padding }) => (padding ? padding : '16px')}; position: relative; text-align: center; text-decoration: none; transform: perspective(1px) translateZ(0); transition: transform 450ms ease; width: ${({ width }) => (width ? width : '100%')}; will-change: transform; z-index: 1; &:disabled { cursor: auto; pointer-events: none; } &:hover { transform: scale(0.99); } > * { user-select: none; } > a { text-decoration: none; } ` export const Base = styled(RebassButton)` ${BaseCSS} ` export const ButtonPrimaryCSS = css` background-color: ${({ theme }) => theme.primary1}; color: white; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.05, theme.primary1)}; background-color: ${({ theme }) => darken(0.05, theme.primary1)}; } &:hover { background-color: ${({ theme }) => darken(0.05, theme.primary1)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.1, theme.primary1)}; background-color: ${({ theme }) => darken(0.1, theme.primary1)}; } &:disabled { background-color: ${({ theme, altDisabledStyle, disabled }) => altDisabledStyle ? (disabled ? theme.primary1 : theme.primary1) : theme.primary1}; color: white; cursor: auto; box-shadow: none; border: 1px solid transparent; outline: none; opacity: 0.4; opacity: ${({ altDisabledStyle }) => (altDisabledStyle ? '0.5' : '0.4')}; } ` export const ButtonPrimary = styled(Base)` ${ButtonPrimaryCSS} ` export const ButtonLightCSS = css` background-color: ${({ theme }) => theme.primary5}; color: ${({ theme }) => theme.primaryText1}; font-size: 16px; font-weight: 500; &:focus { box-shadow: 0 0 0 1pt ${({ theme, disabled }) => !disabled && darken(0.03, theme.primary5)}; background-color: ${({ theme, disabled }) => !disabled && darken(0.03, theme.primary5)}; } &:hover { background-color: ${({ theme, disabled }) => !disabled && darken(0.03, theme.primary5)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme, disabled }) => !disabled && darken(0.05, theme.primary5)}; background-color: ${({ theme, disabled }) => !disabled && darken(0.05, theme.primary5)}; } :disabled { opacity: 0.4; :hover { cursor: auto; background-color: ${({ theme }) => theme.primary5}; box-shadow: none; border: 1px solid transparent; outline: none; } } ` export const ButtonLight = styled(Base)` ${ButtonLightCSS} ` export const ButtonGray = styled(Base)` background-color: ${({ theme }) => theme.bg1}; color: ${({ theme }) => theme.text2}; font-size: 16px; font-weight: 500; &:focus { background-color: ${({ theme, disabled }) => !disabled && darken(0.05, theme.bg2)}; } &:hover { background-color: ${({ theme, disabled }) => !disabled && darken(0.05, theme.bg2)}; } &:active { background-color: ${({ theme, disabled }) => !disabled && darken(0.1, theme.bg2)}; } ` export const ButtonSecondary = styled(Base)` border: 1px solid ${({ theme }) => theme.primary4}; color: ${({ theme }) => theme.primary1}; background-color: transparent; font-size: 16px; border-radius: 12px; padding: ${({ padding }) => (padding ? padding : '10px')}; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => theme.primary4}; border: 1px solid ${({ theme }) => theme.primary3}; } &:hover { border: 1px solid ${({ theme }) => theme.primary3}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => theme.primary4}; border: 1px solid ${({ theme }) => theme.primary3}; } &:disabled { opacity: 50%; cursor: auto; } a:hover { text-decoration: none; } ` export const ButtonPink = styled(Base)` background-color: ${({ theme }) => theme.primary1}; color: white; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.05, theme.primary1)}; background-color: ${({ theme }) => darken(0.05, theme.primary1)}; } &:hover { background-color: ${({ theme }) => darken(0.05, theme.primary1)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.1, theme.primary1)}; background-color: ${({ theme }) => darken(0.1, theme.primary1)}; } &:disabled { background-color: ${({ theme }) => theme.primary1}; opacity: 50%; cursor: auto; } ` export const ButtonUNIGradient = styled(ButtonPrimary)` color: white; padding: 4px 8px; height: 36px; font-weight: 500; background-color: ${({ theme }) => theme.bg3}; background: radial-gradient(174.47% 188.91% at 1.84% 0%, #ff007a 0%, #2172e5 100%), #edeef2; width: fit-content; position: relative; cursor: pointer; border: none; white-space: no-wrap; :hover { opacity: 0.8; } :active { opacity: 0.9; } ` export const ButtonOutlined = styled(Base)` border: 1px solid ${({ theme }) => theme.bg2}; background-color: transparent; color: ${({ theme }) => theme.text1}; &:focus { box-shadow: 0 0 0 1px ${({ theme }) => theme.bg4}; } &:hover { box-shadow: 0 0 0 1px ${({ theme }) => theme.bg4}; } &:active { box-shadow: 0 0 0 1px ${({ theme }) => theme.bg4}; } &:disabled { opacity: 50%; cursor: auto; } ` export const ButtonEmpty = styled(Base)` background-color: transparent; color: ${({ theme }) => theme.primary1}; display: flex; justify-content: center; align-items: center; &:focus { text-decoration: underline; } &:hover { text-decoration: none; } &:active { text-decoration: none; } &:disabled { opacity: 50%; cursor: auto; } ` export const ButtonText = styled(Base)` padding: 0; width: fit-content; background: none; text-decoration: none; &:focus { // eslint-disable-next-line @typescript-eslint/no-unused-vars text-decoration: underline; } &:hover { // text-decoration: underline; opacity: 0.9; } &:active { text-decoration: underline; } &:disabled { opacity: 50%; cursor: auto; } ` export const ButtonWhite = styled(Base)` border: 1px solid #edeef2; background-color: ${({ theme }) => theme.bg1}; color: black; &:focus { // eslint-disable-next-line @typescript-eslint/no-unused-vars box-shadow: 0 0 0 1pt ${darken(0.05, '#edeef2')}; } &:hover { box-shadow: 0 0 0 1pt ${darken(0.1, '#edeef2')}; } &:active { box-shadow: 0 0 0 1pt ${darken(0.1, '#edeef2')}; } &:disabled { opacity: 50%; cursor: auto; } ` const ButtonConfirmedStyle = styled(Base)` background-color: ${({ theme }) => theme.bg3}; color: ${({ theme }) => theme.text1}; &:disabled { background-color: ${({ theme }) => theme.bg2}; color: ${({ theme }) => theme.text2}; cursor: auto; } ` const ButtonErrorStyle = styled(Base)` background-color: ${({ theme }) => theme.red1}; border: 1px solid ${({ theme }) => theme.red1}; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.05, theme.red1)}; background-color: ${({ theme }) => darken(0.05, theme.red1)}; } &:hover { background-color: ${({ theme }) => darken(0.05, theme.red1)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.1, theme.red1)}; background-color: ${({ theme }) => darken(0.1, theme.red1)}; } &:disabled { opacity: 50%; cursor: auto; box-shadow: none; background-color: ${({ theme }) => theme.red1}; border: 1px solid ${({ theme }) => theme.red1}; } ` export function ButtonConfirmed({ confirmed, altDisabledStyle, ...rest }: { confirmed?: boolean; altDisabledStyle?: boolean } & ButtonProps) { if (confirmed) { return } else { return } } export function ButtonError({ error, ...rest }: { error?: boolean } & ButtonProps) { if (error) { return } else { return } } export function ButtonDropdown({ disabled = false, children, ...rest }: { disabled?: boolean } & ButtonProps) { return (
{children}
) } export function ButtonDropdownGrey({ disabled = false, children, ...rest }: { disabled?: boolean } & ButtonProps) { return (
{children}
) } export function ButtonDropdownLight({ disabled = false, children, ...rest }: { disabled?: boolean } & ButtonProps) { return (
{children}
) } export function ButtonRadio({ active, ...rest }: { active?: boolean } & ButtonProps) { if (!active) { return } else { return } } const ActiveOutlined = styled(ButtonOutlined)` border: 1px solid; border-color: ${({ theme }) => theme.primary1}; ` const Circle = styled.div` height: 20px; width: 20px; border-radius: 50%; background-color: ${({ theme }) => theme.primary1}; display: flex; align-items: center; justify-content: center; ` const CheckboxWrapper = styled.div` width: 30px; padding: 0 10px; position: absolute; top: 10px; right: 10px; ` const ResponsiveCheck = styled(Check)` size: 13px; ` export function ButtonRadioChecked({ active = false, children, ...rest }: { active?: boolean } & ButtonProps) { const theme = useTheme() if (!active) { return ( {{children}} ) } else { return ( { {children} } ) } } export const ButtonSmall = styled(Base)` background-color: ${({ theme }) => theme.red5}; color: white; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.05, theme.red5)}; background-color: ${({ theme }) => darken(0.05, theme.red5)}; } &:hover { background-color: ${({ theme }) => darken(0.05, theme.red5)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.1, theme.red5)}; background-color: ${({ theme }) => darken(0.1, theme.red5)}; } &:disabled { background-color: ${({ theme }) => theme.red5}; opacity: 50%; cursor: auto; } padding-top: 0px; padding-bottom: 3px; width: 97px; font-weight: 600; ${({ theme }) => theme.mediaWidth.upToExtraSmall` font-size: 13px; `} ` export const ButtonMedium = styled(Base)` background-color: ${({ theme }) => theme.red5}; color: white; font-size: 18px; font-weight: 700; &:focus { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.05, theme.red5)}; background-color: ${({ theme }) => darken(0.05, theme.red5)}; } &:hover { background-color: ${({ theme }) => darken(0.05, theme.red5)}; } &:active { box-shadow: 0 0 0 1pt ${({ theme }) => darken(0.1, theme.red5)}; background-color: ${({ theme }) => darken(0.1, theme.red5)}; } &:disabled { background-color: ${({ theme }) => theme.red5}; opacity: 50%; cursor: auto; } ${({ theme }) => theme.mediaWidth.upToExtraSmall` font-size: 16px; `} `