Skip to content

Commit 7377cdf

Browse files
committed
docs: align solverforge-ui docs with shipped api
1 parent 026dd5f commit 7377cdf

File tree

5 files changed

+331
-251
lines changed

5 files changed

+331
-251
lines changed

content/en/docs/solverforge-ui/_index.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,85 @@
11
---
2-
title: "solverforge-ui"
3-
linkTitle: "solverforge-ui"
2+
title: 'solverforge-ui'
3+
linkTitle: 'solverforge-ui'
44
icon: fa-solid fa-display
55
weight: 21
66
description: >
7-
Embedded frontend components, scheduling views, backend adapters, and asset delivery for SolverForge web applications.
7+
Embedded frontend components, scheduling views, backend adapters, and asset
8+
serving for SolverForge web applications.
89
---
910

10-
`solverforge-ui` is SolverForge's UI toolkit for web-based scheduling and optimization applications. It ships ready-to-use frontend components, timeline and Gantt views, backend adapters, and static assets that integrate cleanly with Rust backends.
11+
`solverforge-ui` is SolverForge's frontend component library for
12+
constraint-optimization applications. It ships embedded assets, UI primitives,
13+
solver lifecycle helpers, and scheduling views without requiring npm in the
14+
runtime integration path.
1115

1216
## What It Provides
1317

14-
- **Drop-in frontend components** for headers, status bars, tabs, tables, modals, footers, and API guides
15-
- **Scheduling-focused views** with both timeline rail and Gantt primitives
16-
- **Backend adapters** for Axum, Tauri, and generic fetch-based APIs
17-
- **Static asset delivery** under `/sf/*`, including stable and versioned bundles
18-
- **Optional map module** (`SF.map.*`) for map-enabled pages
18+
- **Drop-in components** for headers, status bars, buttons, modals, tabs,
19+
tables, footers, API guides, and toasts
20+
- **Scheduling views** with both timeline rail and split-pane Gantt primitives
21+
- **Solver lifecycle helpers** via `SF.createBackend(...)` and
22+
`SF.createSolver(...)`
23+
- **Embedded asset serving** under `/sf/*` via
24+
`.merge(solverforge_ui::routes())`
25+
- **Stable and versioned bundles** for compatibility and cache-friendly
26+
production deployments
1927

2028
## Installation
2129

2230
```toml
2331
[dependencies]
24-
solverforge-ui = "0.3"
32+
solverforge-ui = "0.3.1"
2533
```
2634

2735
## Minimal Workflow
2836

2937
```rust
30-
use axum::{routing::get, Router};
31-
32-
fn app() -> Router {
33-
Router::new()
34-
.route("/", get(index))
35-
.merge(solverforge_ui::routes()) // serves /sf/*
36-
}
38+
let app = api::router(state).merge(solverforge_ui::routes()); // serves /sf/*
3739
```
3840

3941
```html
4042
<link rel="stylesheet" href="/sf/sf.css" />
4143
<script src="/sf/sf.js"></script>
4244
<script>
43-
const tabs = SF.createTabs(document.getElementById('tabs'));
44-
SF.createHeader(document.getElementById('header'), { title: 'SolverForge UI' });
45+
var tabs = SF.createTabs({
46+
tabs: [{ id: 'plan', content: '<div>Plan view</div>', active: true }],
47+
});
48+
document.body.appendChild(tabs.el);
49+
50+
var header = SF.createHeader({
51+
title: 'SolverForge UI',
52+
tabs: [{ id: 'plan', label: 'Plan', active: true }],
53+
onTabChange: function (id) {
54+
tabs.show(id);
55+
},
56+
});
57+
document.body.prepend(header);
4558
</script>
4659
```
4760

4861
## When To Use It
4962

50-
Use `solverforge-ui` when you want to deliver SolverForge-backed web interfaces quickly without building every UI primitive from scratch.
63+
Use `solverforge-ui` when you want to ship SolverForge-backed web interfaces
64+
quickly without rebuilding common UI primitives or bundling your own asset
65+
pipeline.
5166

5267
It is a strong fit for:
5368

5469
- operations dashboards and schedule review screens
5570
- solver result exploration and troubleshooting tools
56-
- embedded admin UIs in Axum- or Tauri-based applications
71+
- embedded admin UIs in Axum-, Tauri-, or static-asset-served applications
5772

5873
## Sections
5974

