package page→ /base/lenses.md
pages/base/lenses.md
91 lines, 5.3 KB. As a page.
- ---
- type: Page
- title: "Lenses"
- icon: "🔭"
- description: "Base lenses: HTML built from markdown. How they work, how to rebuild, what else to convert to lenses and what will never become a lens."
- toConvert: []
- notLenses: []
- skin: kit
- ---
- A lens is an HTML page that a program builds from the markdown of a base. We edit markdown, then rebuild the lens. We do not edit HTML by hand: the lens check will notice. In detail — the lens standard (`specs/lenses-standard.ru.md` of the Shtukbase standard project).
- Lenses are of two kinds: a view of records of one kind (in essence a collection view) and a lens over mixed records — a map, a diagram, a report.
- ## How a lens works
- The header is YAML in the first HTML comment of the file:
- | Field | Meaning |
- |---|---|
- | `type: Lens` | marks a lens |
- | `title`, `icon`, `description` | the name, the icon and one line about what it shows |
- | `lensType` | `schema` · `spec` · `map` · `diagram` · `report` · `board` · `gallery` |
- | `render` | `live` — the shell reads the built data `lib/data.js`; `static` — all the HTML is built by the generator |
- | `sources` | paths or masks of markdown sources from the base root |
- | `generator` | the build command, one line, from the repository root |
- | `template` | a lens set template or the path to your own template |
- | `sourcesHash`, `outputHash` | only for `static`: fingerprints of the sources and of the HTML, set by the generator |
- Which lenses a base has can be seen from the files themselves: the lens check prints the list, the gallery `lib/index.html` shows the pictures. We do not duplicate the list here so that it does not go stale.
- ## Templates
- A lens on a template is a file `<folder>/<name>.lens.md`: the header `type: Lens`, `title`, `icon`, `description`, `template` and the template's parameters; the text under the header is "About the lens", how to read the picture. Records are selected the same way everywhere: `from` — a folder, `type` — a record type, `where` — a condition on fields.
- | Template | What it shows |
- |---|---|
- | `canvas` | a canvas: areas with record cards and arrows along link fields |
- | `lanes` | lanes: records by a field's value, each in its own strip |
- | `types` | an ontology: record types and the links between them |
- | `nest` | nesting: records inside their parents |
- | `board` | a board: columns by the record's state (by the contour's phases) |
- | `custom` | your own layout on kit components |
- The gallery `lib/index.html` shows all the base's lenses as cards. A lens does not introduce its own colors, fonts or palette: everything comes from `lib/kit.css` and `lib/kit.js`.
- ## Lens style
- A lens style is a set of colors, shadows, corner radii and a font for the light and the dark theme. There are two: "Kit" (`kit`, the quiet Shtukbase style) and "Draft" (`keer`, an earlier product's style: graphite and champagne). Both lie in the package `kit-style`.
- - To change the style, use the button in the lens header, next to the theme button. The choice is remembered and applies to all the project's lenses.
- - The project's default style is the field `skin` in this page's header: `kit` or `keer`. After an edit — `build`.
- - To show a lens in the needed style by a link: `?skin=keer&theme=dark` in the address. This way the choice is not remembered.
- ## How to build and view
- Package actions, from the project root:
- - `build` — build `lib/`: the records' data, the kit, the gallery and the service lenses' data;
- - `check` — exit code 1 if `lib/` is out of date or missing;
- - `serve [port]` — open the project in a browser on `127.0.0.1`.
- The kit lies in the package itself: on install it goes to `.shtukbase/packages/lenses/kit/`. The style comes with the package `kit-style` (the pages `design/kit-style/`), which is installed together with lenses. Nothing needs installing separately: only Bun is needed. The variable `SHTUK_KIT` is needed only if you want to build lenses with another copy of the kit.
- ## Service lenses
- The package puts two lenses about the project itself:
- - `/base/packages.html` — "Project packages": what is installed, versions, sources, dependencies, actions and checks, norms and pages of each package;
- - `/base/checks.html` — "Project checks": all checks with the norm each one holds, and the norms that no check holds.
- `build` takes their data from `.shtukbase/packages.lock` and the packages' `package.md` and writes it to `lib/base/packages.data.js`. If you installed or updated a package, run `shtuk run lenses build` again.
- ## Two lists in the header
- HTML without a lens header is allowed only if it stands in one of the two lists in this page's header. The lens check reads them; HTML without a header outside the lists is an error.
- - `toConvert` — "convert to lenses", an allowed debt. A row: `{path, order, lensType, note}` — a path or mask from the base root, a number in the queue (1 — first), the future lens type, one line "what to build from". First what is read more often and goes stale more often. A converted lens is removed from the list.
- - `notLenses` — HTML that will not become a lens: the customer's sources as received, prototypes, exports of other systems. A row: `{path, note}`.
- The tables below are for reading; they are edited together with the header.
- ### Convert to lenses
- | Order | HTML | Type | What to build from |
- |---|---|---|---|
- ### Not lenses
- | HTML | Why |
- |---|---|