Add clear button to Combobox input

* It only shows up when there is text in the input
* Clicking it clears the text in the input
* It uses CharLimitedFieldset's classes
This commit is contained in:
Justin Edmund 2023-06-05 21:01:24 -07:00
parent 2908c33b2c
commit 121b75f63a
2 changed files with 42 additions and 6 deletions

View file

@ -72,6 +72,26 @@
padding: $unit;
width: 100%;
.Button {
background: none;
padding: ($unit * 0.75) $unit-half $unit-half;
display: none;
&:hover svg {
fill: var(--text-primary);
}
&.Visible {
display: block;
}
svg {
fill: var(--text-tertiary);
width: $unit-2x;
height: $unit-2x;
}
}
.Controls {
display: flex;
gap: $unit;

View file

@ -27,6 +27,7 @@ interface Props {
import Button from '~components/common/Button'
import ArrowIcon from '~public/icons/Arrow.svg'
import CrossIcon from '~public/icons/Cross.svg'
import './index.scss'
import classNames from 'classnames'
@ -130,6 +131,10 @@ const RaidCombobox = (props: Props) => {
setOpen(!open)
}
function clearSearch() {
setSearch('')
}
const linkClass = classNames({
wind: currentRaid && currentRaid.element == 1,
fire: currentRaid && currentRaid.element == 2,
@ -261,12 +266,23 @@ const RaidCombobox = (props: Props) => {
>
<Command className="Raid Combobox">
<div className="Header">
<div className="Bound Joined">
<CommandInput
className="Input Bound"
className="Input"
placeholder={t('search.placeholders.raid')}
value={search}
onValueChange={setSearch}
/>
<div
className={classNames({
Button: true,
Visible: search.length > 0,
})}
onClick={clearSearch}
>
<CrossIcon />
</div>
</div>
{!search ? (
<div className="Controls">
<SegmentedControl blended={true}>