forked from bmcmahen/sancho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBadge.tsx
40 lines (38 loc) · 967 Bytes
/
Badge.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/** @jsx jsx */
import { jsx } from "@emotion/core";
import * as React from "react";
import { Text } from "./Text";
import PropTypes from "prop-types";
import { useTheme } from "./Theme/Providers";
/**
* Use a badge to indicate a count in a menu, such as unread messages.
*/
export const Badge: React.FunctionComponent<
React.HTMLAttributes<HTMLSpanElement>
> = ({ children, ...other }) => {
const theme = useTheme();
return (
<Text
variant="body"
component="span"
css={{
color: "white",
fontSize: `calc(${theme.fontSizes[0]} - 0.15rem)`,
fontWeight: "bold",
display: "inline-block",
borderRadius: "32px",
minWidth: "19px",
textAlign: "center",
textTransform: "uppercase",
padding: `1px 6px`,
background: theme.colors.palette.blue.base
}}
{...other}
>
{children}
</Text>
);
};
Badge.propTypes = {
children: PropTypes.node
};