Skip to content

Commit 9159ba1

Browse files
committed
Create Chip.jsx
1 parent 977fb51 commit 9159ba1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/Chip.jsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import CloseIcon from './CloseIcon'
3+
4+
export default function Chip({ value, deleteAction }) {
5+
const showChipText = (opt) => {
6+
if (typeof opt.label === 'object') {
7+
return opt?.title || opt.value
8+
} else {
9+
return opt.label
10+
}
11+
}
12+
13+
return (
14+
<div clickable='true' className='msl-chip'>
15+
{showChipText(value)}
16+
<div
17+
role='button'
18+
clickable='true'
19+
aria-label='delete-value'
20+
onClick={deleteAction}
21+
onKeyPress={deleteAction}
22+
tabIndex='0'
23+
className='msl-btn msl-chip-delete msl-flx'
24+
>
25+
<CloseIcon />
26+
</div>
27+
<span />
28+
</div>
29+
)
30+
}

0 commit comments

Comments
 (0)