Merge pull request #159 from jedmund/job-icons
Adds job icons to display and dropdown
This commit is contained in:
commit
bdb42bdba4
8 changed files with 52 additions and 6 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)}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,20 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
h3 {
|
.JobName {
|
||||||
font-size: $font-medium;
|
align-items: center;
|
||||||
font-weight: $medium;
|
display: flex;
|
||||||
|
gap: $unit-half;
|
||||||
padding: $unit 0 $unit * 2;
|
padding: $unit 0 $unit * 2;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: $font-medium;
|
||||||
|
font-weight: $medium;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: $unit-4x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,13 @@ const JobSection = (props: Props) => {
|
||||||
ref={selectRef}
|
ref={selectRef}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<h3>{party.job ? party.job.name[locale] : t('no_job')}</h3>
|
<div className="JobName">
|
||||||
|
<img
|
||||||
|
alt={party.job.name[locale]}
|
||||||
|
src={`/images/job-icons/${party.job.granblue_id}.png`}
|
||||||
|
/>
|
||||||
|
<h3>{party.job ? party.job.name[locale] : t('no_job')}</h3>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ul className="JobSkills">
|
<ul className="JobSkills">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
border-radius: $input-corner;
|
border-radius: $input-corner;
|
||||||
border: none;
|
border: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: $unit-2x $unit-2x;
|
gap: $unit;
|
||||||
|
padding: ($unit * 1.5) $unit-2x;
|
||||||
|
|
||||||
&.modal {
|
&.modal {
|
||||||
background-color: var(--select-modal-bg);
|
background-color: var(--select-modal-bg);
|
||||||
|
|
@ -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">
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
.SelectItem {
|
.SelectItem {
|
||||||
|
align-items: center;
|
||||||
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 +27,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>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
1
types/Job.d.ts
vendored
1
types/Job.d.ts
vendored
|
|
@ -1,5 +1,6 @@
|
||||||
interface Job {
|
interface Job {
|
||||||
id: string
|
id: string
|
||||||
|
granblue_id: string
|
||||||
row: string
|
row: string
|
||||||
ml: boolean
|
ml: boolean
|
||||||
order: number
|
order: number
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue