Documentation
¶
Overview ¶
Package designkit keeps UI kits of the design library by version: a kit (stylesheets, scripts, fonts, docs) is installed once as a folder <kits>/<id>/<version>/ and every project loads it from /kit/<id>/<version>/... instead of carrying its own copy. A version never changes after it is installed, so the files are served for good.
The package knows nothing about the library, the runtime or the command line; all three use it.
Index ¶
- Constants
- Variables
- func BuildSeal(id, version, root string) (filestore.KitSeal, error)
- func Bump(v, part string) (string, error)
- func CardPath(id string) string
- func ClearDraft(dir, id string) error
- func Compare(a, b string) int
- func CopyTree(src, dst string, skip []string) (int, int64, error)
- func DefaultDir(dataDir string) string
- func Element(v any) (id string, props map[string]any, children any, ok bool)
- func ElementID(id string) bool
- func Files(dir, id, version string) []string
- func FunctionValue(v any) (field string, ok bool)
- func Identity(root string) (id, version string, err error)
- func Init(dir string, o InitOptions) ([]string, error)
- func InstallTheme(root, theme, project string) (bool, error)
- func JSX(comp string, props map[string]any) string
- func LayoutBoard(root string, l Layout) ([]byte, error)
- func MarshalCompact(v any) []byte
- func MountOf(root, kitID, mount string) string
- func Mounts(root, kitID string) []string
- func ParseLayoutAddress(addr string) (kit, version, theme, layout string, err error)
- func PinBase(dir, id, version string)
- func Prepare(dir string, c *Canvas) error
- func PreparedFile(dir, id, version, theme, name string) string
- func PreviewProp(name string) bool
- func PropsCompatible(base, mine []Prop) string
- func RangeSatisfies(rng, version string) (bool, error)
- func Resolve(dir, id, version string, segments []string) string
- func Root(dir, id, version string) string
- func SealLegacy(dir string) (int, error)
- func SeedDraftPrep(dir, id, base string) error
- func SeedVersionPrep(dir, id, version string)
- func StampVersion(root, id, version string) error
- func Themes(dir, id, version string) []kitTheme
- func TokenGroups(c *Canvas) []string
- func ValidID(v string) bool
- func ValidVersion(v string) bool
- func WriteArchive(dir string, m *Manifest, w io.Writer) error
- func WriteDraft(dir, id string, d Draft) error
- func WriteSeal(id, version, root string) error
- func WriteSettings(dir, id string, s Settings) error
- func XImport(ns, comp string, props map[string]any) string
- type Asset
- type AssetGroup
- type Atlas
- type Base
- type Canvas
- type CanvasSection
- type CanvasTheme
- type CardView
- type Change
- type CheckReport
- type CheckView
- type Code
- type CodeModule
- type ColorToken
- type Component
- type ComponentGroup
- type ComponentReadiness
- type ComponentView
- type ConflictError
- type Diff
- type Draft
- type ExportFile
- type ExportOptions
- type Extends
- type ExtendsInfo
- type FontFace
- type ImportOptions
- type ImportResult
- type IndexEntry
- type IndexGroup
- type IndexTemplate
- type IndexView
- type InitOptions
- type JSXAttr
- type JSXElement
- type JSXImport
- type Kit
- type Layout
- type LayoutItem
- type Manifest
- type Options
- type PartView
- type PlainToken
- type Preset
- type PresetView
- type Problem
- type Prop
- type PublishOptions
- type Published
- type Require
- type Restricted
- type Result
- type Rule
- type SearchHit
- type SearchView
- type Settings
- type Slot
- type StrictFinding
- type StrictKit
- func (k *StrictKit) CheckBoard(file, src string, local func(from string) bool) []StrictFinding
- func (k *StrictKit) CheckModule(file, src string, local bool) []StrictFinding
- func (k *StrictKit) CodeImportOf(id string) (module, export string, ok bool)
- func (k *StrictKit) Package() string
- func (k *StrictKit) TransformModule(src, fixtures string) (CodeModule, error)
- type Template
- type TemplateItem
- type TemplateLayout
- type TemplateListView
- type TemplateSection
- type TemplateView
- type TokenView
- type TokensView
- type TypeStyle
- type UsedWith
- type Variant
- type Version
Constants ¶
const ( SectionFoundation = "foundation" SectionComponents = "components" SectionTemplates = "templates" SectionAssets = "assets" // SectionReference holds a template's own guide (how to use it, palettes, icon libraries): shown apart from the // templates so they stay clean. SectionReference = "reference" )
The canvas's sections, in the tree's order.
const ( LevelError = "error" LevelWarning = "warning" )
Problem levels: an error makes the kit unfit to pack; a warning is a kit that works and reads worse.
const ( // MaxArchiveBytes is the largest tarball read, MaxUnpackedBytes and MaxFiles what it may unpack to. MaxArchiveBytes = 2 << 30 MaxUnpackedBytes = 4 << 30 MaxFiles = 5000 // ManifestFile is looked at, when the kit has it, to make sure the tarball is the kit and version asked for. ManifestFile = "design-system.json" // DirName is the kits folder inside the runtime's data folder when none is configured. DirName = "design-kits" )
const ( KindComponent = "component" KindLayout = "layout" KindTemplate = "template" KindAsset = "asset" KindColor = "color" KindType = "type" KindToken = "token" )
The kinds of index entries, in the order the results are grouped.
const ( SealFile = filestore.KitSealFile SealRequired = ".seal-required" )
SealFile is the seal's name inside a version; SealRequired the mark in the kits folder that versions must be sealed.
const ( // ExportManifest is the manifest's name, the first entry of an export. ExportManifest = "kit-export.json" // KitFile is the kit's own record (layers, themes, fonts with licenses, other kits it needs). KitFile = "kit.json" // SourcesDir holds the heavy originals; an export takes it only when asked. SourcesDir = "sources" )
const DraftVersion = "draft"
DraftVersion names the kit's draft where a version goes: the kit screen and /kit/<id>/draft/... read the draft's folder as if it were an installed version. It is never installed, listed or published under this name.
const ElementKey = "$c"
ElementKey marks a prop value that is another component of the kit rather than data:
{"$c": "Button", "props": {"appearance": "primary"}, "children": "Save"}
A sample, a variant or a layout's props hold one wherever the component takes a React element: a tooltip's trigger, a dialog's body made of its parts, an icon inside a button. The live preview (the kit screen's _play page and `harnessly design kit render`) turns it into React.createElement of that component; children is a value, an element or a list of them. One spelling for every kit: the check, the preview and the docs read this const.
const FunctionKey = "$fn"
FunctionKey marks a prop value that is a function: {"$fn": ""} does nothing, {"$fn": "id"} returns its argument's field id (a row's key, an item's label). JSON cannot carry code; this is enough for a required callback or accessor to let a component draw (DataTable's rowKey, a list's getLabel).
const IndexBudget = 2048
IndexBudget is the size the kit index aims at for a kit of fifty components: bytes of its JSON.
const MaxChangesListed = 200
MaxChangesListed is how many changed files a version's record names; the count is kept in full.
const MaxCheckProblems = 40
MaxCheckProblems bounds the problems a CheckView lists.
const MaxExtendsDepth = 3
MaxExtendsDepth is how many bases a chain may have (brand → base → foundation is 2).
const MaxTemplateSource = 64 << 10
MaxTemplateSource is the largest board kit_template inlines.
const PartProvider = "provider"
PartProvider marks a component that only provides context (a theme, a store) and draws nothing.
const TopLevel = 3
TopLevel is the highest readiness level.
const ViewSchema = "kit-view/1"
ViewSchema is the version of the shapes in this file; it is in every answer of the kit tools and of `kit show`.
Variables ¶
var CardSections = []string{"When to use", "When not to use", "Props", "Example", "Examples", "In code", "Used with", "Content", "Accessibility", "States", "Status"}
CardSections are the headings of a card the view reads, as a card writes them (any case). «Props» is read from the manifest, not from the card.
var ( // ErrExists: the version is installed with other content; versions are immutable, Force replaces it. ErrExists = errors.New("this kit version is already installed with different content") )
var ErrNoCanvas = errors.New("the kit has no canvas")
ErrNoCanvas: the theme does not describe a canvas (an older kit), or the kit, version or theme is not there.
var ErrNoVersion = errors.New("this kit has no installed version")
ErrNoVersion: the kit has no published version to start from or to compare with.
var ErrRestricted = errors.New("the kit has files with a restricted license")
ErrRestricted: the kit has license-restricted files and the export was not confirmed.
var Rules = []Rule{ {"kitjson.json", LevelError, "kit.json is valid JSON"}, {"kitjson.theme", LevelError, "each theme in kit.json has a plain id and a folder inside the kit with its design-system.json"}, {"kitjson.empty", LevelError, "kit.json lists at least one theme (a one-theme kit needs no kit.json)"}, {"index.missing", LevelError, "every theme has design-system.json"}, {"index.json", LevelError, "design-system.json is valid JSON"}, {"index.title", LevelWarning, "the theme has a title"}, {"index.namespace", LevelError, "namespace is a JavaScript name: boards write <Namespace>.<Component>"}, {"index.section", LevelWarning, "sections are only foundation, components, templates, assets"}, {"index.empty", LevelWarning, "the theme has groups, assetGroups or templates"}, {"identity.missing", LevelError, "one member of design-system.json is the kit record {id, version, source}"}, {"identity.id", LevelError, "the kit id is lower case letters, digits and -"}, {"identity.version", LevelError, "the version is major.minor.patch"}, {"identity.source", LevelWarning, "source is library or draft"}, {"identity.kind", LevelError, "the kit record's kind, when set, is app, site, slides or video"}, {"identity.extends", LevelError, "extends, when set, is <id>@<range> with a valid id and version range"}, {"extends.missing", LevelError, "the base kit named by extends is installed"}, {"extends.version", LevelError, "an installed version of the base kit satisfies the range"}, {"extends.cycle", LevelError, "the chain of bases does not lead back to the kit"}, {"extends.depth", LevelError, "the chain of bases is at most three kits long"}, {"extends.override", LevelError, "a component that replaces the base's keeps its props: it may add optional props and enum values, not drop, retype or require"}, {"identity.strict", LevelError, "the kit record's strict, when set, is true or false"}, {"identity.omitted", LevelError, "omitted, when set, lists only tokens, examples, docs, patterns, templates"}, {"code.shape", LevelError, "a component's code, when set, is {import, export} with plain strings"}, {"preset.shape", LevelError, "a component's preset, when set, is {of, props}"}, {"preset.target", LevelError, "a preset's of is another component of the theme, not a preset itself"}, {"preset.props", LevelError, "a preset's props are simple values the target component declares"}, {"status.value", LevelError, "a component's status, when set, is stable, new or deprecated"}, {"status.replaced-by", LevelError, "replacedBy, when set, names another component and goes with status deprecated"}, {"token.var", LevelError, "a token's var, when set, is a CSS custom property name --like-this"}, {"readme.missing", LevelError, "the theme has README.md"}, {"readme.consuming", LevelWarning, "README.md has a Consuming section"}, {"groups.names", LevelError, "groups are component groups, not a claude.ai list of names"}, {"groups.shape", LevelError, "groups is [{id, title, components}]"}, {"groups.id", LevelError, "every group has an id"}, {"component.id", LevelError, "a component id is its export name in the namespace"}, {"component.twice", LevelError, "a component is listed once"}, {"component.description", LevelError, "every component has a description: what it is for"}, {"component.description-short", LevelWarning, "a description has five words or more"}, {"component.description-same", LevelWarning, "no two components share a description"}, {"component.todo", LevelWarning, "a component imported as a draft lists what a person still writes in todo; the list is empty when it is done"}, {"component.thumb", LevelError, "a component's thumb is a file of the kit"}, {"component.preview", LevelError, "a component's preview, when set, is a file of the kit"}, {"component.dotted", LevelWarning, "a component drawn live has a one-word id (a dotted one is a part)"}, {"component.no-sample", LevelWarning, "a component that is not a part has a sample or variants"}, {"prop.name", LevelError, "every prop has a name"}, {"prop.type", LevelError, "a prop's type is one of enum, boolean, number, string, color, token, node, function, object, array"}, {"prop.enum", LevelError, "an enum prop lists its values"}, {"prop.description", LevelWarning, "a prop says what it changes on screen"}, {"variant.id", LevelWarning, "every variant has an id"}, {"sample.undeclared", LevelError, "a sample, a variant or an element sets only props its component declares"}, {"sample.not-passed", LevelWarning, "a sample sets no prop the live preview never passes (handlers, styles, links, dashed names), unless it is required"}, {"sample.enum", LevelError, "a sample sets an enum prop only to one of its values"}, {"sample.required", LevelError, "every required prop has a value in the sample or the first variant"}, {"sample.depth", LevelError, "elements nest at most 12 deep (lists and objects between them do not count)"}, {"element.function", LevelError, `a function value is {"$fn": ""} (does nothing) or {"$fn": "<field>"} (returns its argument's field)`}, {"element.id", LevelError, `an element's "$c" is a component id`}, {"element.unknown", LevelError, "an element names a component of the kit"}, {"part.shape", LevelError, `part is "provider", the parent's id or {"of": parent}`}, {"part.self", LevelError, "a component is not a part of itself"}, {"part.parent", LevelError, "a part's parent is a component of the kit"}, {"part.nested", LevelError, "a part's parent is not itself a part"}, {"part.unused", LevelWarning, "the parent's sample or variants use the part, so the part has a picture"}, {"keywords.shape", LevelError, "keywords is a list of strings"}, {"card.missing", LevelError, "every component has components/<Comp>/README.md"}, {"card.summary", LevelError, "a card starts with a sentence about what the component is for"}, {"card.summary-differs", LevelWarning, "the card's first sentence is the component's description"}, {"card.when-not", LevelWarning, "a card has «When not to use»"}, {"card.example", LevelWarning, "a card has an <x-import component-from-global-scope=…> example"}, {"assets.shape", LevelError, "assetGroups is {id: {title, kind, items: [{name, file}]}}"}, {"assets.items", LevelError, "an asset group lists its items"}, {"assets.kind", LevelWarning, "an asset group's kind is icon, image or logo"}, {"assets.files", LevelError, "every asset has a name and a file of the kit"}, {"templates.shape", LevelError, "templates is a list of templates"}, {"templates.id", LevelError, "every template has an id"}, {"templates.empty", LevelError, "every template has layouts"}, {"layout.id", LevelError, "every layout has an id"}, {"layout.purpose", LevelWarning, "every layout says what page it is for"}, {"layout.file", LevelError, "a layout's board and thumb are files of the kit"}, {"layout.thumb", LevelWarning, "every layout has a thumb"}, {"tokens.missing", LevelError, "the theme has tokens.json"}, {"tokens.json", LevelError, "tokens.json is valid JSON"}, {"tokens.dtcg", LevelError, "tokens.json is lists, not a W3C/DTCG name→$value map"}, {"tokens.family", LevelError, `each family is {"tokens": [{name, value, usage}]}`}, {"tokens.name", LevelError, "a token name is letters, digits, _ . -"}, {"tokens.duplicate", LevelError, "a token name is used once across families"}, {"tokens.usage", LevelWarning, "every token says what it is for"}, {"tokens.font", LevelError, "a font file in type.fonts is a file of the kit"}, {"tokens.color-shape", LevelError, "a colour value is a string or {mode: value}"}, {"tokens.mode", LevelWarning, "a colour has a value in every mode"}, {"tokens.color-value", LevelError, "a colour is hex, rgb(), hsl() or oklch() — no var(), color-mix() or names"}, {"bundle.at-root", LevelError, "the bundle is components/bundle.js, not bundle.js"}, {"bundle.missing", LevelError, "a kit with components has components/bundle.js"}, {"bundle.script-tag", LevelError, "the bundle contains no </script"}, {"bundle.namespace", LevelWarning, "the bundle assigns window.<Namespace>"}, {"bundle.own-react", LevelError, "the bundle takes React from window.React, it does not carry its own"}, {"bundle.module", LevelError, "the bundle is one classic script, not a module"}, {"css.missing", LevelWarning, "a kit with components has components/bundle.css"}, {"css.global", LevelError, "rules on html, body, * sit inside @layer kit-<id>"}, {"render.error", LevelError, "a component or a layout draws without an exception, a console error or a failed request (--render)"}, {"render.blank", LevelError, "a component or a layout draws something visible (--render; a provider or a part is marked as one)"}, }
Rules are the static rules (check.go) and the render rules (`kit check --render`, `kit render`).
var StrictRules = []Rule{ {"strict.element", LevelError, "every element is a component of the kit, or a local component of the project in a file of its own"}, {"strict.value", LevelError, "colours, lengths and CSS variables are the kit's tokens, and a token prop gets a token"}, {"strict.prop", LevelError, "a component gets only the props it declares, an enum prop only one of its values"}, {"strict.deprecated", LevelError, "no component the kit marks deprecated"}, }
StrictRules are the strict check's rules; docs/agents/design-kits.md lists them (a test keeps the two together).
Functions ¶
func Bump ¶
Bump is the version after v: "patch", "minor" (the default) or "major"; a pre-release tag is dropped.
func ClearDraft ¶
ClearDraft forgets the kit's draft; its folder is the caller's to put away.
func CopyTree ¶
CopyTree copies the regular files and folders of src into dst (made), leaving out skip's top-level names; links are not followed. It reports the files and bytes copied.
func DefaultDir ¶
DefaultDir is the kits folder when none is configured.
func Element ¶
Element reads v as an element value: the component's id, its props and its children (nil without).
func ElementID ¶
ElementID is a component id an element may name: the export's name in the namespace, dotted for a member (Button, Dialog.Body).
func Files ¶
Files lists an installed version's files as slash paths, or nil when it is not installed.
func FunctionValue ¶
FunctionValue reads v as a function value: the field it returns, "" for one that does nothing.
func Identity ¶
Identity is the kit's id and version as its folder records them: the kit record of design-system.json at the root, or of the first theme kit.json names. Install checks an archive against the same record.
func Init ¶
func Init(dir string, o InitOptions) ([]string, error)
Init writes a new kit into dir, which must be missing or empty.
func InstallTheme ¶
InstallTheme copies the kit's theme folder (without _harnessly) into <project>/ds/<theme>/ unless it is already there, all or nothing. It reports whether it copied. The project's ds folder must be a real folder inside the project: a link there (which could lead the copy anywhere) is refused.
func JSX ¶
JSX writes a component with its props as JSX: strings as attributes, other values in braces, elements ({"$c": …}) as nested JSX, «children» as the body.
func LayoutBoard ¶
LayoutBoard is the layout's board file.
func MarshalCompact ¶
MarshalCompact is v as JSON on one line, with <, > and & as they are (a board's markup stays readable).
func MountOf ¶
MountOf is the folder of a kit's root a project sees as ds/<mount>/: a theme (themes/<mount>/) when the kit has themes, else the whole kit when the mount is the kit's own id. "" when the kit has no such folder.
func ParseLayoutAddress ¶
ParseLayoutAddress splits <kit>[@version]/<theme>/<layout>.
func PinBase ¶
func PinBase(dir, id, version string)
PinBase resolves and keeps the base of a freshly installed or published version; nothing when it has no base or the base cannot be resolved yet (it is pinned the first time the version is read).
func Prepare ¶
Prepare makes the atlases of a canvas's theme once (later calls read what the first made) and writes their places into the canvas: each asset group's and template's Atlas, each item's Cell.
func PreparedFile ¶
PreparedFile is a prepared file of a version's theme as a real path, or "" when there is none by that name.
func PreviewProp ¶
PreviewProp tells whether the live preview passes a prop of this name: a plain name (letters and digits — the board engine reads a dashed attribute under other spellings), never a handler, a style, a link or a loader, whatever the kit declares. The check warns about sample props it leaves out, so a picture never silently lacks one.
func PropsCompatible ¶
PropsCompatible says whether a component that replaces a base's keeps its contract: every prop the base declares stays, with its type (an enum keeps all its values), and what the replacement adds is optional, so a board written on the base still draws on the child. "" when compatible, else what breaks.
func RangeSatisfies ¶
RangeSatisfies is whether version is in the range text, an error when the text is not a range.
func Resolve ¶
Resolve is a requested file of an installed version as a real path confined to the version's folder, or "" when the kit, the version or the file is not there, the path escapes (.., a link) or is not a regular file. With no segments it is the version's folder itself.
func SealLegacy ¶
SealLegacy seals every version in dir that has no seal yet and marks the folder (SealRequired). It runs once at the runtime's start, before the kits are synced; running it again changes nothing. It returns how many it sealed.
A folder that already has the mark is left alone without being read: a version without a seal there is one still arriving, never a legacy one, and listing the folder checks every sealed version by hashing its files, which held the start of a runtime with many kits for more than a minute before its gate listened.
func SeedDraftPrep ¶
SeedDraftPrep gives a new draft the atlases of the version it was copied from: the copy keeps the files' times, so they stand until a file of the draft is edited.
func SeedVersionPrep ¶
func SeedVersionPrep(dir, id, version string)
SeedVersionPrep gives a version published from the draft the draft's atlases of each theme that are not older than the theme's files (the version keeps the draft files' times), so its first open does not make them again.
func StampVersion ¶
StampVersion writes the kit's id and version into kit.json of a folder (a draft just published as that version), the way Publish writes them into the version: the draft and its version then hold the same bytes.
func Themes ¶
func Themes(dir, id, version string) []kitTheme
Themes lists the themes of an installed version: kit.json's, or the version itself as one theme ("") when it keeps its design-system.json at its root.
func TokenGroups ¶
TokenGroups are the families a canvas has tokens in, sorted.
func ValidVersion ¶
ValidVersion is whether v can name a version: major.minor.patch with an optional pre-release tag.
func WriteArchive ¶
WriteArchive writes the manifest and then the files it lists as a tar.gz. Files are read again and checked against the manifest, so a kit that changed under the export is refused rather than packed half-and-half.
func WriteDraft ¶
WriteDraft records the kit's draft.
func WriteSettings ¶
WriteSettings keeps the kit's settings (written whole, then moved into place).
Types ¶
type Asset ¶
type Asset struct {
NodeID string `json:"node"`
Name string `json:"name"`
File string `json:"file"`
Dark string `json:"dark,omitempty"`
// Bg is the colour the asset is meant to sit on (a white logo on a dark one), "" for any.
Bg string `json:"bg,omitempty"`
// Cell is the asset's place in its group's atlas, -1 when the atlas does not hold it (a vector file).
Cell int `json:"cell"`
}
Asset is a named file of an asset group, relative to the theme's folder; Dark is its variant for the dark mode.
type AssetGroup ¶
type AssetGroup struct {
ID string `json:"id"`
NodeID string `json:"node"`
Title string `json:"title"`
Kind string `json:"kind"`
Component string `json:"component,omitempty"`
Prop string `json:"prop,omitempty"`
Items []Asset `json:"items"`
Atlas *Atlas `json:"atlas,omitempty"`
}
AssetGroup is a group of assets (icons, art, logos).
type Atlas ¶
type Atlas struct {
File string `json:"file"`
CellW int `json:"cellW"`
CellH int `json:"cellH"`
Cols int `json:"cols"`
Count int `json:"count"`
}
Atlas is one picture holding many small ones in a grid of cells, row by row: the far view loads it instead of hundreds of files. File is a path under the version's prepared folder.
type Base ¶
type Base struct {
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Folder string `json:"folder"`
Namespace string `json:"namespace"`
}
Base is a kit a canvas is built on: where its files are (its theme folder in its version) and its namespace.
type Canvas ¶
type Canvas struct {
Kit string `json:"kit"`
Version string `json:"version"`
Versions []string `json:"versions"`
Title string `json:"title"`
Theme string `json:"theme"`
Themes []CanvasTheme `json:"themes"`
Namespace string `json:"namespace"`
// Root is the provider component every board on the kit wraps its content in (the kit record's root), "" for none.
Root string `json:"root,omitempty"`
// TokenPrefix is the kit record's prefix of the tokens' CSS variables (--acme-), "" when none.
TokenPrefix string `json:"tokenPrefix,omitempty"`
// React is the React the kit's bundle was built for ("19"), "" for the page's own React 18.3.1: the kit record's
// react. A board or preview on such a kit loads React 19 before the engine.
React string `json:"react,omitempty"`
// Package is the npm package the kit stands for (kit.package), Strict whether projects on it are checked in strict
// mode (kit.strict).
Package string `json:"package,omitempty"`
Strict bool `json:"strict,omitempty"`
// Base is the theme's folder in the version (slash path, "" for a kit that is one theme).
Base string `json:"base"`
Sections []CanvasSection `json:"sections"`
Modes []string `json:"modes"`
Colors []ColorToken `json:"colors"`
Type []TypeStyle `json:"type"`
Fonts []FontFace `json:"fonts"`
Tokens []PlainToken `json:"tokens"`
Groups []ComponentGroup `json:"groups"`
Assets []AssetGroup `json:"assets"`
Templates []Template `json:"templates"`
Index []IndexEntry `json:"index"`
PreparedAt int64 `json:"preparedAt"`
// Extends is the kit's link to its base (extends.go): the spec, the version it resolved to or why it did not.
Extends *ExtendsInfo `json:"extends,omitempty"`
// Bases are the kits this one is built on, the outermost first; their files load before the kit's own.
Bases []Base `json:"bases,omitempty"`
// RootNs is the namespace of Root when it is inherited from another namespace.
RootNs string `json:"rootNs,omitempty"`
}
Canvas is a theme of an installed kit version as the kit screen draws it.
func ReadCanvas ¶
ReadCanvas reads a theme of an installed version ("" is its first theme) as the kit screen draws it, without the prepared atlases (Prepare adds them).
func (*Canvas) CleanValue ¶
CleanValue is v with what the live preview may build: elements of components the canvas has, with props the component declares and PreviewProp allows, nested at most maxElementDepth deep. Anything else in an element is dropped; plain data (strings, numbers, lists, objects) passes as it is.
func (*Canvas) NamespaceOf ¶
NamespaceOf is the namespace a board calls a component by: the kit's, or the base's for an inherited one.
func (*Canvas) Namespaces ¶
Namespaces are the namespaces a page of the kit loads, the kit's own first.
type CanvasSection ¶
CanvasSection is a section of the tree; Title is the kit's own name for it, "" for the screen's default.
type CanvasTheme ¶
CanvasTheme is one theme of a kit.
type CardView ¶
type CardView struct {
// Found: the card file exists.
Found bool `json:"found"`
Summary string `json:"summary,omitempty"`
WhenToUse []string `json:"whenToUse,omitempty"`
WhenNotToUse []string `json:"whenNotToUse,omitempty"`
Examples []string `json:"examples,omitempty"`
InCode string `json:"inCode,omitempty"`
Content []string `json:"content,omitempty"`
Accessibility []string `json:"accessibility,omitempty"`
States []string `json:"states,omitempty"`
// Status is the card's own «Status» section (a note on maturity), apart from the manifest's status.
Status string `json:"status,omitempty"`
}
CardView is a component's card cut into its sections. Empty sections are left out of the JSON.
type Change ¶
type Change struct {
Path string `json:"path"`
// Kind is "added", "changed" or "removed".
Kind string `json:"kind"`
}
Change is one file a draft has changed against its base.
type CheckReport ¶
type CheckReport struct {
Themes []string `json:"themes"`
Components int `json:"components"`
Problems []Problem `json:"problems"`
// Readiness is how far each component is built out (readiness.go); Level is the kit's, the lowest of its
// components (-1: a component has no code yet), Next what that component lacks.
Level int `json:"level"`
Next string `json:"next"`
Readiness []ComponentReadiness `json:"readiness"`
}
CheckReport is what Check found in a folder.
func Check ¶
func Check(root string) (*CheckReport, error)
Check checks the kit folder root: kit.json's themes when it has one, else the folder as one theme.
func CheckIn ¶
func CheckIn(root, dir string) (*CheckReport, error)
CheckIn is Check for a kit that may extend another: the base is looked for in the kits folder dir, and the child is checked as assembled with it (what it inherits can be named by its presets, parts and samples; what it replaces keeps the base's props). With no dir, a kit that extends is checked as its own files only.
func (*CheckReport) Errors ¶
func (r *CheckReport) Errors() int
Errors counts the problems that make the kit unfit to pack.
type CheckView ¶
type CheckView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Ok bool `json:"ok"`
Themes []string `json:"themes"`
Components int `json:"components"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
Problems []Problem `json:"problems"`
// Truncated: more problems than were listed.
Truncated bool `json:"truncated,omitempty"`
// Level is the kit's readiness (the lowest component's, -1 .. TopLevel), Next what that component lacks.
Level int `json:"level"`
Next string `json:"next,omitempty"`
// Levels counts components by level; Behind lists the components below the top level.
Levels map[string]int `json:"levels"`
Behind []ComponentReadiness `json:"behind,omitempty"`
}
CheckView is the summary of `kit check` for an agent: counts, the problems (errors first, at most MaxCheckProblems), and where the components stand in the readiness levels.
func CheckOf ¶
func CheckOf(kit, version string, rep *CheckReport) CheckView
CheckOf summarises a report of Check for a kit version.
type CodeModule ¶
type CodeModule struct {
Source string
// Component is the name of the page's default export, Props what it takes from its fixtures (in import order).
Component string
Props []string
}
CodeModule is a module turned into the product's code.
type ColorToken ¶
type ColorToken struct {
ID string `json:"id"`
Name string `json:"name"`
Values map[string]string `json:"values"`
Usage string `json:"usage,omitempty"`
// Var is the CSS variable the token is published as, when tokens.json says (token.var).
Var string `json:"var,omitempty"`
// From is the kit this token is inherited from («id@version»), "" for the kit's own.
From string `json:"from,omitempty"`
}
ColorToken is a colour of the foundation; Values holds a value per mode («light», «dark») or one under "".
type Component ¶
type Component struct {
ID string `json:"id"`
NodeID string `json:"node"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Props []Prop `json:"props"`
Variants []Variant `json:"variants"`
Sample map[string]any `json:"sample,omitempty"`
Preview string `json:"preview,omitempty"`
// Thumb is the component's picture (a path in the theme), drawn on the canvas when it is not live; Cell is its place
// in the group's atlas, -1 without one.
Thumb string `json:"thumb,omitempty"`
Cell int `json:"cell"`
// Part is what the component is a part of: another component's id (TableRow of Table), or PartProvider for a
// provider that draws nothing itself. A part is not a tile of the canvas; it shows in its parent's panel.
Part string `json:"part,omitempty"`
// Keywords are the words people look for it by besides its name and description (synonyms, tasks).
Keywords []string `json:"keywords,omitempty"`
// Code is the module a consuming project imports it from, Preset what it is a fixed-props copy of, Status its
// life (stable, new, deprecated) and ReplacedBy what replaces a deprecated one; all optional (see "Optional fields").
Code *Code `json:"code,omitempty"`
Preset *Preset `json:"preset,omitempty"`
Status string `json:"status,omitempty"`
ReplacedBy string `json:"replacedBy,omitempty"`
// From is the base kit the component is inherited from («id@version»), "" for the kit's own; Overrides the base
// one this component replaces. Ns is the namespace to call an inherited component by when it is not the kit's own.
From string `json:"from,omitempty"`
Overrides string `json:"overrides,omitempty"`
Ns string `json:"ns,omitempty"`
// contains filtered or unexported fields
}
Component is a component of the kit.
type ComponentGroup ¶
type ComponentGroup struct {
ID string `json:"id"`
Title string `json:"title"`
Components []Component `json:"components"`
Atlas *Atlas `json:"atlas,omitempty"`
}
ComponentGroup is a group of components.
type ComponentReadiness ¶
type ComponentReadiness struct {
Name string `json:"name"`
// Theme is the theme folder when the kit has several, "" for one.
Theme string `json:"theme,omitempty"`
// Of is the component a preset expands to.
Of string `json:"of,omitempty"`
Level int `json:"level"`
// Next is what is missing for level+1, "" at the top.
Next string `json:"next"`
}
ComponentReadiness is the level of one component and what it lacks for the next one.
type ComponentView ¶
type ComponentView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
ID string `json:"id"`
Name string `json:"name"`
Group string `json:"group"`
Description string `json:"description"`
Keywords []string `json:"keywords,omitempty"`
Status string `json:"status,omitempty"`
ReplacedBy string `json:"replacedBy,omitempty"`
// From is the base kit the component is inherited from («id@version»); Overrides the base one it replaces.
From string `json:"from,omitempty"`
Overrides string `json:"overrides,omitempty"`
// Part is the parent's id for a piece of a compound component, «provider» for a provider.
Part string `json:"part,omitempty"`
// Props are all of them; Required and Optional are their names, so the minimum call is clear at a glance.
Props []Prop `json:"props"`
Required []string `json:"required"`
Optional []string `json:"optional"`
Variants []Variant `json:"variants"`
// Parts are the pieces of a compound component; InSample: the component's sample draws it.
Parts []PartView `json:"parts,omitempty"`
// Sample is the sample's props as the manifest has them; SampleJSX the same as JSX; Call as board markup.
Sample map[string]any `json:"sample,omitempty"`
SampleJSX string `json:"sampleJsx,omitempty"`
Call string `json:"call"`
Code *Code `json:"code,omitempty"`
Preset *Preset `json:"preset,omitempty"`
// Presets are the components that are this one with fixed props.
Presets []PresetView `json:"presets,omitempty"`
// The card (components/<Comp>/README.md): when to use it and when not, examples, and the optional sections.
Card CardView `json:"card"`
// UsedWith is computed from the samples and the layouts' boards, never written by hand.
UsedWith UsedWith `json:"usedWith"`
}
ComponentView is everything an agent needs to use one component.
func ComponentOf ¶
func ComponentOf(dir string, c *Canvas, name string) *ComponentView
ComponentOf builds the view of a component of a canvas read from dir (the cards and boards are read from there). nil when the canvas has no component of this id or name.
type ConflictError ¶
ConflictError: the kit version is installed with other content. Nothing was overwritten.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
func (*ConflictError) Is ¶
func (e *ConflictError) Is(target error) bool
Is lets errors.Is(err, ErrExists) see a conflict.
type Diff ¶
type Diff struct {
Added []string `json:"added"`
Changed []string `json:"changed"`
Removed []string `json:"removed"`
}
Diff is how an incoming kit differs from the installed one with the same id and version.
type Draft ¶
type Draft struct {
// Project is the library project holding the draft's files (its project folder is the kit's root).
Project string `json:"project"`
// Base is the version the draft started from or was last published as.
Base string `json:"base"`
CreatedAt int64 `json:"createdAt"`
// Skip are top-level names of the draft's folder that are the project's, not the kit's.
Skip []string `json:"skip,omitempty"`
// Dir is the project's folder: the kit screen reads the draft as the version DraftVersion from there.
Dir string `json:"dir,omitempty"`
}
Draft is the record of a kit's draft.
type ExportFile ¶
type ExportFile struct {
Path string `json:"path"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
ExportFile is one file of an export.
type ExportOptions ¶
type ExportOptions struct {
WithSources bool
// AcceptRestricted confirms exporting files with a restricted license.
AcceptRestricted bool
Now func() time.Time
}
ExportOptions of BuildManifest.
type Extends ¶
Extends is the kit record's link to a base kit: its id and the version range.
type ExtendsInfo ¶
type ExtendsInfo struct {
Spec string `json:"spec"`
Resolved string `json:"resolved,omitempty"`
Rule string `json:"rule,omitempty"`
Error string `json:"error,omitempty"`
}
ExtendsInfo says how a kit's link to its base came out: the version it resolved to, or the rule it broke and why.
func ResolveBase ¶
func ResolveBase(dir, childID, childVersion string, ex Extends, chain []string) (string, *ExtendsInfo)
ResolveBase picks the version of the base kit ex names for the kit childID at childVersion: the one pinned when the child was published, else the newest installed that satisfies the range (and then pinned). chain holds the ids of the kits above, the child last: it detects a loop and a chain that is too long. The returned info has Rule and Error set when no base can be used.
type FontFace ¶
type FontFace struct {
Family string `json:"family"`
File string `json:"file"`
Weight string `json:"weight,omitempty"`
}
FontFace is a font file of the theme (a path relative to its folder).
type ImportOptions ¶
type ImportOptions struct {
// AsID and AsVersion install the kit under another id or version instead of the one in the file.
AsID, AsVersion string
// DryRun checks everything and installs nothing.
DryRun bool
// Force replaces a version holding other content (repair only).
Force bool
// UpstreamRelease is the current release of Claude Design; a kit not tested on it gets a warning.
UpstreamRelease string
// Assume are kits counted as installed when the kit's requirements are checked: a pack installs its kits in
// order, and a dry run of one kit must not fail on a parent the same pack brings.
Assume []Require
Now func() time.Time
}
ImportOptions of Import.
type ImportResult ¶
type ImportResult struct {
Manifest *Manifest `json:"manifest"`
ID string `json:"id"`
Version string `json:"version"`
// Installed is false for a dry run and for a kit that was already there.
Installed bool `json:"installed"`
Unchanged bool `json:"unchanged"`
Replaced bool `json:"replaced"`
// Conflict is set (and an error returned) for dry runs too, so the caller can show the difference.
Conflict *Diff `json:"conflict,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
ImportResult of Import.
func Import ¶
func Import(dir string, src io.Reader, opt ImportOptions) (ImportResult, error)
Import reads an export, checks it and installs the kit. It installs all or nothing, never overwrites a version with other content (a *ConflictError with the difference is returned), and refuses a file whose bytes do not match its manifest.
type IndexEntry ¶
type IndexEntry struct {
Node string `json:"node"`
Kind string `json:"kind"`
Title string `json:"title"`
// Path is where the node is, for a result's second line: «Шаблоны › Презентация › Обложки».
Path string `json:"path"`
// Words is what it is found by, lower case, separated by spaces.
Words string `json:"words"`
// From is the base kit the node comes from, "" for the kit's own.
From string `json:"from,omitempty"`
}
IndexEntry is a node of the canvas the search finds.
func Search ¶
func Search(index []IndexEntry, q string, limit int) []IndexEntry
Search answers a query over a canvas's index, best first, at most limit (all when limit <= 0).
type IndexGroup ¶
IndexGroup is a group of components in the index.
type IndexTemplate ¶
IndexTemplate is a template with the number of its layouts.
type IndexView ¶
type IndexView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Title string `json:"title"`
Namespace string `json:"namespace"`
Root string `json:"root,omitempty"`
// Strict: projects on the kit are checked in strict mode (kit.strict): only its components, props and tokens.
Strict bool `json:"strict,omitempty"`
// Components are the groups; an item is «Name — what it is for», with «[new]», «[deprecated → X]» or «+N» (parts)
// after the name when it applies. A part is not an item of its own: it is counted under its parent.
Components []IndexGroup `json:"components"`
// Tokens counts the tokens by family; Total is all of them.
Tokens map[string]int `json:"tokens"`
Templates []IndexTemplate `json:"templates,omitempty"`
Next string `json:"next"`
}
IndexView is the compact map of a kit: its groups with a component per line, how many tokens, its templates.
type InitOptions ¶
type InitOptions struct {
ID string // lower case, digits, -
Namespace string // the window global and the boards' prefix
Title string
Source string // library or draft
}
InitOptions name the new kit.
type JSXAttr ¶
type JSXAttr struct {
Name string
Kind byte
Value string
Off int
At int // where the attribute's name starts
}
JSXAttr is an attribute of an element. Kind: 's' a string ("…"), 'e' an expression ({…}), 'b' a bare name (true), '.' a spread ({...x}), 'j' an element as the value. Value is the string or the expression's source; Off is where Value starts in the source (the attribute's name for a bare one).
type JSXElement ¶
type JSXElement struct {
Name string
Off int
Attrs []JSXAttr
// CloseOff is where the name of the closing tag starts, -1 for a self-closing element (or a fragment).
CloseOff int
}
JSXElement is one element of a source; Name is "" for a fragment.
func ScanJSX ¶
func ScanJSX(src string) []JSXElement
ScanJSX reads the elements of a source, in source order.
type JSXImport ¶
type JSXImport struct {
From string
Names map[string]string
Off int
// End is where the statement ends: after its ";" when it has one.
End int
}
JSXImport is one import of a source: local name -> imported name ("default", "*" for a namespace import).
func ScanImports ¶
ScanImports reads the imports of a source; type-only imports are left out.
type Layout ¶
type Layout struct {
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
ID string `json:"id"`
Name string `json:"name"`
Mode string `json:"mode,omitempty"`
Purpose string `json:"purpose,omitempty"`
Components []string `json:"components,omitempty"`
Source string `json:"source,omitempty"`
File string `json:"file"`
}
Layout is one slide layout of a kit's theme.
func FindLayout ¶
FindLayout is the layout at addr, with the folder of its kit version; the newest version when none is named.
type LayoutItem ¶
type LayoutItem struct {
ID string `json:"id"`
Name string `json:"name"`
Section string `json:"section,omitempty"`
Purpose string `json:"purpose,omitempty"`
}
LayoutItem is a layout in the list: enough to choose one.
type Manifest ¶
type Manifest struct {
Schema int `json:"schema"`
ID string `json:"id"`
Version string `json:"version"`
ExportedAt string `json:"exportedAt"`
Upstream []string `json:"upstreamTested,omitempty"`
Requires []Require `json:"requires,omitempty"`
Restricted []Restricted `json:"restricted,omitempty"`
WithSources bool `json:"withSources"`
Files []ExportFile `json:"files"`
// SHA256 is the hash of the sorted "path size sha256" lines: one number for the whole content.
SHA256 string `json:"sha256"`
}
Manifest is kit-export.json.
func BuildManifest ¶
func BuildManifest(dir, id, version string, opt ExportOptions) (*Manifest, error)
BuildManifest reads an installed version and lists what its export holds. When the kit has restricted files and the export is not confirmed it returns the manifest together with ErrRestricted, so the caller can show what is limited.
type Options ¶
type Options struct {
// Force replaces a version installed with other content.
Force bool
// Now is the clock; time.Now when nil.
Now func() time.Time
}
Options of Install.
type PartView ¶
type PartView struct {
ID string `json:"id"`
Description string `json:"description,omitempty"`
InSample bool `json:"inSample"`
}
PartView is a piece of a compound component.
type PlainToken ¶
type PlainToken struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Value string `json:"value"`
Usage string `json:"usage,omitempty"`
Var string `json:"var,omitempty"`
From string `json:"from,omitempty"`
}
PlainToken is any other token of the foundation (a radius, a spacing, a shadow).
type PresetView ¶
PresetView is a preset of a component.
type Problem ¶
type Problem struct {
Rule string `json:"rule"`
Level string `json:"level"`
File string `json:"file"`
Message string `json:"message"`
}
Problem is one finding of Check: the file it is about (slash path from the checked folder) and what is wrong.
type Prop ¶
type Prop struct {
Name string `json:"name"`
Type string `json:"type"`
Values []string `json:"values,omitempty"`
Required bool `json:"required,omitempty"`
Description string `json:"description,omitempty"`
}
Prop is a property of a component.
type PublishOptions ¶
type PublishOptions struct {
// Notes is the short "what changed" of the version.
Notes string
// Changes are the files changed against the version the draft started from.
Changes []Change
// From is the version the draft started from.
From string
Now func() time.Time
}
PublishOptions are what a published version says about itself.
type Published ¶
type Published struct {
Version
Notes string `json:"notes,omitempty"`
From string `json:"from,omitempty"`
Changed []Change `json:"changed,omitempty"`
ChangedCount int `json:"changedCount,omitempty"`
}
Published is a version's record with what the publishing said.
func Publish ¶
func Publish(dir, id, version, src string, skip []string, opt PublishOptions) (Published, error)
Publish copies a draft's folder into the new version <dir>/<id>/<version>/, all or nothing, and records what changed. A version that is already installed is never replaced.
func ReadPublished ¶
ReadPublished is a version's record with its notes; a version installed from an archive has none.
type Restricted ¶
type Restricted struct {
Path string `json:"path"`
Font string `json:"font,omitempty"`
Holder string `json:"holder,omitempty"`
Reason string `json:"reason"`
}
Restricted is a file whose license limits who may have it.
type Result ¶
type Result struct {
Version
// Unchanged: the same tarball was already installed and nothing was written.
Unchanged bool `json:"unchanged"`
// Replaced: Force replaced a different install.
Replaced bool `json:"replaced"`
}
Result of Install.
func Install ¶
Install unpacks a .tar or .tar.gz into <dir>/<id>/<version>/. It is all or nothing: the tarball is unpacked into a hidden folder next to the target and renamed into place, so a half-installed version is never served. Links, devices and paths outside the kit are refused. When the kit has a design-system.json with an id and a version, they must be the ones asked for.
type Rule ¶
type Rule struct {
ID string
Level string
// What the rule wants, in one line: the docs table shows it.
Want string
}
Rule is one thing `harnessly design kit check` looks at. The registry is the only list of them: the check names a problem by its rule, and the docs page agents/design-kits lists every rule — a test fails when the two differ, so a rule the docs do not explain cannot exist, and the docs cannot promise a rule the check does not run.
type SearchHit ¶
type SearchHit struct {
Node string `json:"node"`
Kind string `json:"kind"`
Title string `json:"title"`
Path string `json:"path,omitempty"`
// Ref is what the next tool takes: a component's id (kit_component), a layout's id (kit_template).
Ref string `json:"ref,omitempty"`
// From is the base kit the node comes from, "" for the kit's own.
From string `json:"from,omitempty"`
}
SearchHit is a result of kit search: what the node is and what to ask for next.
type SearchView ¶
type SearchView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Query string `json:"query"`
Results []SearchHit `json:"results"`
}
SearchView is the answer to a query.
type Settings ¶
type Settings struct {
// Owner is the email of the kit's maker; "" is the library's owner.
Owner string `json:"owner,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
}
Settings are a kit's own settings beside its versions, in <kits>/<id>/.settings.json: who made the kit and whether it is for viewing only. While ReadOnly is on, nobody edits the kit, its maker included, until the maker turns it off.
func ReadSettings ¶
ReadSettings are the kit's settings; a kit without the file has the zero ones.
type Slot ¶
type Slot struct {
Key string `json:"key"`
Kind string `json:"kind"`
// Label is what the field is called to a person («Заголовок», «Картинка 2»); "" falls back to the key.
Label string `json:"label,omitempty"`
Sample string `json:"sample,omitempty"`
}
Slot is what an agent fills in a layout: a text (with the sample the template shows), an image, a chart.
type StrictFinding ¶
type StrictFinding struct {
Rule string `json:"rule"`
File string `json:"file"`
Line int `json:"line"`
Col int `json:"col"`
Element string `json:"element,omitempty"`
What string `json:"what"`
Fix string `json:"fix"`
}
StrictFinding is one finding of the strict check. Line and Col are 1-based.
func (StrictFinding) String ¶
func (f StrictFinding) String() string
String is the finding as one line: file:line:col rule — what. Fix: …
type StrictKit ¶
type StrictKit struct {
// contains filtered or unexported fields
}
StrictKit is what the strict check knows of a kit.
func NewStrictKit ¶
NewStrictKit prepares a kit (as assembled, with its bases) for the strict check.
func (*StrictKit) CheckBoard ¶
func (k *StrictKit) CheckBoard(file, src string, local func(from string) bool) []StrictFinding
CheckBoard checks a board written by hand: its <x-import> elements against the kit, every other element inside <x-dc> as not from the kit, its styles and style attributes for raw values, and the elements renderVals() makes with createElement('div', …). local says whether a component file a board imports (from="…") is the project's own.
func (*StrictKit) CheckModule ¶
func (k *StrictKit) CheckModule(file, src string, local bool) []StrictFinding
CheckModule checks a page module or a local component. A page (local false) may hold only the kit's components and local components imported from the project's files; a local component may hold plain HTML of its own, but its values still come from the tokens.
func (*StrictKit) CodeImportOf ¶
CodeImportOf is how the product imports a component of the kit (its preset target for a preset): module and name.
func (*StrictKit) TransformModule ¶
func (k *StrictKit) TransformModule(src, fixtures string) (CodeModule, error)
TransformModule turns a module of the mockup into the product's. fixtures is the module specifier of the page's own fixtures ("./home.fixtures"), "" for a module that is not a page.
type Template ¶
type Template struct {
ID string `json:"id"`
NodeID string `json:"node"`
// Section is the tree section the template lives in: templates, or reference for a template's guide.
Section string `json:"section"`
// Blank: its layouts are a master's empty layouts (background and placeholders), not counted as templates.
Blank bool `json:"blank,omitempty"`
Title string `json:"title"`
Kind string `json:"kind"`
Aspect [2]int `json:"aspect"`
Component string `json:"component,omitempty"`
Cover string `json:"cover,omitempty"`
Description string `json:"description,omitempty"`
Sections []TemplateSection `json:"sections"`
Atlas *Atlas `json:"atlas,omitempty"`
// From is the base kit the template is inherited from, "" for the kit's own.
From string `json:"from,omitempty"`
}
Template is a template (a deck's master): its sections of layouts.
type TemplateItem ¶
type TemplateItem struct {
ID string `json:"id"`
Title string `json:"title"`
Kind string `json:"kind"`
Aspect [2]int `json:"aspect"`
Description string `json:"description,omitempty"`
Layouts []LayoutItem `json:"layouts"`
}
TemplateItem is a template in the list.
type TemplateLayout ¶
type TemplateLayout struct {
ID string `json:"id"`
NodeID string `json:"node"`
Name string `json:"name"`
Purpose string `json:"purpose,omitempty"`
Props map[string]any `json:"props,omitempty"`
Scripts []string `json:"scripts,omitempty"`
Board string `json:"board,omitempty"`
Thumb string `json:"thumb,omitempty"`
Slots []Slot `json:"slots"`
// Cell is the layout's place in its template's atlas, -1 without a picture.
Cell int `json:"cell"`
// Address is how a deck takes the layout (`<kit>/<theme>/<layout>`), "" when the theme does not ship its board.
Address string `json:"address,omitempty"`
// contains filtered or unexported fields
}
TemplateLayout is a layout of a template: its props for the template's component, the scripts it needs, its board and its picture (paths relative to the theme's folder).
type TemplateListView ¶
type TemplateListView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Templates []TemplateItem `json:"templates"`
}
TemplateListView lists the templates (pages, slides) with their layouts' purposes.
func TemplatesOf ¶
func TemplatesOf(c *Canvas, template string) TemplateListView
TemplatesOf lists a canvas's templates (a template's guide and master layouts are left out); only names a template id when template is not empty.
type TemplateSection ¶
type TemplateSection struct {
ID string `json:"id"`
NodeID string `json:"node"`
Title string `json:"title"`
Layouts []TemplateLayout `json:"layouts"`
}
TemplateSection is a section of a template.
type TemplateView ¶
type TemplateView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Template string `json:"template"`
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Aspect [2]int `json:"aspect"`
Purpose string `json:"purpose,omitempty"`
Slots []Slot `json:"slots"`
Props map[string]any `json:"props,omitempty"`
// Address is how a project takes the layout, Board the board's file in the theme.
Address string `json:"address,omitempty"`
Board string `json:"board,omitempty"`
// Source is the board's HTML when it is small enough to read here (MaxTemplateSource bytes), else BoardBytes tells its size.
Source string `json:"source,omitempty"`
BoardBytes int `json:"boardBytes,omitempty"`
}
TemplateView is one layout with what an agent fills and copies.
func TemplateOf ¶
func TemplateOf(dir string, c *Canvas, id string) *TemplateView
TemplateOf finds a layout by its id (or a template's id: its first layout) and reads its board from dir.
type TokenView ¶
type TokenView struct {
Name string `json:"name"`
Var string `json:"var,omitempty"`
Value string `json:"value,omitempty"`
Values map[string]string `json:"values,omitempty"`
Usage string `json:"usage,omitempty"`
// From is the base kit the token is inherited from.
From string `json:"from,omitempty"`
}
TokenView is a token as an agent uses it: its name, the CSS variable, the value (per mode for a colour).
type TokensView ¶
type TokensView struct {
Schema string `json:"schema"`
Kit string `json:"kit"`
Version string `json:"version"`
Theme string `json:"theme"`
Prefix string `json:"prefix,omitempty"`
Modes []string `json:"modes,omitempty"`
Groups map[string][]TokenView `json:"groups"`
}
TokensView is the foundation of a theme by family: color, type, then radius, spacing… as the kit names them.
func TokensOf ¶
func TokensOf(c *Canvas, group string) TokensView
TokensOf lists a canvas's tokens; group names one family ("" all). A token with no explicit var gets the kit's prefix and its name, which is how tokens.css names them; none without a prefix.
type TypeStyle ¶
type TypeStyle struct {
ID string `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Family string `json:"family"`
Size string `json:"size"`
Line string `json:"line,omitempty"`
Weight string `json:"weight,omitempty"`
}
TypeStyle is a text style of the foundation.
type UsedWith ¶
UsedWith: the components whose samples hold this one or are held by its sample, and the layouts whose boards use it.
type Variant ¶
type Variant struct {
ID string `json:"id"`
Name string `json:"name"`
Props map[string]any `json:"props,omitempty"`
}
Variant is a named set of a component's props.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package formats moves a kit's tokens, descriptions and component drafts to and from other people's formats: W3C Design Tokens (DTCG), CSS variables, Tailwind, DESIGN.md, a built Storybook, a Figma variables export.
|
Package formats moves a kit's tokens, descriptions and component drafts to and from other people's formats: W3C Design Tokens (DTCG), CSS variables, Tailwind, DESIGN.md, a built Storybook, a Figma variables export. |
|
Package kitadd makes a library kit from a package in one command (`harnessly design kit add npm:<package>` or `shadcn:<registry>`) and brings it to a new version of the package (`kit update`): the package's exports built into one browser script on the page's React, props read from its types, its CSS variables as tokens, a card per component.
|
Package kitadd makes a library kit from a package in one command (`harnessly design kit add npm:<package>` or `shadcn:<registry>`) and brings it to a new version of the package (`kit update`): the package's exports built into one browser script on the page's React, props read from its types, its CSS variables as tokens, a card per component. |