Display icons in dropdown and trigger
This commit is contained in:
parent
d562de8b39
commit
fefcd91290
5 changed files with 29 additions and 1 deletions
|
|
@ -91,7 +91,12 @@ const JobDropdown = React.forwardRef<HTMLSelectElement, Props>(
|
||||||
.sort((a, b) => a.order - b.order)
|
.sort((a, b) => a.order - b.order)
|
||||||
.map((item, i) => {
|
.map((item, i) => {
|
||||||
return (
|
return (
|
||||||
<SelectItem key={i} value={item.id}>
|
<SelectItem
|
||||||
|
key={i}
|
||||||
|
value={item.id}
|
||||||
|
altText={item.name[locale]}
|
||||||
|
iconSrc={`/images/job-icons/${item.granblue_id}.png`}
|
||||||
|
>
|
||||||
{item.name[locale]}
|
{item.name[locale]}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
)
|
)
|
||||||
|
|
@ -109,6 +114,10 @@ const JobDropdown = React.forwardRef<HTMLSelectElement, Props>(
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
value={currentJob ? currentJob.id : 'no-job'}
|
value={currentJob ? currentJob.id : 'no-job'}
|
||||||
|
altText={currentJob ? currentJob.name[locale] : ''}
|
||||||
|
iconSrc={
|
||||||
|
currentJob ? `/images/job-icons/${currentJob.granblue_id}.png` : ''
|
||||||
|
}
|
||||||
open={open}
|
open={open}
|
||||||
onClick={openJobSelect}
|
onClick={openJobSelect}
|
||||||
onOpenChange={() => setOpen(!open)}
|
onOpenChange={() => setOpen(!open)}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
border-radius: $input-corner;
|
border-radius: $input-corner;
|
||||||
border: none;
|
border: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: $unit;
|
||||||
padding: $unit-2x $unit-2x;
|
padding: $unit-2x $unit-2x;
|
||||||
|
|
||||||
&.modal {
|
&.modal {
|
||||||
|
|
@ -56,6 +57,11 @@
|
||||||
min-width: $unit * 30;
|
min-width: $unit * 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: $unit-4x;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.SelectIcon {
|
.SelectIcon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ interface Props
|
||||||
React.SelectHTMLAttributes<HTMLSelectElement>,
|
React.SelectHTMLAttributes<HTMLSelectElement>,
|
||||||
HTMLSelectElement
|
HTMLSelectElement
|
||||||
> {
|
> {
|
||||||
|
altText?: string
|
||||||
|
iconSrc?: string
|
||||||
open: boolean
|
open: boolean
|
||||||
trigger?: React.ReactNode
|
trigger?: React.ReactNode
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
|
|
@ -79,6 +81,7 @@ const Select = React.forwardRef<HTMLButtonElement, Props>(function Select(
|
||||||
placeholder={props.placeholder}
|
placeholder={props.placeholder}
|
||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
>
|
>
|
||||||
|
{props.iconSrc ? <img alt={props.altText} src={props.iconSrc} /> : ''}
|
||||||
<RadixSelect.Value placeholder={props.placeholder} />
|
<RadixSelect.Value placeholder={props.placeholder} />
|
||||||
{!props.disabled ? (
|
{!props.disabled ? (
|
||||||
<RadixSelect.Icon className="SelectIcon">
|
<RadixSelect.Icon className="SelectIcon">
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
border-radius: $item-corner;
|
border-radius: $item-corner;
|
||||||
border: 2px solid transparent;
|
border: 2px solid transparent;
|
||||||
color: var(--text-tertiary);
|
color: var(--text-tertiary);
|
||||||
|
display: flex;
|
||||||
|
gap: $unit;
|
||||||
font-size: $font-regular;
|
font-size: $font-regular;
|
||||||
padding: ($unit * 1.5) $unit-2x;
|
padding: ($unit * 1.5) $unit-2x;
|
||||||
|
|
||||||
|
|
@ -24,4 +26,9 @@
|
||||||
&:last-child {
|
&:last-child {
|
||||||
margin-bottom: $unit;
|
margin-bottom: $unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: $unit-4x;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import classNames from 'classnames'
|
||||||
|
|
||||||
interface Props extends ComponentProps<'div'> {
|
interface Props extends ComponentProps<'div'> {
|
||||||
value: string | number
|
value: string | number
|
||||||
|
iconSrc?: string
|
||||||
|
altText?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const SelectItem = React.forwardRef<HTMLDivElement, Props>(function selectItem(
|
const SelectItem = React.forwardRef<HTMLDivElement, Props>(function selectItem(
|
||||||
|
|
@ -19,6 +21,7 @@ const SelectItem = React.forwardRef<HTMLDivElement, Props>(function selectItem(
|
||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
value={`${props.value}`}
|
value={`${props.value}`}
|
||||||
>
|
>
|
||||||
|
{props.iconSrc ? <img alt={props.altText} src={props.iconSrc} /> : ''}
|
||||||
<Select.ItemText>{children}</Select.ItemText>
|
<Select.ItemText>{children}</Select.ItemText>
|
||||||
</Select.Item>
|
</Select.Item>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue