|
1 | 1 | /* eslint-disable no-unused-vars */ |
2 | 2 | import { injectGlobal, css } from 'styled-components' |
3 | | -import { transparentize, lighten, modularScale, darken } from 'polished' |
4 | | -import { th } from '../utils' |
| 3 | +import { |
| 4 | + transparentize, |
| 5 | + lighten, |
| 6 | + modularScale, |
| 7 | + darken, |
| 8 | + parseToRgb, |
| 9 | +} from 'polished' |
| 10 | +import { th, mixin } from '../utils' |
5 | 11 |
|
6 | 12 | /* eslint-disable no-unused-expressions */ |
7 | 13 | injectGlobal` |
@@ -54,6 +60,9 @@ export const dark = gray800 |
54 | 60 | export const primaryLight = th('primary', c => lighten(0.3, c)) |
55 | 61 | export const secondaryLight = th('secondary', c => lighten(0.3, c)) |
56 | 62 |
|
| 63 | +export const yikTextDark = '#111' |
| 64 | +export const yikTextLight = '#fff' |
| 65 | + |
57 | 66 | // Borders |
58 | 67 |
|
59 | 68 | export const borderRadius = '.25rem' |
@@ -110,11 +119,6 @@ export const btnPaddingXLg = th('inputBtnPaddingXLg') |
110 | 119 | export const btnLineHeightLg = th('inputBtnLineHeightLg') |
111 | 120 |
|
112 | 121 | export const btnBorderWidth = 0 |
113 | | - |
114 | | -export const btnBackgroundColor = th('primary') |
115 | | -export const btnHoverBackgroundColor = th('btnBackgroundColor', color => |
116 | | - darken(0.05, color), |
117 | | -) |
118 | 122 | export const btnDisabledOpacity = 0.8 |
119 | 123 |
|
120 | 124 | // Inputs |
@@ -168,7 +172,27 @@ export const breakPoints = { |
168 | 172 |
|
169 | 173 | // Mixins |
170 | 174 |
|
171 | | -export const controlFocus = css` |
| 175 | +export const controlFocus = (baseColor = 'primary') => css` |
172 | 176 | outline: 0; |
173 | | - box-shadow: 0 0 2px ${th('primary', color => transparentize(0.1, color))}; |
| 177 | + box-shadow: 0 0 2px ${th(baseColor, color => transparentize(0.1, color))}; |
174 | 178 | ` |
| 179 | + |
| 180 | +export const btnVariant = baseColor => css` |
| 181 | + color: ${props => props.theme.colorYik(th(baseColor)(props))}; |
| 182 | + background-color: ${th(baseColor)}; |
| 183 | +
|
| 184 | + &:focus { |
| 185 | + ${mixin('controlFocus', baseColor)}; |
| 186 | + } |
| 187 | +
|
| 188 | + &:not(:disabled):hover, |
| 189 | + &:not(:disabled):active { |
| 190 | + background-color: ${th(baseColor, color => darken(0.05, color))}; |
| 191 | + } |
| 192 | +` |
| 193 | + |
| 194 | +export const colorYik = color => { |
| 195 | + const { red: r, green: g, blue: b } = parseToRgb(color) |
| 196 | + const yik = (r * 299 + g * 587 + b * 114) / 1000 |
| 197 | + return yik >= 150 ? th('yikTextDark') : th('yikTextLight') |
| 198 | +} |
0 commit comments