UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

77 lines (71 loc) 1.85 kB
import styled from 'styled-components'; import { variant } from 'styled-system'; import { get } from '../constants.js'; import sx from '../sx.js'; const variants = { default: { borderColor: 'border.default' }, primary: { borderColor: 'fg.default' }, secondary: { borderColor: 'border.muted', color: 'fg.muted' }, accent: { borderColor: 'accent.emphasis', color: 'accent.fg' }, success: { borderColor: 'success.emphasis', color: 'success.fg' }, attention: { borderColor: 'attention.emphasis', color: 'attention.fg' }, severe: { borderColor: 'severe.emphasis', color: 'severe.fg' }, danger: { borderColor: 'danger.emphasis', color: 'danger.fg' }, done: { borderColor: 'done.emphasis', color: 'done.fg' }, sponsors: { borderColor: 'sponsors.emphasis', color: 'sponsors.fg' } }; const sizes = { small: { height: '20px', padding: '0 7px' // hard-coded to align with Primer ViewComponents and Primer CSS }, large: { height: '24px', padding: '0 10px' // hard-coded to align with Primer ViewComponents and Primer CSS } }; const Label = styled.span.withConfig({ displayName: "Label", componentId: "sc-1dgcne-0" })(["align-items:center;background-color:transparent;border-width:1px;border-radius:999px;border-style:solid;display:inline-flex;font-weight:", ";font-size:", ";line-height:1;white-space:nowrap;", ";", ";", ";"], get('fontWeights.bold'), get('fontSizes.0'), variant({ variants }), variant({ prop: 'size', variants: sizes }), sx); // TODO: Remove defaultProps to be compatible with the next major version of React // Reference: https://github.com/primer/react/issues/2758 Label.defaultProps = { size: 'small', variant: 'default' }; var Label$1 = Label; export { Label$1 as default, variants };