-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstyled.js
More file actions
90 lines (80 loc) · 2.33 KB
/
styled.js
File metadata and controls
90 lines (80 loc) · 2.33 KB
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
import styled, { css } from "styled-components"
import { Icon } from "@/components/icon"
import Flex from "@/components/templates/flex"
import { TextSmall } from "@/components/typography"
import { getColor, getValidatedControlColor } from "@/theme/utils"
const disabledCursorSupport = css`
cursor: ${({ disabled }) => (disabled ? "not-allowed" : "")};
pointer-events: ${({ disabled }) => (disabled ? "none" : "auto")};
`
export const Input = styled(Flex).attrs(props => ({
round: 0.5,
as: "input",
background: "inputBg",
backgroundOpacity: props.disabled ? 0.4 : 1,
width: "100%",
border: props.error ? "error" : props.hasValue ? "text" : "inputBorder",
_hover: {
border: props.error ? "errorText" : "inputBorderHover",
},
_focus: {
border: props.error ? "errorText" : "inputBorderFocus",
},
padding: [0.5, 1],
height: 6,
...props,
}))`
font-size: 12px;
color: ${({ disabled, hasValue }) =>
hasValue ? getColor("text") : disabled ? getColor("placeholder") : getColor("textLite")};
${({ hasIconLeft }) => hasIconLeft && "padding-left: 24px;"}
${({ hasIconRight, hasIndicator }) =>
(hasIconRight || hasIndicator) && `padding-right: ${hasIconRight && hasIndicator ? 48 : 24}px;`}
&::placeholder {
font-size: 12px;
color: ${getColor("placeholder")};
opacity: ${({ disabled }) => (disabled ? 0.4 : 1)};
font-weight: normal;
${({ placeholderProps }) => placeholderProps || null}
}
${disabledCursorSupport};
`
export const StyledLabel = styled.label`
width: 100%;
display: block;
${disabledCursorSupport};
`
export const LabelText = styled(Flex).attrs(props => ({
as: TextSmall,
strong: true,
alignItems: "center",
flex: false,
width: "100%",
...props,
}))``
export const StyledIcon = styled(Icon)`
flex-grow: 0;
flex-shrink: 0;
`
export const ErrorIcon = styled(StyledIcon)`
fill: ${getColor("error")};
`
export const SuccessIcon = styled(StyledIcon)`
fill: ${getColor("success")};
`
export const IconContainer = styled(Flex)``
export const MetaContainer = styled(Flex)`
flex-flow: row nowrap;
`
export const MetaInfo = styled.span`
font-size: 12px;
line-height: 16px;
overflow: hidden;
flex-grow: 0;
flex-shrink: 0;
color: ${getColor("placeholder")};
`
export const FieldInfo = styled(MetaInfo)`
color: ${getValidatedControlColor("text")};
flex-shrink: 1;
`