UNPKG

1.66 kBJavaScriptView Raw
1import "core-js/modules/es.object.assign.js";
2import "core-js/modules/es.string.bold.js";
3import React from 'react';
4import { styled } from '@storybook/theming';
5var BadgeWrapper = styled.div(function (_ref) {
6 var theme = _ref.theme;
7 return {
8 display: 'inline-block',
9 fontSize: 11,
10 lineHeight: '12px',
11 alignSelf: 'center',
12 padding: '4px 12px',
13 borderRadius: '3em',
14 fontWeight: theme.typography.weight.bold
15 };
16}, {
17 svg: {
18 height: 12,
19 width: 12,
20 marginRight: 4,
21 marginTop: -2,
22 path: {
23 fill: 'currentColor'
24 }
25 }
26}, function (_ref2) {
27 var theme = _ref2.theme,
28 status = _ref2.status;
29
30 switch (status) {
31 case 'critical':
32 {
33 return {
34 color: theme.color.critical,
35 background: theme.background.critical
36 };
37 }
38
39 case 'negative':
40 {
41 return {
42 color: theme.color.negative,
43 background: theme.background.negative
44 };
45 }
46
47 case 'warning':
48 {
49 return {
50 color: theme.color.warning,
51 background: theme.background.warning
52 };
53 }
54
55 case 'neutral':
56 {
57 return {
58 color: theme.color.dark,
59 background: theme.color.mediumlight
60 };
61 }
62
63 case 'positive':
64 {
65 return {
66 color: theme.color.positive,
67 background: theme.background.positive
68 };
69 }
70
71 default:
72 {
73 return {};
74 }
75 }
76});
77export var Badge = function Badge(_ref3) {
78 var props = Object.assign({}, _ref3);
79 return /*#__PURE__*/React.createElement(BadgeWrapper, props);
80};
81Badge.displayName = "Badge";
\No newline at end of file