Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 96x 10x 86x 86x 9x 53x 5x 48x 48x 9x 106x 106x 53x 53x 53x 53x 53x 53x 53x 53x 53x 53x 53x | /* eslint-disable no-ternary, no-nested-ternary */
import Reset from "components/buttons/Reset"
import { Theme } from "styles/theme"
import colors from "styles/colors"
import getColorGrades from "helpers/getColorGrades"
import { rgba } from "polished"
import styled from "styled-components"
type Props = {
$bold?: boolean
$expanded?: boolean
$hasIconEnd: boolean
$hasIconStart: boolean
$iconOnly?: boolean
$loading?: boolean
$noHoverHighlight?: boolean
$outlined?: boolean
$padded?: boolean
$raised?: boolean
$rounded?: boolean
$secondary?: boolean
$small?: boolean
$transparent?: boolean
disabled?: boolean
}
const BACKGROUND_ALPHA = 0.7
const BOX_SHADOW_ALPHA_ONE = 0.2
const BOX_SHADOW_ALPHA_TWO = 0.14
const BOX_SHADOW_ALPHA_THREE = 0.12
const getBackground = (props: Props & { theme: Theme }) => {
if (props.$transparent) {
return "transparent"
}
const colorGrades = getColorGrades(props)
return props.$outlined ? colorGrades.contrast : colorGrades.main
}
const getBorder = (props: Props & { theme: Theme }) => {
if (props.$transparent) {
return "1px solid transparent"
}
const colorGrades = getColorGrades(props)
return `1px solid ${colorGrades.main}`
}
const getColor = (props: Props & { theme: Theme }) => {
const colorGrades = getColorGrades(props)
return props.$outlined || props.$transparent
? colorGrades.main
: colorGrades.contrast
}
export const Wrapper = styled(Reset).attrs((props: Props) => ({
"data-variant": props.$secondary
? "secondary"
: props.$outlined
? "outlined"
: props.$iconOnly
? "iconOnly"
: undefined
}))`
align-items: center;
background: ${getBackground};
border: ${getBorder};
border-radius: ${({ $rounded }: { $rounded?: boolean }) =>
$rounded ? "50%" : "3px"};
${({ $raised }: { $raised?: boolean }) =>
$raised &&
`box-shadow: 0px 3px 1px -2px ${rgba(
colors.black,
BOX_SHADOW_ALPHA_ONE
)}, 0px 2px 2px 0px ${rgba(
colors.black,
BOX_SHADOW_ALPHA_TWO
)}, 0px 1px 5px 0px ${rgba(colors.black, BOX_SHADOW_ALPHA_THREE)};`}
color: ${getColor};
column-gap: 10px;
cursor: ${({ disabled }: { disabled?: boolean }) =>
disabled ? "not-allowed" : "pointer"};
display: grid;
font-family: ${({ theme }: { theme: Theme }) => theme.font.family};
font-size: ${({ $small }: { $small?: boolean }) =>
$small ? "14px" : "16px"};
font-weight: ${({ $bold }: { $bold?: boolean }) => ($bold ? "700" : "300")};
grid-template-columns: ${({ $hasIconEnd, $hasIconStart, $loading }: Props) =>
$loading
? "auto auto auto auto"
: $hasIconEnd || $hasIconStart
? "auto auto auto"
: "auto"};
justify-items: center;
line-height: 1.33;
padding: ${({ $padded, $rounded, $small, $iconOnly }: Props) =>
$small
? "6px 12px"
: $iconOnly || $rounded
? "10px"
: $padded
? "15px 42px"
: "10px 20px"};
transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
transition-property: background-color, color, opacity;
width: ${({ $expanded }: { $expanded?: boolean }) =>
$expanded ? "100%" : "auto"};
&:hover {
${(props: any) =>
!props.$noHoverHighlight &&
`background:
${
props.disabled || props.$transparent
? getBackground(props)
: rgba(getBackground(props), BACKGROUND_ALPHA)
};}`}
& i,
svg {
color: ${getColor};
}
`
|