Fix job accessory popover

This was actually easy, I guess I was just tired.
This commit is contained in:
Justin Edmund 2023-09-01 07:54:28 -07:00
parent 14ad468737
commit 37e9187945
6 changed files with 95 additions and 65 deletions

View file

@ -1,3 +1,59 @@
.popover {
animation: scaleIn $duration-zoom ease-out;
background: var(--dialog-bg);
border-radius: $card-corner;
border: 0.5px solid rgba(0, 0, 0, 0.18);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
outline: none;
padding: $unit;
transform-origin: var(--radix-popover-content-transform-origin);
width: var(--radix-popover-trigger-width);
z-index: 5;
@include breakpoint(phone) {
min-width: auto;
}
&.raid {
width: auto;
}
&.flush {
padding: 0;
}
}
.jobAccessory {
padding: $unit-2x;
min-width: 40vw;
max-width: 40vw;
max-height: 40vh;
overflow-y: auto;
overflow-x: none;
margin-left: $unit-2x;
h3 {
font-size: $font-regular;
font-weight: $medium;
margin: 0 0 $unit $unit;
}
&.readOnly {
min-width: inherit;
max-width: inherit;
}
@include breakpoint(tablet) {
width: initial;
max-width: initial;
}
@include breakpoint(phone) {
width: initial;
max-width: initial;
}
}
.arrow { .arrow {
fill: var(--dialog-bg); fill: var(--dialog-bg);
filter: drop-shadow(0px 1px 1px rgb(0 0 0 / 0.18)); filter: drop-shadow(0px 1px 1px rgb(0 0 0 / 0.18));

View file

@ -20,9 +20,13 @@ export const PopoverContent = React.forwardRef<HTMLDivElement, Props>(
{ children, ...props }: PropsWithChildren<Props>, { children, ...props }: PropsWithChildren<Props>,
forwardedRef forwardedRef
) { ) {
const classes = classnames(props.className, { const classes = classnames(
Popover: true, {
}) [styles.popover]: true,
},
props.className?.split(' ').map((a) => styles[a])
)
return ( return (
<PopoverPrimitive.Portal> <PopoverPrimitive.Portal>

View file

@ -1,4 +1,4 @@
.JobAccessoryItem { .item {
background: none; background: none;
border-radius: $input-corner; border-radius: $input-corner;
border: none; border: none;

View file

@ -18,7 +18,7 @@ const JobAccessoryItem = ({ accessory, selected }: Props) => {
return ( return (
<RadioGroup.Item <RadioGroup.Item
className="JobAccessoryItem" className={styles.item}
data-state={selected ? 'checked' : 'unchecked'} data-state={selected ? 'checked' : 'unchecked'}
value={accessory.id} value={accessory.id}
> >

View file

@ -1,33 +1,4 @@
.JobAccessory.Popover { .accessories {
padding: $unit-2x;
min-width: 40vw;
max-width: 40vw;
max-height: 40vh;
overflow-y: scroll;
margin-left: $unit-2x;
h3 {
font-size: $font-regular;
font-weight: $medium;
margin: 0 0 $unit $unit;
}
&.ReadOnly {
min-width: inherit;
max-width: inherit;
}
@include breakpoint(tablet) {
width: initial;
max-width: initial;
}
@include breakpoint(phone) {
width: initial;
max-width: initial;
}
.Accessories {
display: grid; display: grid;
gap: $unit; gap: $unit;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
@ -38,7 +9,7 @@
} }
} }
.EquippedAccessory { .equippedAccessory {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: $unit-2x; gap: $unit-2x;
@ -47,7 +18,7 @@
margin: 0; margin: 0;
} }
.Accessory { .accessory {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: $unit; gap: $unit;
@ -64,4 +35,3 @@
} }
} }
} }
}

View file

@ -49,8 +49,8 @@ const JobAccessoryPopover = ({
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const classes = classNames({ const classes = classNames({
JobAccessory: true, jobAccessory: true,
ReadOnly: !editable, readOnly: !editable,
}) })
// Hooks // Hooks
@ -91,7 +91,7 @@ const JobAccessoryPopover = ({
)} )}
</h3> </h3>
<RadioGroup.Root <RadioGroup.Root
className="Accessories" className={styles.accessories}
onValueChange={handleAccessorySelected} onValueChange={handleAccessorySelected}
> >
{accessories.map((accessory) => ( {accessories.map((accessory) => (
@ -110,14 +110,14 @@ const JobAccessoryPopover = ({
) )
const readOnly = currentAccessory ? ( const readOnly = currentAccessory ? (
<div className="EquippedAccessory"> <div className={styles.equippedAccessory}>
<h3> <h3>
{t('equipped')}{' '} {t('equipped')}{' '}
{job.accessory_type === 1 {job.accessory_type === 1
? `${t('accessories.paladin')}s` ? `${t('accessories.paladin')}s`
: t('accessories.manadiver')} : t('accessories.manadiver')}
</h3> </h3>
<div className="Accessory"> <div className={styles.accessory}>
<img <img
alt={currentAccessory.name[locale]} alt={currentAccessory.name[locale]}
src={`${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/accessory-grid/${currentAccessory.granblue_id}.jpg`} src={`${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/accessory-grid/${currentAccessory.granblue_id}.jpg`}