Repository navigation
Auxiliary UI components (@spatial-kit/react-ui) #46
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Context
@spatial-kit/react gives you the canvas (SpatialCanvas) and hooks (useSpatialCore, useSelection, useViewport, useCoreEvent). Every app still builds the same surrounding UI by hand: zoom buttons, a zoom percentage, "fit to screen", a minimap, a properties panel for the selection.
The idea is an optional package, @spatial-kit/react-ui, with small, unstyled-by-default components built only on the public hooks. That makes it a good showcase of the API and a quick start for apps. This issue is design-first: agree on scope and styling in the comments.
What changes (proposal)
A first, small set of components:
| Component | What it does | Built on |
|---|---|---|
<ZoomControls /> |
+ / − / percentage / "fit" buttons |
useViewport, core.zoomAt, core.fitToScene |
<Minimap /> |
Small view of the whole scene with the visible area outlined; click or drag to pan | useViewport, core.scene, sceneBounds |
<SelectionInfo /> |
Shows the selected count and the bounds of a single selected entity; render-prop for custom content | useSelection, core.scene |
<SpatialCanvas core={core} drawEntity={drawEntity} />
<ZoomControls core={core} />
<Minimap core={core} width={200} />Each component should be easy to restyle (className, style, or render props) and should not ship a CSS framework.
Open questions
- Styling: unstyled with minimal inline defaults, or a small optional CSS file?
- Which components go into the first version? Proposal:
ZoomControlsandMinimap, then the rest as follow-up issues (good entry points for contributors). - Separate package, or a subpath export of
@spatial-kit/react(@spatial-kit/react/ui)?
Affected files
| File | Change |
|---|---|
packages/adapters/react-ui/ (new package) |
Components, tests, README, package.json mirroring react's setup |
packages/examples/react/ |
Use the components in the example |
| Root README | List the package |
Invariants to preserve
- Only public APIs from
@spatial-kit/coreand@spatial-kit/react, no internal imports. react,@spatial-kit/coreand@spatial-kit/reactare peer dependencies; no other runtime dependencies.- Works with React 18 and 19, like
@spatial-kit/react.
Implementation checklist
- Agree on scope and styling in this issue
- Package scaffold (build, tests, exports, LICENSE, README)
-
ZoomControlswith tests -
Minimapwith tests - Used in the React example
- Changeset
- Run
pnpm typecheck && pnpm test && pnpm lint
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
[-]Auxiliary UI components (@floormap/react-ui)[/-][+]Auxiliary UI components (@spatial-kit/react-ui)[/+]