Skip to content

Commit

Permalink
fix: add default hint color (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
anucreative authored Jul 15, 2019
1 parent e5d3802 commit 766ebee
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/components/Hint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export const Hint = forwardRef(({ children, variant }, ref) => (
Hint.displayName = 'Hint'

Hint.propTypes = {
/** Node component from parent */
children: node,
/** Variant of component */
variant: oneOf(['warning', 'error'])
}
2 changes: 1 addition & 1 deletion src/components/Hint/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('<Hint>', () => {
const button = getByTestId('hint')

expect(button).toHaveTextContent(content)
expect(button).toHaveStyleRule('color', undefined)
expect(button).toHaveStyleRule('color', '#8e8e8e')
})

it('should render correctly with a state', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Hint/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { getVariantStateColor, system } from '../../utils/'

export const Hint = styled.div(
props => css`
font-family: texts;
color: ${getVariantStateColor(props.variant)};
${th('fields.hint')};
color: ${getVariantStateColor(props.variant)};
margin-top: sm;
${system};
`
Expand Down
1 change: 1 addition & 0 deletions src/theme/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const getFields = theme => {
color: colors.nude[600]
},
hint: {
color: colors.nude[600],
'font-size': fontSizes.body3,
'font-weight': fontWeights.regular
},
Expand Down
6 changes: 3 additions & 3 deletions src/utils/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const getHintText = ({ connected, error, hint, touched, warning }) => {
}
}

const variantStateColors = {
const VARIANTS = {
focused: 'colors.primary.500',
error: 'colors.danger.500',
warning: 'colors.warning.500',
info: 'colors.info.500'
}

export const getVariantStateColor = variant => {
const variantColor = variantStateColors[variant]
const variantColor = VARIANTS[variant]
return variantColor ? th(variantColor) : null
}

Expand All @@ -45,7 +45,7 @@ const variantColors = {
secondary: 'colors.secondary.500',
turquoize: 'colors.sub.turquoize',
yellow: 'colors.sub.yellow',
...variantStateColors
...VARIANTS
}

export const getVariantColor = variant => {
Expand Down

0 comments on commit 766ebee

Please sign in to comment.