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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | 7x 7x 7x 7x 7x 84x 10x 74x 74x 7x 42x 5x 37x 37x 7x 84x 84x 42x 42x 42x 42x 42x 42x 42x 42x 42x 42x 7x 7x 7x | // @flow
/* eslint-disable no-ternary, no-nested-ternary */
import styled, { type StyledComponent } from "styled-components"
import Reset from "components/buttons/Reset"
import type { Theme } from "@bluframe/blublocks"
import colors from "styles/colors"
import getColorGrades from "helpers/getColorGrades"
import { rgba } from "polished"
type Props = {|
+$bold?: boolean,
+$expanded?: boolean,
+$iconOnly?: 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: StyledComponent<
Props,
Theme,
StyledComponent<{||}, Theme, HTMLButtonElement>
> = 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: flex;
font-family: ${({ theme }: { theme: Theme }) => theme.font.family};
font-size: ${({ $small }: { $small: boolean }) => ($small ? "14px" : "16px")};
font-weight: ${({ $bold }: { $bold: boolean }) => ($bold ? "700" : "300")};
justify-content: center;
line-height: 1.33;
padding: ${({
$padded,
$rounded,
$small,
$iconOnly
}: {
$padded: boolean,
$rounded: boolean,
$small: boolean,
$iconOnly: boolean
}) =>
$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};
}
`
export const Icon: StyledComponent<{||}, Theme, HTMLElement> = styled.span``
export const IconEnd: StyledComponent<{||}, Theme, HTMLElement> = styled.span``
export const IconStart: StyledComponent<
{||},
Theme,
HTMLElement
> = styled.span``
|