Accepting color in Hairline component

This commit is contained in:
apanizo 2018-10-18 16:56:21 +02:00
parent 53b169bc42
commit 369045b75f
1 changed files with 5 additions and 4 deletions

View File

@ -3,19 +3,20 @@ import * as React from 'react'
import { type Size, getSize } from '~/theme/size'
import { border } from '~/theme/variables'
const calculateStyleFrom = (margin?: Size) => ({
const calculateStyleFrom = (color?: string, margin?: Size) => ({
width: '100%',
height: '1px',
backgroundColor: border,
backgroundColor: color || border,
margin: `${getSize(margin)} 0px`,
})
type Props = {
margin?: Size,
color?: string,
}
const Hairline = ({ margin }: Props) => {
const style = calculateStyleFrom(margin)
const Hairline = ({ margin, color }: Props) => {
const style = calculateStyleFrom(color, margin)
return <div style={style} />
}