Skip to content

Commit a1ba385

Browse files
feat: make opponent & move count & drill count global for all selected openings
1 parent 64a221f commit a1ba385

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

src/components/Openings/OpeningSelectionModal.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ const PreviewPanel: React.FC<{
478478
<p className="text-xs text-secondary">Configure your drill settings</p>
479479
</div>
480480

481-
<div className="flex flex-1 flex-col gap-4 overflow-hidden p-2 md:p-3">
481+
<div className="flex flex-1 flex-col gap-4 overflow-hidden p-3 md:p-4">
482482
<div className="flex flex-col gap-1">
483483
<p className="text-sm font-medium md:text-base">
484484
{previewOpening.name}
@@ -629,10 +629,10 @@ const SelectedPanel: React.FC<{
629629
}
630630
}}
631631
onClick={() => removeSelection(selection.id)}
632-
className="group flex cursor-pointer items-center justify-between border-b border-white/5 p-3 transition-colors hover:bg-human-2/10 md:p-4"
632+
className="group flex cursor-pointer items-center justify-between border-b border-white/5 p-3 transition-colors hover:bg-human-2/10 md:px-4"
633633
>
634634
<div className="min-w-0 flex-1">
635-
<div className="flex items-center gap-3">
635+
<div className="flex items-center gap-2">
636636
<div className="relative h-4 w-4 flex-shrink-0 md:h-5 md:w-5">
637637
<Image
638638
src={
@@ -644,22 +644,15 @@ const SelectedPanel: React.FC<{
644644
alt={`${selection.playerColor} king`}
645645
/>
646646
</div>
647-
<div className="flex min-w-0 flex-1 flex-col">
647+
<div className="flex min-w-0 flex-1 flex-row items-center gap-2">
648648
<span className="truncate text-xs font-medium text-primary md:text-sm">
649649
{selection.opening.name}
650650
</span>
651-
<div className="flex items-center gap-1 text-xs text-secondary">
652-
{selection.variation && (
653-
<span className="truncate">
654-
{selection.variation.name}
655-
</span>
656-
)}
657-
<span>
658-
v. Maia{' '}
659-
{selection.maiaVersion.replace('maia_kdd_', '')}
651+
{selection.variation && (
652+
<span className="mt-1 truncate text-xxs text-secondary">
653+
{selection.variation.name}
660654
</span>
661-
<span>{selection.targetMoveNumber} moves</span>
662-
</div>
655+
)}
663656
</div>
664657
</div>
665658
</div>
@@ -708,14 +701,14 @@ const SelectedPanel: React.FC<{
708701
<input
709702
type="range"
710703
min="5"
711-
max="30"
704+
max="20"
712705
value={targetMoveNumber}
713706
onChange={(e) => setTargetMoveNumber(parseInt(e.target.value) || 10)}
714707
className="w-full accent-human-4"
715708
/>
716709
<div className="mt-1 flex justify-between text-xs text-secondary">
717710
<span>5</span>
718-
<span>30</span>
711+
<span>20</span>
719712
</div>
720713
</div>
721714

@@ -727,14 +720,14 @@ const SelectedPanel: React.FC<{
727720
<input
728721
type="range"
729722
min="1"
730-
max="50"
723+
max="20"
731724
value={drillCount}
732725
onChange={(e) => setDrillCount(parseInt(e.target.value) || 5)}
733726
className="w-full accent-human-4"
734727
/>
735728
<div className="mt-1 flex justify-between text-xs text-secondary">
736729
<span>1</span>
737-
<span>50</span>
730+
<span>20</span>
738731
</div>
739732
<p className="mt-1 text-xs text-secondary">
740733
{drillCount <= selections.length
@@ -814,6 +807,17 @@ export const OpeningSelectionModal: React.FC<Props> = ({
814807
}
815808
}, [hasTrackedModalOpen, initialSelections.length])
816809

810+
// Update the ID to reflect the new settings
811+
useEffect(() => {
812+
setSelections((prevSelections) =>
813+
prevSelections.map((selection) => ({
814+
...selection,
815+
maiaVersion: selectedMaiaVersion.id,
816+
targetMoveNumber,
817+
})),
818+
)
819+
}, [selectedMaiaVersion.id, targetMoveNumber])
820+
817821
const handleStartTour = () => {
818822
startTour(tourConfigs.openingDrill.id, tourConfigs.openingDrill.steps, true)
819823
}

0 commit comments

Comments
 (0)