Skip to content

Commit a27916a

Browse files
committed
Add badge style component
1 parent 19e41d6 commit a27916a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/components/badge.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react'
2+
3+
export default function Badge({ name, color, children }) {
4+
return (
5+
<span className='badge'>
6+
{children}
7+
{name}
8+
<style jsx>
9+
{`
10+
.badge {
11+
font-size: 0.75rem;
12+
background: ${color};
13+
display: inline-flex;
14+
align-items: center;
15+
padding: 0.125rem 0.5rem;
16+
border-radius: 999px;
17+
font-size: 12px;
18+
line-height: 1.5;
19+
white-space: nowrap;
20+
margin-right: 4px;
21+
}
22+
`}
23+
</style>
24+
</span>
25+
)
26+
}

src/components/tables/users.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import T from 'prop-types'
22
import Table from './table'
3+
import Badge from '../badge'
34
import { useFetchList } from '../../hooks/use-fetch-list'
45
import { useState } from 'react'
56
import Pagination from '../pagination'
@@ -38,7 +39,11 @@ function UsersTable({ type, orgId, onRowClick, isSearchable }) {
3839
render: ({ badges }) => (
3940
<>
4041
{badges?.length > 0 &&
41-
badges.map((b) => <div key={b.id}>{b.name}</div>)}
42+
badges.map((b) => (
43+
<Badge color={b.color} key={b.id}>
44+
{b.name}
45+
</Badge>
46+
))}
4247
</>
4348
),
4449
},

0 commit comments

Comments
 (0)