|
| 1 | +import styled from 'vue-styled-components' |
| 2 | +// import { colors } from '../../lib/theme' |
| 3 | + |
| 4 | +const buttonProps = { |
| 5 | + variant: String |
| 6 | +} |
| 7 | + |
| 8 | +/** |
| 9 | + * @description Determines style colors for solid variant |
| 10 | + * @param {{color:String, colorMode:String, _theme:Object }} params |
| 11 | + */ |
| 12 | +const solidVariantProps = ({ color, colorMode = 'light', _theme }) => { |
| 13 | + let style = { |
| 14 | + light: { |
| 15 | + bg: `${color}.500`, |
| 16 | + color: 'white', |
| 17 | + _hover: { |
| 18 | + bg: `${color}.600` |
| 19 | + }, |
| 20 | + _active: { |
| 21 | + bg: `${color}.700` |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + return style[colorMode] |
| 26 | +} |
| 27 | + |
| 28 | +/** |
| 29 | + * @description Generates styled for variants |
| 30 | + * @param {Object} props |
| 31 | + * @returns {Object} Variant styles object |
| 32 | + */ |
| 33 | +const variantProps = props => { |
| 34 | + switch (props.variant) { |
| 35 | + case 'solid': |
| 36 | + return solidVariantProps(props) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +// const baseProps = { |
| 41 | +// display: 'inline-flex', |
| 42 | +// appearance: 'none', |
| 43 | +// alignItems: 'center', |
| 44 | +// justifyContent: 'center', |
| 45 | +// transition: 'all 250ms', |
| 46 | +// userSelect: 'none', |
| 47 | +// position: 'relative', |
| 48 | +// whiteSpace: 'nowrap', |
| 49 | +// verticalAlign: 'middle', |
| 50 | +// lineHeight: '1.2', |
| 51 | +// outline: 'none' |
| 52 | +// } |
| 53 | + |
| 54 | +const Button = styled('button', buttonProps)` |
| 55 | + font-size: 1em; |
| 56 | + text-align: center; |
| 57 | + padding: 10px 15px; |
| 58 | + border-radius: ${({ radius }) => radius ? '6px' : null}; |
| 59 | + ${(props) => variantProps(props)} |
| 60 | +` |
| 61 | + |
| 62 | +export default Button |
0 commit comments