60-
- **[Getting Started](getting-started/)** — Wire up Axum routes, assets, and a minimal page
61-
- **[Components](components/)** — Base component API for common UI building blocks
62-
- **[Scheduling Views](scheduling-views/)** — Timeline rail and Gantt construction patterns
63-
- **[Integration & Assets](integration-assets/)** — Backend adapters, REST expectations, and asset strategy
75+
- **[Getting Started](getting-started/)** — Mount `/sf/*`, include the bundled
76+
assets, and wire the verified primitives into an app
77+
- **[Components](components/)** — Core factories, return values, and unsafe HTML
78+
opt-ins
79+
- **[Scheduling Views](scheduling-views/)** — Timeline rail and Gantt APIs with
80+
shipped examples
81+
- **[Integration & Assets](integration-assets/)** — Backend adapters, asset
82+
serving, cache behavior, and example route contracts
6483

6584
## External References
6685

Lines changed: 62 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,93 @@
11
---
22
title: Components
3-
description: Build pages with the shipped solverforge-ui base components and helpers.
3+
description: >
4+
Core factories, return values, and helpers in the shipped solverforge-ui
5+
surface.
46
weight: 2
57
---
68

79
# Components
810

9-
`solverforge-ui` ships a base component surface for common scheduling and operations UIs.
11+
`solverforge-ui` ships a verified component surface for common scheduling and
12+
operations UIs.
1013

11-
## Core Factory Functions
14+
## Core Factories
1215

13-
### Header
16+
The current public API documents these factories:
1417

15-
Use `SF.createHeader` for page titles, subtitle context, and top-level action areas.
18+
| Factory | Returns | Description |
19+
| ----------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
20+
| `SF.createHeader(config)` | `HTMLElement` | Sticky header with logo, title, nav tabs, and solve/stop/analyze actions |
21+
| `SF.createStatusBar(config)` | `{el, bindHeader, updateScore, setSolving, updateMoves, colorDotsFromAnalysis}` | Score display with constraint indicators |
22+
| `SF.createButton(config)` | `HTMLButtonElement` | Button with variant, size, icon, and shape modifiers |
23+
| `SF.createModal(config)` | `{el, body, open, close, setBody}` | Dialog with backdrop and header |
24+
| `SF.createTable(config)` | `HTMLElement` | Data table with headers and row click support |
25+
| `SF.createTabs(config)` | `{el, show}` | Tab panel container with instance-scoped tab switching |
26+
| `SF.createFooter(config)` | `HTMLElement` | Footer with links and version |
27+
| `SF.createApiGuide(config)` | `HTMLElement` | REST API documentation panel |
28+
| `SF.showToast(config)` | `void` | Auto-dismissing toast notification |
29+
| `SF.showError(title, detail)` | `void` | Error toast shorthand |
30+
| `SF.showTab(tabId, root?)` | `void` | Activate tab panels globally or within one root |
1631

17-
```js
18-
SF.createHeader(document.getElementById('header'), {
19-
title: 'Plant Schedule',
20-
subtitle: 'Line 3 · Morning Shift'
21-
});
22-
```
23-
24-
### Status Bar
25-
26-
Use `SF.createStatusBar` for run state, sync state, and user-facing health messages.
27-
28-
```js
29-
const status = SF.createStatusBar(document.getElementById('status'));
30-
status.setStatus('ok', 'Data loaded');
31-
```
32-
33-
### Button
34-
35-
Use `SF.createButton` for standardized button rendering and behavior.
36-
37-
```js
38-
const runBtn = SF.createButton({
39-
label: 'Run Solver',
40-
icon: 'fa-solid fa-play',
41-
onClick: () => runSolver()
42-
});
43-
document.getElementById('actions').append(runBtn);
44-
```
45-
46-
### Modal
47-
48-
Use `SF.createModal` for confirmations, detail panes, and error drill-downs.
49-
50-
```js
51-
const modal = SF.createModal({ title: 'Schedule Details' });
52-
modal.setBody('<p>Batch A starts at 08:00.</p>');
53-
modal.open();
54-
```
55-
56-
### Table
57-
58-
Use `SF.createTable` to render structured rows with consistent styles.
59-
60-
```js
61-
SF.createTable(document.getElementById('table'), {
62-
columns: ['Job', 'Line', 'Start', 'End'],
63-
rows: [
64-
['J-102', 'L3', '08:00', '09:20'],
65-
['J-103', 'L2', '08:15', '10:00']
66-
]
67-
});
68-
```
69-
70-
### Tabs
71-
72-
Use `SF.createTabs` for view switching and section organization.
32+
## Composition Example
7333

