@@ -2,14 +2,15 @@ import React from 'react';
22import propTypes from 'prop-types' ;
33
44import styled , { css } from 'styled-components' ;
5+ import { focusOutline } from '../common' ;
56import useControlledOrUncontrolled from '../common/hooks/useControlledOrUncontrolled' ;
67import Button from '../Button/Button' ;
78import Bar from '../Bar/Bar' ;
89
910const StyledBar = styled ( Bar ) `
1011 height: 23px;
1112 position: relative;
12- top: -1px ;
13+ top: 0 ;
1314` ;
1415
1516export const StyledColorInput = styled . input `
@@ -20,6 +21,7 @@ export const StyledColorInput = styled.input`
2021 left: 0;
2122 top: 0;
2223 opacity: 0;
24+ z-index: 1;
2325` ;
2426
2527// TODO replace with SVG icon
@@ -28,7 +30,7 @@ const ColorPreview = styled.div`
2830 height: 21px;
2931 display: inline-block;
3032 width: 35px;
31- margin-right: 0.5rem ;
33+ margin-right: 7px ;
3234
3335 background: ${ ( { color } ) => color } ;
3436
@@ -46,13 +48,12 @@ const ColorPreview = styled.div`
4648` ;
4749
4850const ChevronIcon = styled . span `
49- position: relative;
5051 width: 0px;
5152 height: 0px;
5253 border-left: 6px solid transparent;
5354 border-right: 6px solid transparent;
5455 display: inline-block;
55- margin-left: 0.5rem ;
56+ margin-left: 6px ;
5657
5758 ${ ( { isDisabled } ) =>
5859 isDisabled
@@ -65,6 +66,18 @@ const ChevronIcon = styled.span`
6566 : css `
6667 border-top: 6px solid ${ ( { theme } ) => theme . text } ;
6768 ` }
69+ &:after {
70+ content: '';
71+ box-sizing: border-box;
72+ position: absolute;
73+ top: ${ ( { variant } ) => ( variant === 'flat' ? '6px' : '8px' ) } ;
74+ right: 8px;
75+ width: 16px;
76+ height: 19px;
77+ }
78+ ${ StyledColorInput } :focus + &:after {
79+ ${ focusOutline }
80+ }
6881` ;
6982
7083// TODO make sure all aria and role attributes are in place
@@ -109,7 +122,7 @@ const ColorInput = React.forwardRef(function ColorInput(props, ref) {
109122 ref = { ref }
110123 { ...otherProps }
111124 />
112- < ChevronIcon isDisabled = { disabled } />
125+ < ChevronIcon isDisabled = { disabled } variant = { variant } />
113126 </ Button >
114127 ) ;
115128} ) ;
0 commit comments