@primer/react
Version:
An implementation of GitHub's Primer Design System using React
85 lines (80 loc) • 2.33 kB
JavaScript
import React__default from 'react';
import styled from 'styled-components';
import { variant } from 'styled-system';
import { get } from '../constants.js';
import sx from '../sx.js';
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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 StyledLabel = styled.span.withConfig({
displayName: "Label__StyledLabel",
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);
const Label = /*#__PURE__*/React__default.forwardRef(function Label({
as,
size = 'small',
variant = 'default',
...rest
}, ref) {
return /*#__PURE__*/React__default.createElement(StyledLabel, _extends({
as: as,
size: size,
variant: variant,
ref: ref
}, rest));
});
var Label$1 = Label;
export { Label$1 as default, variants };