7434
```js
75-
SF.createTabs(document.getElementById('tabs'), {
35+
var tabs = SF.createTabs({
7636
tabs: [
77-
{ id: 'overview', label: 'Overview', active: true },
78-
{ id: 'timeline', label: 'Timeline' },
79-
{ id: 'analysis', label: 'Analysis' }
80-
]
37+
{ id: 'plan', content: '<div>Plan view</div>', active: true },
38+
{ id: 'gantt', content: '<div>Gantt view</div>' },
39+
],
8140
});
82-
```
83-
84-
### Footer
41+
document.body.appendChild(tabs.el);
8542

86-
Use `SF.createFooter` for build/version info and support links.
87-
88-
```js
89-
SF.createFooter(document.getElementById('footer'), {
90-
text: 'SolverForge UI · Production'
43+
var header = SF.createHeader({
44+
title: 'My Scheduler',
45+
subtitle: 'by SolverForge',
46+
tabs: [
47+
{ id: 'plan', label: 'Plan', active: true },
48+
{ id: 'gantt', label: 'Gantt' },
49+
],
50+
onTabChange: function (id) {
51+
tabs.show(id);
52+
},
9153
});
92-
```
93-
94-
### API Guide
95-
96-
Use `SF.createApiGuide` for built-in API reference panels in operator tools.
54+
document.body.prepend(header);
9755

98-
```js
99-
SF.createApiGuide(document.getElementById('api-guide'), {
100-
title: 'Scheduler API',
101-
sections: []
102-
});
56+
var statusBar = SF.createStatusBar({ header: header, constraints: [] });
57+
header.after(statusBar.el);
10358
```
10459

105-
### Toasts and Error Helpers
106-
107-
Use `SF.showToast` for transient notifications and `SF.showError` for consistent error presentation.
60+
## Unsafe HTML APIs
10861

109-
```js
110-
SF.showToast('Schedule queued');
62+
Default content is text-rendered. These opt-ins accept trusted HTML:
11163

112-
try {
113-
await doWork();
114-
} catch (err) {
115-
SF.showError(err);
116-
}
117-
```
64+
| Factory | Unsafe HTML field |
65+
| ------------------------- | ------------------------------------------------------ |
66+
| `SF.el(tag, attrs, ...)` | `unsafeHtml` |
67+
| `SF.createModal(config)` | `unsafeBody` |
68+
| `SF.createTabs(config)` | `tabs[].content.unsafeHtml` |
69+
| `SF.createTable(config)` | `cells[].unsafeHtml` |
70+
| `SF.gantt.create(config)` | `unsafePopupHtml`, `columns[].render(task).unsafeHtml` |
11871

119-
### Tab Switching
72+
Escape user-provided content before interpolation. `SF.escHtml(...)` is the
73+
shipped helper for that.
12074

121-
Use `SF.showTab` to activate a tab and its related content region.
75+
## Button Variants
12276

12377
```js
124-
SF.showTab('timeline');
78+
SF.createButton({ text: 'Solve', variant: 'success' });
79+
SF.createButton({ text: 'Stop', variant: 'danger' });
80+
SF.createButton({ text: 'Save', variant: 'primary' });
81+
SF.createButton({ text: 'Cancel', variant: 'default' });
82+
SF.createButton({ icon: 'fa-gear', variant: 'ghost', circle: true });
12583
```
12684

127-
## Unsafe HTML APIs
128-
129-
Some component APIs accept HTML strings (for example, custom modal body content). Treat untrusted user data as unsafe.
130-
131-
- Escape user-provided text before injecting into HTML.
132-
- Prefer text-only rendering paths when possible.
133-
- Only pass trusted HTML if it is sanitized.
134-
135-
A practical helper pattern is `SF.escHtml` before interpolation.
136-
13785
## Useful Helpers
13886

139-
The following helpers are optional but often useful in real pages:
87+
These helpers are documented in the current public API:
14088

141-
- `SF.score.*` for score formatting and display helpers
142-
- `SF.colors.*` for consistent palette usage
143-
- `SF.escHtml` for HTML escaping
144-
- `SF.el` for lightweight DOM element creation
89+
- `SF.score.parseHard`, `parseSoft`, `parseMedium`, `getComponents`,
90+
`colorClass`
91+
- `SF.colors.pick`, `project`, `reset`
92+
- `SF.escHtml(...)` for safe HTML escaping
93+
- `SF.el(tag, attrs, ...children)` for lightweight DOM element creation

0 commit comments

Comments
 (0)