-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update styles for nih button and add single select list
- Loading branch information
1 parent
c4e173d
commit 6d5e5f5
Showing
5 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from "react" | ||
|
||
export interface SingleSelectProps { | ||
items: string[] | ||
className?: string | ||
label?: string | ||
selected: string | null | ||
setSelected: (selected: string | null) => void | ||
} | ||
|
||
export const SingleSelect = ({ | ||
items, | ||
className, | ||
label, | ||
selected, | ||
setSelected, | ||
}: SingleSelectProps) => { | ||
const handleSelect = (e: React.MouseEvent, value: string) => { | ||
e.stopPropagation() | ||
setSelected(value) | ||
} | ||
|
||
return ( | ||
<div className={className}> | ||
<ul className="single-select-list"> | ||
{items.map((item, index) => ( | ||
<li | ||
key={index} | ||
onClick={(e) => handleSelect(e, item)} | ||
className={selected === item ? "selected-item" : "item"} | ||
> | ||
{label ? label : item} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters