ShtukbaseStandard

Page icons

icons · 版本 0.2.2
其他4 条规范4 项检查

Icons for pages, as in Notion and further: an emoji, an icon from a shared set or an SVG an agent draws for the page. Tiers say which pages get which, so 20 000 service pages never get bespoke art; norms with checks, a prompt for the agent, validate and sanitize for SVG. Style-agnostic: a style plugs in with an IconStyle page; an icon set follows the convention icon-set (a registry, flat drawings, no plate), and the icon lens shows every set in every style.

关于该包

这段内容尚未翻译,下面是英文原文。

A page shows a small icon next to its title: in the sidebar, in lists and links, in the card and in the page header. The package says what an icon may be, which pages get which kind of icon, where the files lie, and checks it. The full explanation is the page /base/icons.md; the settings are /design/icons.md.

What an icon is. The field icon: of a page: one emoji (icon: "🥕") or a path to an SVG file (icon: /assets/icons/carrot.svg). The field art: is a large picture for cards, a path to an SVG too. Files lie in /assets/icons/; the shared set of uniform icons lies in /assets/icons/set/. Nothing is inlined in the front matter.

Tiers. A collection says in its page how its records get icons: icons: {tier: kind, item: "🏃"}. none — no icon; kind — all records show the collection's one icon; pick — a record picks an emoji or a set icon; bespoke — a picture is drawn for the record, at most max files per collection. A collection without icons: gets defaultTier (pick): a drawing for a page is always a decision someone wrote down.

For agents. Before giving a page an icon run shtuk run icons prompt <page.md>: it says the page's tier and prints what to do — nothing, one emoji, or a drawing prompt with the contract and the style. After drawing: shtuk run icons validate <file>; a file from elsewhere: shtuk run icons sanitize <file> --write.

What is checked

  • ICN-R01 (MUST, enforce): icon and art of every page, icons.item of every collection and every .svg in the icons folder: the file exists, lies in /assets/icons/, is an SVG by the contract — square viewBox, xmlns, at most maxBytes (4096), only drawing elements, no script, event attributes, links out of the file, text, <style>, <image> or currentColor; with an icon style installed, colours from its palette. The valid check.
  • ICN-R02 (MUST, enforce): a page carries only what its tier allows, and the bespoke files of a collection are at most its max. The budget check.
  • ICN-R03 (SHOULD, enforce): in a collection with icons: {required: true} every record shows an icon: its own, or the inherited one. The required check.
  • ICN-R04 (SHOULD, warn): an icon set and its registry agree — every drawing has a record and every record its file, a name or an alias belongs to one icon, every record says what it draws and where it fits; near duplicates are reported. The registry check; it reports and never fails (the health of the convention).

Style

The package draws nothing itself and has no palette. A style package plugs in with a page type: IconStyle under /design/ (or the one named by style: in the settings): palette, viewBox, gradients, rules (lines for the drawing prompt), examples. The prompt quotes it; the checks hold the palette. Without a style the contract alone holds.

An IconStyle page may also say role (base, the default; variant or reserve, which are shown but never held by default), styleId, set (the registry it draws) and render, the parameters of the renderer lib/render.js: outline (ink, deep, hueink or a colour), outlineWidth, rim, rimColor, shadow, offset, shadowOnly, scale. A palette entry that is a list is a hue: main, dark, light, deep, deeper. The renderer is pure JavaScript with no DOM: the same file renders a set in a build and in the lens.

Icon sets: the convention

An icon set (for example shtukbase-icons) keeps the convention icon set: flat drawings in /design/<set>/flat/, one registry /design/<set>/registry.json (a record per icon: name, file, description, use, avoid, aliases, group, added), names by Lucide where Lucide has the concept, no plate under an icon. The prompt searches the registries first and prints the reuse rules; the agent draws only when no record means the same thing.

The icon lens

/design/icons.html shows every set by colour group, each icon at the chosen size on a light and a dark surface, in the held style or in every installed style side by side; search by name, alias and meaning; a click shows the record and copies the name. The settings are in the explore panel (explore-kit; without it, plain fields). Build its data with shtuk run icons lens.

Where the boundary is

  • Here: the fields, tiers, storage, the SVG contract, the checks, the prompt, validate and sanitize, the renderer, the convention for icon sets and the icon lens.
  • A set and its style: a set package such as shtukbase-icons.
  • How icons are shown in lenses is in the lens kit (lenses): emoji as text, SVG through <img>, the fallback is the record's icon → the collection's icons.item → the collection page's icon → 📄.
  • The look of icons is the style package's.

规范 4

ID规范级别模式Enforcer
ICN-R01
Every SVG that a page (icon, art) or a collection (icons.item) refers to, and every SVG in the icons folder, exists, lies in the icons folder and keeps the SVG contract.
MUST 拦截
检查
ICN-R02
A page sets icon and art only as its tier allows (none, kind, pick, bespoke), and the distinct bespoke files of a collection are at most its icons.max.
MUST 拦截
检查
ICN-R03
In a collection with icons.required, every record shows an icon: its own as its tier allows, or the inherited one (icons.item, else the collection page icon).
SHOULD 拦截
检查
ICN-R04
Every SVG of a set has a record in its registry and every record has its file; names are kebab-case and unique, a word (name or alias) belongs to one icon, and every record says what it draws and where it fits.
SHOULD 提醒
检查

“拦截”:enforcer 会阻止违规;“观察”:只记录违规。MUST 级别表示必须遵守;SHOULD 表示默认应当遵守。

动作 8

名称作用文件时机
validAn icon a page refers to exists and is a valid, safe SVG
规范 ICN-R01
checks/i01_valid.ts
检查
budgetA page carries only what its tier allows; bespoke files stay in the budget
规范 ICN-R02
checks/i02_budget.ts
检查
requiredEvery record of a collection that requires an icon shows one (inherited counts)
规范 ICN-R03
checks/i03_required.ts
检查
registryAn icon set and its registry agree (warn: the health of the convention icon-set)
规范 ICN-R04
checks/i04_registry.ts
检查
promptPrint a ready prompt for an agent to give a page its icon: shtuk run icons prompt <page.md> [--art] [--kind]actions/prompt.ts
shtuk run
validateCheck SVG files by the contract and the installed icon style: shtuk run icons validate <file | folder>...actions/validate.ts
shtuk run
sanitizeDrop what the contract refuses from an SVG: shtuk run icons sanitize <file.svg> [--write | -o <out>]actions/sanitize.ts
shtuk run
lensWrite the data of the icon lens (lib/design/icons.data.js and lib/design/icon-render.js): shtuk run icons lens [--check]actions/lens.ts
shtuk run

shtuk check 运行检查;shtuk run icons <名称> 运行任意动作。“安装后”动作只有在包来自可信来源时才会自动运行。

页面 8

这些页面会放到项目中的以下路径。

包文件 16

它们会放到 .shtukbase/packages/icons/,动作从那里运行。