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:
parent
2908c33b2c
commit
121b75f63a
2 changed files with 42 additions and 6 deletions
|
|
@ -72,6 +72,26 @@
|
||||||
padding: $unit;
|
padding: $unit;
|
||||||
width: 100%;
|
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 {
|
.Controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: $unit;
|
gap: $unit;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ interface Props {
|
||||||
|
|
||||||
import Button from '~components/common/Button'
|
import Button from '~components/common/Button'
|
||||||
import ArrowIcon from '~public/icons/Arrow.svg'
|
import ArrowIcon from '~public/icons/Arrow.svg'
|
||||||
|
import CrossIcon from '~public/icons/Cross.svg'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
|
|
@ -130,6 +131,10 @@ const RaidCombobox = (props: Props) => {
|
||||||
setOpen(!open)
|
setOpen(!open)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearSearch() {
|
||||||
|
setSearch('')
|
||||||
|
}
|
||||||
|
|
||||||
const linkClass = classNames({
|
const linkClass = classNames({
|
||||||
wind: currentRaid && currentRaid.element == 1,
|
wind: currentRaid && currentRaid.element == 1,
|
||||||
fire: currentRaid && currentRaid.element == 2,
|
fire: currentRaid && currentRaid.element == 2,
|
||||||
|
|
@ -261,12 +266,23 @@ const RaidCombobox = (props: Props) => {
|
||||||
>
|
>
|
||||||
<Command className="Raid Combobox">
|
<Command className="Raid Combobox">
|
||||||
<div className="Header">
|
<div className="Header">
|
||||||
<CommandInput
|
<div className="Bound Joined">
|
||||||
className="Input Bound"
|
<CommandInput
|
||||||
placeholder={t('search.placeholders.raid')}
|
className="Input"
|
||||||
value={search}
|
placeholder={t('search.placeholders.raid')}
|
||||||
onValueChange={setSearch}
|
value={search}
|
||||||
/>
|
onValueChange={setSearch}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className={classNames({
|
||||||
|
Button: true,
|
||||||
|
Visible: search.length > 0,
|
||||||
|
})}
|
||||||
|
onClick={clearSearch}
|
||||||
|
>
|
||||||
|
<CrossIcon />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{!search ? (
|
{!search ? (
|
||||||
<div className="Controls">
|
<div className="Controls">
|
||||||
<SegmentedControl blended={true}>
|
<SegmentedControl blended={true}>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue