Update job-related components

This commit is contained in:
Justin Edmund 2023-06-30 14:03:54 -07:00
parent ee9b95bace
commit 2f3fdd36c7
8 changed files with 69 additions and 62 deletions

View file

@ -1,3 +0,0 @@
.Job.SelectTrigger {
margin-bottom: $unit;
}

View file

@ -10,8 +10,6 @@ import SelectGroup from '~components/common/SelectGroup'
import { appState } from '~utils/appState' import { appState } from '~utils/appState'
import { jobGroups } from '~data/jobGroups' import { jobGroups } from '~data/jobGroups'
import styles from './index.module.scss'
// Props // Props
interface Props { interface Props {
currentJob?: string currentJob?: string
@ -94,8 +92,12 @@ const JobDropdown = React.forwardRef<HTMLSelectElement, Props>(
<SelectItem <SelectItem
key={i} key={i}
value={item.id} value={item.id}
altText={item.name[locale]} icon={{
iconSrc={`${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/job-icons/${item.granblue_id}.png`} alt: item.name[locale],
src: [
`${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/job-icons/${item.granblue_id}.png`,
],
}}
> >
{item.name[locale]} {item.name[locale]}
</SelectItem> </SelectItem>
@ -114,18 +116,20 @@ 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] : ''} icon={{
iconSrc={ alt: currentJob ? currentJob.name[locale] : '',
currentJob src: currentJob
? `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/job-icons/${currentJob.granblue_id}.png` ? `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/job-icons/${currentJob.granblue_id}.png`
: '' : '',
} }}
open={open} open={open}
onClick={openJobSelect} onClick={openJobSelect}
onOpenChange={() => setOpen(!open)} onOpenChange={() => setOpen(!open)}
onValueChange={handleChange} onValueChange={handleChange}
className="Job" className="job"
triggerClass="Job" trigger={{
className: 'job',
}}
overlayVisible={false} overlayVisible={false}
> >
<SelectItem key={-1} value="no-job"> <SelectItem key={-1} value="no-job">

View file

@ -49,29 +49,6 @@
z-index: 2; z-index: 2;
} }
.JobAccessory.Button {
align-items: center;
border-radius: 99px;
justify-content: center;
position: relative;
padding: $unit * 1.5;
top: $unit;
left: $unit;
height: auto;
z-index: 10;
&:hover .Accessory svg,
&.Selected .Accessory svg {
fill: var(--button-text-hover);
}
.Accessory svg {
fill: var(--button-text);
width: $unit-3x;
height: auto;
}
}
.overlay { .overlay {
backdrop-filter: blur(5px) saturate(100%) brightness(80%) opacity(1); backdrop-filter: blur(5px) saturate(100%) brightness(80%) opacity(1);
background: none; background: none;

View file

@ -54,8 +54,8 @@ const JobImage = ({
const image = <img alt={job?.name[locale]} src={imageUrl()} /> const image = <img alt={job?.name[locale]} src={imageUrl()} />
const classes = classNames({ const classes = classNames({
JobAccessory: true, jobAccessory: true,
Selected: open, selected: open,
}) })
function handleAccessoryButtonClicked() { function handleAccessoryButtonClicked() {
@ -78,6 +78,7 @@ const JobImage = ({
leftAccessoryIcon={icon} leftAccessoryIcon={icon}
className={classes} className={classes}
onClick={handleAccessoryButtonClicked} onClick={handleAccessoryButtonClicked}
size="icon"
ref={buttonRef} ref={buttonRef}
/> />
) )

View file

@ -25,6 +25,7 @@
.details { .details {
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
gap: $unit;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;

View file

@ -136,6 +136,7 @@ const JobSection = (props: Props) => {
skill={skills[index]} skill={skills[index]}
position={index} position={index}
editable={canEditSkill(skills[index])} editable={canEditSkill(skills[index])}
small={props.editable}
key={`skill-${index}`} key={`skill-${index}`}
hasJob={job != undefined && job.id != '-1'} hasJob={job != undefined && job.id != '-1'}
removeJobSkill={props.removeSkill} removeJobSkill={props.removeSkill}

View file

@ -17,28 +17,42 @@
align-items: stretch; align-items: stretch;
justify-content: space-between; justify-content: space-between;
&.editable .info:hover { &.editable {
background-color: var(--button-bg-hover); &:hover {
cursor: pointer;
.info {
&:hover {
background-color: var(--button-bg-hover);
}
& > img.editable,
& > div.placeholder.editable {
border: $hover-stroke;
box-shadow: $hover-shadow;
cursor: pointer;
transform: $scale-tall;
}
& p.placeholder {
color: var(--text-tertiary-hover);
}
& svg {
fill: var(--icon-secondary-hover);
}
}
}
} }
&.editable:hover { &.small {
cursor: pointer;
.info { .info {
& > img.editable, padding: $unit-half * 1.5;
& > div.placeholder.editable {
border: $hover-stroke;
box-shadow: $hover-shadow;
cursor: pointer;
transform: $scale-tall;
}
& p.placeholder { .placeholder.image,
color: var(--text-tertiary-hover); img {
} width: $unit-4x;
height: $unit-4x;
& svg {
fill: var(--icon-secondary-hover);
} }
} }
} }

View file

@ -21,16 +21,22 @@ interface Props extends React.ComponentPropsWithoutRef<'div'> {
skill?: JobSkill skill?: JobSkill
position: number position: number
editable: boolean editable: boolean
small?: boolean
hasJob: boolean hasJob: boolean
removeJobSkill: (position: number) => void removeJobSkill: (position: number) => void
} }
const defaultProps = {
small: false,
}
const JobSkillItem = React.forwardRef<HTMLDivElement, Props>( const JobSkillItem = React.forwardRef<HTMLDivElement, Props>(
function useJobSkillItem( function useJobSkillItem(
{ {
skill, skill,
position, position,
editable, editable,
small,
hasJob, hasJob,
removeJobSkill: sendJobSkillToRemove, removeJobSkill: sendJobSkillToRemove,
...props ...props
@ -53,13 +59,20 @@ const JobSkillItem = React.forwardRef<HTMLDivElement, Props>(
const classes = classNames({ const classes = classNames({
[styles.skill]: true, [styles.skill]: true,
[styles.editable]: editable, [styles.editable]: editable,
[styles.small]: small,
}) })
const imageClasses = classNames({ const imageClasses = classNames({
[styles.placeholder]: !skill, [styles.placeholder]: !skill,
[styles.image]: true,
[styles.editable]: editable && hasJob, [styles.editable]: editable && hasJob,
}) })
const labelClasses = classNames({
[styles.placeholder]: !skill,
[styles.text]: true,
})
const buttonClasses = classNames({ const buttonClasses = classNames({
[styles.clicked]: contextMenuOpen, [styles.clicked]: contextMenuOpen,
}) })
@ -79,6 +92,7 @@ const JobSkillItem = React.forwardRef<HTMLDivElement, Props>(
if (!open) setContextMenuOpen(false) if (!open) setContextMenuOpen(false)
} }
// Methods: Rendering
const skillImage = () => { const skillImage = () => {
let jsx: React.ReactNode let jsx: React.ReactNode
@ -107,11 +121,7 @@ const JobSkillItem = React.forwardRef<HTMLDivElement, Props>(
if (skill) { if (skill) {
jsx = <p>{skill.name[locale]}</p> jsx = <p>{skill.name[locale]}</p>
} else if (editable && hasJob) { } else if (editable && hasJob) {
jsx = ( jsx = <p className={labelClasses}>{t('job_skills.state.selectable')}</p>
<p className={styles.placeholder}>
{t('job_skills.state.selectable')}
</p>
)
} else { } else {
jsx = ( jsx = (
<p className={styles.placeholder}>{t('job_skills.state.no_skill')}</p> <p className={styles.placeholder}>{t('job_skills.state.no_skill')}</p>
@ -175,4 +185,6 @@ const JobSkillItem = React.forwardRef<HTMLDivElement, Props>(
} }
) )
JobSkillItem.defaultProps = defaultProps
export default JobSkillItem export default JobSkillItem