From 1bb24d2620c7ca794b98df21a4638a9512520f00 Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Mon, 11 Aug 2025 10:04:46 +0000
Subject: [PATCH] Add success state to playground
Update the Rules of Inference Playground to display a light green background and freeze interactions upon successful completion of a proof. This state allows users to select a new puzzle.
---
src/components/RulesOfInferencePlayground.tsx | 35 +++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/src/components/RulesOfInferencePlayground.tsx b/src/components/RulesOfInferencePlayground.tsx
index e378764..6df2e2f 100644
--- a/src/components/RulesOfInferencePlayground.tsx
+++ b/src/components/RulesOfInferencePlayground.tsx
@@ -88,13 +88,17 @@ function parseDragData(e: React.DragEvent): { type: DragType; value: string } |
}
}
-function DraggableChip({ label, onDragStart: handle }: { label: string; onDragStart: (e: React.DragEvent) => void }) {
+function DraggableChip({ label, onDragStart: handle, disabled = false }: { label: string; onDragStart: (e: React.DragEvent) => void; disabled?: boolean }) {
return (
@@ -222,6 +226,7 @@ export default function RulesOfInferencePlayground() {
}
function handlePremiseDrop(e: React.DragEvent) {
+ if (reachedTarget) return; // Freeze interactions when solved
const data = parseDragData(e);
if (!data) return;
if (data.type === "premise" || data.type === "statement") {
@@ -233,6 +238,7 @@ export default function RulesOfInferencePlayground() {
}
function handleRuleDrop(e: React.DragEvent) {
+ if (reachedTarget) return; // Freeze interactions when solved
const data = parseDragData(e);
if (!data) return;
if (data.type === "rule") setActiveRule(data.value);
@@ -248,7 +254,7 @@ export default function RulesOfInferencePlayground() {
setActivePremises((prev) => prev.filter((x) => x !== p));
return (
-
+
{/* Top controls */}
@@ -290,13 +296,14 @@ export default function RulesOfInferencePlayground() {
Derived so far
- {steps.map((s, idx) => (
- onDragStart(e, "statement", s.result)}
- />
- ))}
+ {steps.map((s, idx) => (
+ onDragStart(e, "statement", s.result)}
+ disabled={reachedTarget}
+ />
+ ))}
)}
@@ -308,7 +315,7 @@ export default function RulesOfInferencePlayground() {
{example.rules.map((r) => (
-
onDragStart(e, "rule", r.id)} />
+ onDragStart(e, "rule", r.id)} disabled={reachedTarget} />
{r.help && {r.help}
}
))}