Documentation
¶
Overview ¶
Package kit is Flatte's design-system components: pane headers, tabs, list rows, segmented choices, badges, sections, setting rows, empty states and popovers, built from layout nodes in the theme's roles (fills, text roles and colors) and token sizes (layout.RowSize, BarSize…). They hold no colors or lengths of their own, so a theme — its palette, density and roundness — restyles them all, in a window and in a terminal alike.
Each component is a plain struct; Layout builds its tree, as flatui widgets do. Components are stateless: selection, focus and values come from app state, and clicks arrive as MouseEvents targeting the IDs each one documents. Every slot that takes nodes (Actions, Trailing, Children) takes any layout.Node, so an app can put its own pieces where the recipe leaves room.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
ID string
Icon layout.IconName
Glyph string // the terminal spelling ("" : the icon's glyph)
Tooltip string
}
Action is a small icon button inside a row, a tab or a pane header — a tab's close, a row's reveal: in a window a compact square with the hover wash under its icon, in a terminal its glyph. Its node ID is ID.
type Disclosure ¶
type Disclosure int
Disclosure is a tree row's expand state (ListRow.Disclosure).
const ( // DisclosureNone is no chevron and no room for one (a flat list). DisclosureNone Disclosure = iota // DisclosureLeaf is the chevron's room, empty: a file among folders. DisclosureLeaf DisclosureClosed DisclosureOpen )
type EmptyState ¶
type EmptyState struct {
ID string
Icon layout.IconName
Title string
Hint string
Actions []layout.Node
// Inline sets it at the top left with the hint wrapping, for a narrow
// sidebar, instead of centered in the pane.
Inline bool
}
EmptyState fills a pane with nothing to show: an icon, a title, a hint and actions (buttons), centered.
func (EmptyState) Layout ¶
func (e EmptyState) Layout() layout.Node
type ListRow ¶
type ListRow struct {
ID string
Icon layout.IconName
Title string
Meta string
Trailing []layout.Node
Selected bool
Active bool
Indent int
Disabled bool
// Disclosure is a tree row's chevron, before the icon: DisclosureLeaf
// keeps the chevron's room empty so leaves line up with folders.
Disclosure Disclosure
// TitleColor colors the title (and dims the icon with it) while the row
// stays clickable: secondary files, disabled-grey ignored entries.
TitleColor layout.TextColor
// Italic sets the title in italics (a placeholder, a preview).
Italic bool
}
ListRow is one row of a list or tree at the row height: an optional leading icon, a title, meta text after it, and trailing nodes (a badge, a count). Selected rows take the selection fill — the strong one when Active (the list has focus), the quiet one otherwise; rows show hover in a window. Indent shifts the content right by steps (tree depth).
type PaneHeader ¶
type PaneHeader struct {
ID string
Title string
Meta string
Actions []layout.Node
// Active brightens the caption while its pane has keyboard focus.
Active bool
// Body follows the title and takes the room before the actions: a
// panel's tab strip (kit.Tabs), a filter field.
Body layout.Node
}
PaneHeader is the bar on top of a pane or sidebar: a caption title, optional meta text beside it, and trailing actions (icon buttons, usually) at the right, on the chrome surface at the bar height.
func (PaneHeader) Layout ¶
func (h PaneHeader) Layout() layout.Node
type Popover ¶
Popover is a raised panel over the frame: a quick-open list, a menu of choices. Anchor places it under the node with that ID (empty: centered); Width is its width (zero: its content's).
type Segmented ¶
Segmented is a choice of a few options shown side by side, the chosen one filled. Option i's node ID is ID + ":" + its index (OptionID).
type Setting ¶
Setting is a settings row: a name with an optional description under it, and the control (a toggle, a segmented choice, a field) at the right.
type Tab ¶
type Tab struct {
ID string
Label string
Icon layout.IconName
Modified bool
Italic bool
Close string
}
Tab is one tab of a Tabs strip. Close is its close action's ID (empty: none); Modified shows a dot in the close action's place (an unsaved file), still clickable by the same ID. Italic marks a preview tab.
type Tabs ¶
Tabs is a tab strip at the bar height on the chrome surface: the active tab sits on the content surface in strong text under an accent edge (Box.Edge, in a window), the others in secondary text. Each tab's node ID is Tab.ID; Trailing nodes (a new-tab button, a breadcrumb) follow the tabs directly. Fill shares the strip's width equally between the tabs (too many to fit at their names' width): long names end in "…".