feat: improved visuals and structure

ref: N25B-402
This commit is contained in:
JobvAlewijk
2025-12-30 20:56:05 +01:00
parent f0fe520ea0
commit b0a5e4770c
2 changed files with 293 additions and 80 deletions

View File

@@ -0,0 +1,167 @@
/* ---------- Layout ---------- */
.container {
height: 100%;
display: flex;
flex-direction: column;
background: #1e1e1e;
color: #f5f5f5;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: clamp(0.75rem, 2vw, 1.25rem);
background: #2a2a2a;
border-bottom: 1px solid #3a3a3a;
}
.header h2 {
font-size: clamp(1rem, 2.2vw, 1.4rem);
font-weight: 600;
}
.controls button {
margin-left: 0.5rem;
padding: 0.4rem 0.9rem;
border-radius: 6px;
border: none;
background: #111;
color: white;
cursor: pointer;
}
.controls button:disabled {
opacity: 0.4;
cursor: not-allowed;
}
/* ---------- Content ---------- */
.content {
flex: 1;
padding: 2%;
}
/* ---------- Grid ---------- */
.phaseGrid {
height: 100%;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-rows: repeat(2, minmax(0, 1fr));
gap: 2%;
}
/* ---------- Box ---------- */
.box {
display: flex;
flex-direction: column;
background: #ffffff;
color: #1e1e1e;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.boxHeader {
padding: 0.6rem 0.9rem;
background: linear-gradient(135deg, #dcdcdc, #e9e9e9);
font-style: italic;
font-weight: 500;
font-size: clamp(0.9rem, 1.5vw, 1.05rem);
border-bottom: 1px solid #cfcfcf;
}
.boxContent {
flex: 1;
padding: 0.8rem 1rem;
overflow-y: auto;
}
/* ---------- Lists ---------- */
.iconList {
list-style: none;
padding: 0;
margin: 0;
}
.iconList li {
display: flex;
align-items: center;
gap: 0.6rem;
margin-bottom: 0.5rem;
font-size: clamp(0.85rem, 1.3vw, 1rem);
}
.bulletList {
margin: 0;
padding-left: 1.2rem;
}
.bulletList li {
margin-bottom: 0.4rem;
}
/* ---------- Icons ---------- */
.successIcon,
.failIcon {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 1.5rem;
height: 1.5rem;
border-radius: 4px;
font-weight: bold;
color: white;
flex-shrink: 0;
}
.successIcon {
background: #3cb371;
}
.failIcon {
background: #e5533d;
}
/* ---------- Empty ---------- */
.empty {
opacity: 0.55;
font-style: italic;
font-size: 0.9rem;
}
/* ---------- Responsive ---------- */
@media (max-width: 900px) {
.phaseGrid {
grid-template-columns: 1fr;
grid-template-rows: repeat(4, minmax(0, 1fr));
gap: 1rem;
}
}
.leftControls {
display: flex;
align-items: center;
gap: 1rem;
}
.backButton {
background: transparent;
border: 1px solid #555;
color: #ddd;
padding: 0.35rem 0.75rem;
border-radius: 6px;
cursor: pointer;
}
.backButton:hover {
background: #333;
}

View File

@@ -1,7 +1,7 @@
import React from "react";
import styles from "../VisProgPage/VisProg.module.css";
import styles from "./SimpleProgram.module.css";
/* ---------- Types (mirrors backend / reducer output) ---------- */
/* ---------- Types ---------- */
type Norm = {
id: string;
@@ -40,95 +40,141 @@ type SimpleProgramProps = {
phases: Phase[];
};
/* ---------- Reusable UI ---------- */
/* ---------- Component ---------- */
type BoxProps = {
title: string;
children: React.ReactNode;
};
const Box: React.FC<BoxProps> = ({ title, children }) => (
<div className={styles.box}>
<div className={styles.boxHeader}>{title}</div>
<div className={styles.boxContent}>{children}</div>
</div>
);
/* ---------- Lists ---------- */
const GoalList: React.FC<{ goals: Goal[] }> = ({ goals }) => {
if (goals.length === 0) return <p className={styles.empty}>No goals defined.</p>;
/**
* SimpleProgram
*
* Read-only oversight view for a reduced program.
* Displays norms, goals, and triggers grouped per phase.
*/
const SimpleProgram: React.FC<SimpleProgramProps> = ({ phases }) => {
return (
<div className={`${styles.innerEditorContainer} round-lg border-lg`}>
<h2>Simple Program Overview</h2>
<button onClick={() => {
<ul className={styles.iconList}>
{goals.map((goal) => (
<li key={goal.id}>
<span
className={
goal.achieved ? styles.successIcon : styles.failIcon
}
>
{goal.achieved ? "✔" : "✖"}
</span>
{goal.description}
</li>
))}
</ul>
);
};
const TriggerList: React.FC<{ triggers: KeywordTrigger[] }> = ({
triggers,
}) => {
if (triggers.length === 0)
return <p className={styles.empty}>No triggers defined.</p>;
return (
<ul className={styles.iconList}>
{triggers.map((trigger) => (
<li key={trigger.id}>
<span className={styles.failIcon}></span>
{trigger.label}
</li>
))}
</ul>
);
};
const NormList: React.FC<{ norms: Norm[] }> = ({ norms }) => {
if (norms.length === 0) return <p className={styles.empty}>No norms defined.</p>;
return (
<ul className={styles.bulletList}>
{norms.map((norm) => (
<li key={norm.id}>{norm.norm}</li>
))}
</ul>
);
};
/* ---------- Phase Grid ---------- */
const PhaseGrid: React.FC<{ phase: Phase }> = ({ phase }) => {
return (
<div className={styles.phaseGrid}>
<Box title="Norms">
<NormList norms={phase.norms} />
</Box>
<Box title="Triggers">
<TriggerList triggers={phase.triggers} />
</Box>
<Box title="Goals">
<GoalList goals={phase.goals} />
</Box>
<Box title="Conditional Norms">
<p className={styles.empty}>No conditional norms defined.</p>
</Box>
</div>
);
};
/* ---------- Main Component ---------- */
const SimpleProgram: React.FC<SimpleProgramProps> = ({ phases }) => {
const [phaseIndex, setPhaseIndex] = React.useState(0);
const phase = phases[phaseIndex];
return (
<div className={styles.container}>
<header className={styles.header}>
<button
className={styles.backButton}
onClick={() => {
window.history.back();
setTimeout(() => {
window.history.forward();
}, 5); // small delay to ensure the back happens
} }> Back </button>
{phases.map((phase) => (
<div
key={phase.id}
style={{
border: "1px solid #505050",
borderRadius: "6px",
padding: "1rem",
marginBottom: "1rem",
}}
}, 5);
}}
>
<h2>{phase.label}</h2>
Back
</button>
<h2>
Phase {phaseIndex + 1} / {phases.length}: {phase.label}
</h2>
{/* Norms */}
<section>
<h3>Norms</h3>
{phase.norms.length === 0 ? (
<p>No norms defined.</p>
) : (
<ul>
{phase.norms.map((norm) => (
<li key={norm.id}>
<strong>{norm.label}</strong>: {norm.norm}
</li>
))}
</ul>
)}
</section>
<div className={styles.controls}>
<button
disabled={phaseIndex === 0}
onClick={() => setPhaseIndex((i) => i - 1)}
>
Prev
</button>
{/* Goals */}
<section>
<h3>Goals</h3>
{phase.goals.length === 0 ? (
<p>No goals defined.</p>
) : (
<ul>
{phase.goals.map((goal) => (
<li key={goal.id}>
<strong>{goal.label}</strong>: {goal.description}{" "}
<em>
[{goal.achieved ? "✔" : "❌"}]
</em>
</li>
))}
</ul>
)}
</section>
{/* Triggers */}
<section>
<h3>Triggers</h3>
{phase.triggers.length === 0 ? (
<p>No triggers defined.</p>
) : (
<ul>
{phase.triggers.map((trigger) => (
<li key={trigger.id}>
<strong>{trigger.label}</strong> ({trigger.type})
<ul>
{trigger.keywords.map((kw) => (
<li key={kw.id}>{kw.keyword}</li>
))}
</ul>
</li>
))}
</ul>
)}
</section>
<button
disabled={phaseIndex === phases.length - 1}
onClick={() => setPhaseIndex((i) => i + 1)}
>
Next
</button>
</div>
))}
</header>
<div className={styles.content}>
<PhaseGrid phase={phase} />
</div>
</div>
);
};