diff --git a/ui/app/components/ui/chip/chip.js b/ui/app/components/ui/chip/chip.js new file mode 100644 index 000000000..c2281f7d4 --- /dev/null +++ b/ui/app/components/ui/chip/chip.js @@ -0,0 +1,55 @@ +import React from 'react' +import PropTypes from 'prop-types' +import classnames from 'classnames' +import { omit } from 'lodash' +import Typography from '../typography' +import { COLORS } from '../../../helpers/constants/design-system' + +export default function Chip({ + className, + children, + borderColor = COLORS.UI1, + label, + labelProps = {}, + leftIcon, + rightIcon, + onClick, +}) { + return ( +
+ {leftIcon &&
{leftIcon}
} + {children ?? ( + + {label} + + )} + {rightIcon &&
{rightIcon}
} +
+ ) +} + +Chip.propTypes = { + borderColor: PropTypes.oneOf(Object.values(COLORS)), + label: PropTypes.string, + children: PropTypes.node, + labelProps: PropTypes.shape(omit(Typography.propTypes, ['className'])), + leftIcon: PropTypes.node, + rightIcon: PropTypes.node, + className: PropTypes.string, + onClick: PropTypes.func, +} diff --git a/ui/app/components/ui/chip/chip.scss b/ui/app/components/ui/chip/chip.scss new file mode 100644 index 000000000..911f5a8ce --- /dev/null +++ b/ui/app/components/ui/chip/chip.scss @@ -0,0 +1,48 @@ +@use "design-system"; + +.chip { + $self: &; + + border-radius: 100px; + border: 1px solid design-system.$ui-1; + padding: 8px 16px; + margin: 0 4px; + display: flex; + align-items: center; + width: max-content; + + &__left-icon, + &__right-icon { + display: flex; + align-items: center; + } + + @each $variant, $color in design-system.$color-map { + &--#{$variant} { + border-color: $color; + } + } + + &--with-left-icon, + &--with-right-icon { + padding-top: 4px; + padding-bottom: 4px; + } + + &--with-left-icon { + padding-left: 4px; + + #{$self}__label { + margin-left: 8px; + } + } + + + + &--with-right-icon { + padding-right: 4px; + #{$self}__label { + margin-right: 8px; + } + } +} diff --git a/ui/app/components/ui/chip/chip.stories.js b/ui/app/components/ui/chip/chip.stories.js new file mode 100644 index 000000000..e2f3fd5df --- /dev/null +++ b/ui/app/components/ui/chip/chip.stories.js @@ -0,0 +1,82 @@ +/* eslint-disable react/prop-types */ + +import React from 'react' +import { select, text } from '@storybook/addon-knobs' +import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system' +import ApproveIcon from '../icon/approve-icon.component' +import Identicon from '../identicon/identicon.component' +import Chip from '.' + +export default { + title: 'Chip', +} + +export const Plain = ({ + leftIcon, + rightIcon, + label = 'Hello', + borderColor = COLORS.UI1, + fontColor = COLORS.BLACK, +}) => ( + +) + +export const WithLeftIcon = () => ( + } + /> +) + +export const WithRightIcon = () => ( + + } + /> +) + +export const WithBothIcons = () => ( + + + + } + leftIcon={ + + } + /> +) diff --git a/ui/app/components/ui/chip/index.js b/ui/app/components/ui/chip/index.js new file mode 100644 index 000000000..54029bc48 --- /dev/null +++ b/ui/app/components/ui/chip/index.js @@ -0,0 +1 @@ +export { default } from './chip' diff --git a/ui/app/components/ui/ui-components.scss b/ui/app/components/ui/ui-components.scss index 3d5e5446c..f7f18b0a2 100644 --- a/ui/app/components/ui/ui-components.scss +++ b/ui/app/components/ui/ui-components.scss @@ -7,6 +7,7 @@ @import 'button/buttons'; @import 'card/index'; @import 'check-box/index'; +@import 'chip/chip'; @import 'circle-icon/index'; @import 'currency-display/index'; @import 'currency-input/index'; diff --git a/ui/app/css/design-system/colors.scss b/ui/app/css/design-system/colors.scss index a1383b661..b447315f8 100644 --- a/ui/app/css/design-system/colors.scss +++ b/ui/app/css/design-system/colors.scss @@ -136,4 +136,5 @@ $color-map: ( 'kovan': $kovan, 'rinkeby': $rinkeby, 'goerli': $goerli, + 'transparent': transparent, ); diff --git a/ui/app/helpers/constants/design-system.js b/ui/app/helpers/constants/design-system.js index 6d6512eba..0d1a42eea 100644 --- a/ui/app/helpers/constants/design-system.js +++ b/ui/app/helpers/constants/design-system.js @@ -25,6 +25,7 @@ export const COLORS = { KOVAN: 'kovan', RINKEBY: 'rinkeby', GOERLI: 'goerli', + TRANSPARENT: 'transparent', } export const TYPOGRAPHY = {