-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathstyled.js
29 lines (26 loc) · 946 Bytes
/
styled.js
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
import styled from "styled-components"
import { getColor } from "@/theme"
import margin from "@/mixins/margin"
import alignSelf from "@/mixins/alignSelf"
import cursor from "@/mixins/cursor"
const SIZES = {
small: "14px",
medium: "16px",
large: "24px",
}
const styledColor = ({ theme, color }) => color && `fill: ${getColor(color)({ theme })};`
const styledHoverColor = ({ theme, hoverColor }) =>
hoverColor && `&:hover { fill: ${getColor(hoverColor)({ theme })}; }`
const styledRotate = ({ rotate }) => !isNaN(rotate) && `transform: rotate(${rotate * 90}deg);`
export const StyledIcon = styled.svg`
height: ${({ size, height }) => height || SIZES[size]};
width: ${({ size, width }) => width || SIZES[size]};
opacity: ${({ disabled }) => (disabled ? 0.4 : 1)};
pointer-events: ${({ disabled }) => (disabled ? "none" : "unset")};
${styledRotate}
${styledColor}
${styledHoverColor}
${margin}
${alignSelf}
${cursor}
`