Skip to content

Commit a1ae8cc

Browse files
committed
Update badge style
1 parent a27916a commit a1ae8cc

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/components/badge.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
import React from 'react'
2+
import theme from '../styles/theme'
3+
4+
const hexToRgb = (hex) =>
5+
hex
6+
.replace(
7+
/^#?([a-f\d])([a-f\d])([a-f\d])$/i,
8+
(m, r, g, b) => '#' + r + r + g + g + b + b
9+
)
10+
.substring(1)
11+
.match(/.{2}/g)
12+
.map((x) => parseInt(x, 16))
13+
.join()
214

315
export default function Badge({ name, color, children }) {
416
return (
@@ -8,16 +20,27 @@ export default function Badge({ name, color, children }) {
820
<style jsx>
921
{`
1022
.badge {
11-
font-size: 0.75rem;
12-
background: ${color};
1323
display: inline-flex;
1424
align-items: center;
25+
font-size: 0.75rem;
26+
background: rgba(${hexToRgb(color)}, 0.125);
1527
padding: 0.125rem 0.5rem;
1628
border-radius: 999px;
29+
box-shadow: 0 0 0 1px ${theme.colors.primaryLite};
1730
font-size: 12px;
18-
line-height: 1.5;
1931
white-space: nowrap;
2032
margin-right: 4px;
33+
position: relative;
34+
overflow: hidden;
35+
}
36+
.badge::before {
37+
content: '';
38+
background-color: ${color};
39+
box-shadow: 0 0 0 1px ${theme.colors.primaryLite};
40+
height: 0.5rem;
41+
width: 0.5rem;
42+
border-radius: 999px;
43+
margin-right: 0.25rem;
2144
}
2245
`}
2346
</style>

0 commit comments

Comments
 (0)