ShtukbaseStandard

Lenses

lenses · version 0.3.11
Shtukbase Basicin Basic

What a lens is — HTML built from the markdown of a base — and which templates exist. The lens kit lies in the package; the style and the skins ("Kit", "Draft") are in the package kit-style. Actions to build, check and show lenses; the service lenses "Project packages" and "Project checks".

About the package

A lens is an HTML page that a program builds from the markdown of a base and that shows records in its own perspective: a board, a map, an ontology, nesting. You edit markdown, you rebuild the HTML. The package puts the page /base/lenses.md (what a lens is, the header, the templates, the lists "convert to lenses" and "not lenses"), two service lenses, and gives three actions: build, check, serve.

Service lenses

  • /base/packages.html — "Project packages", the package map: a canvas (drag to pan, Ctrl or Cmd and the wheel to zoom, F to fit) of every installed package as a card with its icon, title, version and counts, in groups by set and family, each a quiet heading above its cards, or in dependency layers with arrows. Click or press Enter on a package card to open it with the selected layout. Peek shows its version, source, linked dependencies, actions, norms and page link. The right panel remembers the opening mode. The arrangement, the canvas and the card presets (main, editorial, quiet, juicy) are settings in the right panel.
  • /base/checks.html — "Project checks": all checks with their norm, and the norms that no check holds.

build writes the data of both to lib/base/packages.data.js from .shtukbase/packages.lock and the packages' package.md (actions/packages.mjs); check says if they are out of date.

Lenses on a live server

A lens opened from a live server (the live package, shtuk run live serve) notices this itself (/api/hello) and turns on editing: the record's fields by the collection schema, changing a select or a phase by clicking a card's chip, dragging a card between board columns (changing the select or phase), editing text, "Create record", "To trash". A schema or contour error is shown at the field. If files change, the lens rereads itself. From disk and from a static server (serve) it is read-only, as before. A board by phase shows the columns of all the contour's phases in order.

Icons

A record shows its icon next to its title in cards, links, lists and the record header: the field icon is an emoji (shown as text) or a path to an .svg (shown through <img>, so no script in it runs; from the root of the base, /assets/icons/x.svg, or from the page's folder). Without its own icon a record shows what its collection gives: icons.item of the collection page, else the collection page's icon, else 📄; a collection with icons: {tier: none} shows none, with tier: kind only its own. Lens and region icons may be an .svg path too. The fields and the rules are the package "Page icons" (icons); the kit only shows them. The kit server sends .svg as image/svg+xml with no scripts allowed.

Lens style: "Kit" and "Draft"

In the Appearance section of the right panel there is a style choice: "Kit" (as it was) or "Draft" (graphite, champagne). The choice is remembered and applies to all the project's lenses, like the theme; it works both from disk and from a server.

  • The project's default style is the field skin in the header of /base/lenses.md: skin: keer is "Draft", skin: kit or empty is "Kit". After an edit — build.
  • A lens address can set the style and the theme for one showing without remembering them: packages.html?skin=keer&theme=dark. The lens's own settings are set the same way, for example the arrangement: ?arrange=layers; #<record id> opens a record.
  • Skins are the files skins/<id>.css of the package kit-style; a new skin appears in the choice after build.

Lens layout

Set layout: on Design to an installed layout id and rebuild the lenses. The kit loads the package's CSS and JavaScript under the Lens layout convention. An empty or unavailable choice uses the built-in frame. The selected style and component library still provide tokens and component CSS.

Where the boundary is

  • Here: the definition of a lens, the templates, the kit and the actions on it.
  • The kit (kit.js, its own part of kit.css, templates, the build, the server) lies in kit/ of the package; install puts it in .shtukbase/packages/lenses/kit/. There are no npm dependencies: js-yaml lies as one file in kit/vendor/. Bun is needed (or Node 20+ for the build itself).
  • The style is in the package kit-style (which requires lists): the base, the header, chips, the card, markdown, the board, the gallery and the skins. Its own part kit/kit/kit.css holds only what lenses need: the canvas, arrows, panels, the record, views. The build puts into lib/kit.css the "Kit" skin, the kit-style style, its own part and the other skins. It looks for the style in the project (design/kit-style/, the kit-style pages), then next to the package in the standard repository; if absent — a clear error "install kit-style".
  • The explore kit (package explore-kit, not required): when the project has design/explore-kit/explore.js and explore.css, the build copies them into lib/ next to kit.js, so a lens links ../lib/explore.js for a settings panel with presets.
  • SHTUK_KIT is an optional replacement: the path to another copy of the kit, for example when working on the kit itself.
  • The package has no norms: checking that lenses are fresh (check) is an action, not a norm's enforcer.
  • Ontology lenses are built by the package ontology; it takes the kit from this package.

Actions 3

NameWhat it doesFileWhen
buildBuild the project's lenses (lib/) and the data of the service lensesactions/build.mjs
shtuk run
checkCheck that the built lenses (lib/) are up to dateactions/check.mjs
shtuk run
serveOpen the project in a browser on 127.0.0.1 (the kit server)actions/serve.mjs
shtuk run

shtuk check runs the checks; shtuk run lenses <name> runs any action. "After install" actions run by themselves only if the package comes from a trusted source.

Pages 3

They go into the project at these paths.

Package files 81

They go into .shtukbase/packages/lenses/; actions run from there.

icon.svg 571 B