complete first iteration
This commit is contained in:
@@ -5,6 +5,8 @@ import { serializeInterface, parseInterface } from './lib/xml';
|
||||
import SignalTree from './SignalTree';
|
||||
import EditCanvas, { genWidgetId, DEFAULT_SIZES } from './EditCanvas';
|
||||
import PropertiesPane from './PropertiesPane';
|
||||
import ContextualHelp from './ContextualHelp';
|
||||
import HelpModal from './HelpModal';
|
||||
|
||||
interface Props {
|
||||
initial: Interface | null;
|
||||
@@ -79,6 +81,9 @@ export default function EditMode({ initial, onDone }: Props) {
|
||||
const [snapGrid, setSnapGrid] = useState(10);
|
||||
const [showSnapGrid, setShowSnapGrid] = useState(true);
|
||||
const [showInsertMenu, setShowInsertMenu] = useState(false);
|
||||
const [showHelp, setShowHelp] = useState(false);
|
||||
const [helpSection, setHelpSection] = useState('edit');
|
||||
function openHelp(section = 'edit') { setHelpSection(section); setShowHelp(true); }
|
||||
|
||||
// Undo / redo
|
||||
const undoStack = useRef<Widget[][]>([]);
|
||||
@@ -232,6 +237,7 @@ export default function EditMode({ initial, onDone }: Props) {
|
||||
function handleKeyDown(e: KeyboardEvent) {
|
||||
const target = e.target as Element;
|
||||
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') return;
|
||||
if (e.key === '?') { openHelp('edit'); return; }
|
||||
|
||||
if ((e.key === 'Delete' || e.key === 'Backspace') && selectedIds.length > 0) {
|
||||
pushUndo();
|
||||
@@ -338,6 +344,8 @@ export default function EditMode({ initial, onDone }: Props) {
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
<ContextualHelp mode="edit" onOpenManual={openHelp} />
|
||||
<button class="icon-btn help-manual-btn" onClick={() => openHelp('edit')} title="Open user manual">📖</button>
|
||||
<button class="toolbar-btn" onClick={handleImport}>Import</button>
|
||||
<button class="toolbar-btn" onClick={handleExport}>Export</button>
|
||||
<button class="toolbar-btn toolbar-btn-primary" onClick={handleSave} disabled={saving}>
|
||||
@@ -365,6 +373,10 @@ export default function EditMode({ initial, onDone }: Props) {
|
||||
onIfaceChange={handleIfaceChange}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{showHelp && (
|
||||
<HelpModal initialSection={helpSection} onClose={() => setShowHelp(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import { wsClient } from './lib/ws';
|
||||
import { parseInterface } from './lib/xml';
|
||||
import type { Interface } from './lib/types';
|
||||
import { useEffect } from 'preact/hooks';
|
||||
import ContextualHelp from './ContextualHelp';
|
||||
import HelpModal from './HelpModal';
|
||||
|
||||
interface Props {
|
||||
onEdit?: (iface?: Interface) => void;
|
||||
@@ -21,6 +23,10 @@ export default function ViewMode({ onEdit }: Props) {
|
||||
const [currentInterface, setCurrentInterface] = useState<Interface | null>(null);
|
||||
const [parseError, setParseError] = useState<string | null>(null);
|
||||
const [wsStatus, setWsStatus] = useState('connecting');
|
||||
const [showHelp, setShowHelp] = useState(false);
|
||||
const [helpSection, setHelpSection] = useState('start');
|
||||
|
||||
function openHelp(section = 'start') { setHelpSection(section); setShowHelp(true); }
|
||||
|
||||
// Historical time range — null means live
|
||||
const now = useMemo(() => new Date(), []);
|
||||
@@ -117,6 +123,14 @@ export default function ViewMode({ onEdit }: Props) {
|
||||
<span class="status-dot"></span>
|
||||
{wsStatus}
|
||||
</div>
|
||||
<ContextualHelp mode="view" onOpenManual={openHelp} />
|
||||
<button
|
||||
class="icon-btn help-manual-btn"
|
||||
onClick={() => openHelp('start')}
|
||||
title="Open user manual"
|
||||
>
|
||||
📖
|
||||
</button>
|
||||
<button
|
||||
class="btn-edit"
|
||||
onClick={() => onEdit?.(currentInterface ?? undefined)}
|
||||
@@ -143,6 +157,10 @@ export default function ViewMode({ onEdit }: Props) {
|
||||
/>
|
||||
<Canvas iface={currentInterface} onNavigate={handleNavigate} timeRange={timeRange} />
|
||||
</div>
|
||||
|
||||
{showHelp && (
|
||||
<HelpModal initialSection={helpSection} onClose={() => setShowHelp(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1585,3 +1585,384 @@ body {
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
/* ── Help Manual button (📖) in toolbar ─────────────────────────────────── */
|
||||
|
||||
.help-manual-btn {
|
||||
font-size: 1rem;
|
||||
line-height: 1;
|
||||
padding: 0.15rem 0.35rem;
|
||||
opacity: 0.8;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
.help-manual-btn:hover { opacity: 1; }
|
||||
|
||||
/* ── Help Modal ──────────────────────────────────────────────────────────── */
|
||||
|
||||
.help-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 500;
|
||||
}
|
||||
|
||||
.help-modal {
|
||||
background: #1a1f2e;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 10px;
|
||||
width: min(960px, 96vw);
|
||||
height: min(720px, 94vh);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.help-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-bottom: 1px solid #2d3748;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.help-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
.help-close {
|
||||
font-size: 1rem;
|
||||
color: #64748b;
|
||||
}
|
||||
.help-close:hover { color: #e2e8f0; }
|
||||
|
||||
.help-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Sidebar navigation */
|
||||
.help-sidebar {
|
||||
width: 188px;
|
||||
min-width: 188px;
|
||||
border-right: 1px solid #2d3748;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0.5rem 0;
|
||||
overflow-y: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.help-nav-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 0.55rem 1.1rem;
|
||||
font-size: 0.85rem;
|
||||
color: #94a3b8;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
.help-nav-item:hover { background: #0f1117; color: #cbd5e1; }
|
||||
.help-nav-item.active {
|
||||
color: #4a9eff;
|
||||
background: rgba(74, 158, 255, 0.08);
|
||||
border-left-color: #4a9eff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Content area */
|
||||
.help-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem 2rem 2rem;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.65;
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
.help-h2 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
color: #e2e8f0;
|
||||
margin-bottom: 1rem;
|
||||
padding-bottom: 0.5rem;
|
||||
border-bottom: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
.help-h3 {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: #e2e8f0;
|
||||
margin: 1.2rem 0 0.4rem;
|
||||
}
|
||||
|
||||
.help-lead {
|
||||
color: #94a3b8;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.help-list {
|
||||
padding-left: 1.2rem;
|
||||
margin: 0.4rem 0 0.8rem;
|
||||
}
|
||||
.help-list li { margin-bottom: 0.3rem; }
|
||||
|
||||
/* SVG diagrams */
|
||||
.help-diagram {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 580px;
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
margin: 1rem 0 0.25rem;
|
||||
border: 1px solid #2d3748;
|
||||
}
|
||||
.help-diagram-narrow {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.help-caption {
|
||||
font-size: 0.75rem;
|
||||
color: #64748b;
|
||||
margin-bottom: 1rem;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* Getting started cards */
|
||||
.help-cards {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
margin: 0.75rem 0 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.help-card {
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
background: #0f1117;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 6px;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.help-card-title {
|
||||
font-weight: 600;
|
||||
color: #e2e8f0;
|
||||
margin-bottom: 0.35rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* Widget reference table */
|
||||
.help-widget-table {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
margin: 0.75rem 0;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.help-widget-row {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
border-bottom: 1px solid #1e2535;
|
||||
}
|
||||
.help-widget-row:last-child { border-bottom: none; }
|
||||
.help-widget-row:nth-child(odd) { background: #0f1117; }
|
||||
|
||||
.help-widget-name {
|
||||
font-weight: 600;
|
||||
color: #4a9eff;
|
||||
min-width: 120px;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.help-widget-desc {
|
||||
color: #94a3b8;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
/* Two-column layout for signals section */
|
||||
.help-two-col {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.help-two-col > div:first-child { flex: 1; }
|
||||
|
||||
/* Shortcut table */
|
||||
.help-shortcut-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 0.75rem 0;
|
||||
font-size: 0.83rem;
|
||||
}
|
||||
|
||||
.help-shortcut-table th {
|
||||
text-align: left;
|
||||
padding: 0.4rem 0.75rem;
|
||||
background: #0f1117;
|
||||
color: #64748b;
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid #2d3748;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.help-shortcut-table td {
|
||||
padding: 0.4rem 0.75rem;
|
||||
border-bottom: 1px solid #1e2535;
|
||||
color: #cbd5e1;
|
||||
}
|
||||
|
||||
.help-shortcut-table tr:last-child td { border-bottom: none; }
|
||||
.help-shortcut-table tr:nth-child(odd) td { background: rgba(15, 17, 23, 0.5); }
|
||||
|
||||
.help-kbd {
|
||||
display: inline-block;
|
||||
background: #0f1117;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 4px;
|
||||
padding: 0.1rem 0.4rem;
|
||||
font-family: monospace;
|
||||
font-size: 0.8rem;
|
||||
color: #e2e8f0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
.help-content code {
|
||||
background: #0f1117;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 3px;
|
||||
padding: 0.1rem 0.35rem;
|
||||
font-size: 0.82rem;
|
||||
font-family: monospace;
|
||||
color: #4a9eff;
|
||||
}
|
||||
|
||||
/* Config block */
|
||||
.help-pre {
|
||||
background: #0f1117;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 6px;
|
||||
padding: 0.75rem 1rem;
|
||||
font-family: monospace;
|
||||
font-size: 0.8rem;
|
||||
color: #94a3b8;
|
||||
white-space: pre-wrap;
|
||||
margin: 0.75rem 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* kbd element in content */
|
||||
kbd {
|
||||
display: inline-block;
|
||||
background: #0f1117;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 3px;
|
||||
padding: 0 0.35rem;
|
||||
font-size: 0.8rem;
|
||||
font-family: monospace;
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
/* ── Contextual Help ─────────────────────────────────────────────────────── */
|
||||
|
||||
.ctx-help {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ctx-help-btn {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border-radius: 50%;
|
||||
border: 1.5px solid #4a5568;
|
||||
background: #1a2236;
|
||||
color: #94a3b8;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: border-color 0.15s, color 0.15s;
|
||||
flex-shrink: 0;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
}
|
||||
.ctx-help-btn:hover { border-color: #4a9eff; color: #4a9eff; }
|
||||
|
||||
.ctx-help-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 8px);
|
||||
right: 0;
|
||||
z-index: 400;
|
||||
background: #1a1f2e;
|
||||
border: 1px solid #2d3748;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
|
||||
width: 280px;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.ctx-help-tip {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.82rem;
|
||||
color: #cbd5e1;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.ctx-help-icon {
|
||||
font-size: 1rem;
|
||||
flex-shrink: 0;
|
||||
margin-top: 0.05rem;
|
||||
}
|
||||
|
||||
.ctx-help-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-top: 1px solid #2d3748;
|
||||
padding-top: 0.5rem;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.ctx-help-nav {
|
||||
font-size: 0.75rem;
|
||||
color: #64748b;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.ctx-help-nav:hover { color: #94a3b8; }
|
||||
|
||||
.ctx-help-link {
|
||||
font-size: 0.75rem;
|
||||
color: #4a9eff;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
.ctx-help-link:hover { text-decoration: underline; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user