kit

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

README

mygo-kit

The look, window and tray shared by my MyGo apps. It is built for them, not as a general library, and its API changes without notice.

License

GPL-3.0-or-later

Documentation

Overview

Package kit is how the MyGo apps of one author look and move: the theme, the window's frame, the surfaces pages are made of and the controls drawn differently from MyGo's. DESIGN.md says when to use which.

Index

Constants

View Source
const (
	SidebarWidth = 220
	// PageSide is the room beside a page's content.
	PageSide = 32
	// PanelRadius rounds cards and panels; controls inside them take the
	// theme's smaller one.
	PanelRadius = 12
	// TitleSize is the size of a page's title.
	TitleSize = 20
	// RowMinHeight is a setting row's height with a one-line label.
	RowMinHeight = 56
	// ContentWidth is the widest a NarrowPage's content grows, so that a
	// row's label and its control stay within one glance.
	ContentWidth = 1120
)

Sizes, in DIPs.

View Source
const (
	TintDuration   = 120 * time.Millisecond
	EnterDuration  = 180 * time.Millisecond
	ResizeDuration = 200 * time.Millisecond
)

How long the transitions take. Menus, popups, dialogs and toasts move as MyGo moves them.

Variables

View Source
var (
	// Flow moves what a row coming or going pushes around.
	Flow = ui.ElementTransition{Animation: &resize, Position: true, Size: true}
	// RowMotion is Flow for the row itself.
	RowMotion = ui.ElementTransition{Animation: &resize, Position: true, Size: true,
		Enter: &ui.Motion{Collapse: true}, Exit: &ui.Motion{Collapse: true}}
	// Tint fades a color that follows the pointer or a state. It is short,
	// as the pointer crosses many items on its way to one.
	Tint = ui.ElementTransition{Colors: true, Duration: TintDuration}
	// PageEnter brings a page up into place, as Windows' Settings do. The
	// page before it goes at once, so that two never show together.
	PageEnter = ui.ElementTransition{Colors: true, Duration: EnterDuration,
		Enter: &ui.Motion{Y: 12}}
)

The only transitions. An element that comes and goes needs a Key, as do its siblings after it.

Functions

func Apply

func Apply(c *ui.Context)

Apply sets the window's theme: Windows 11's surfaces, translucent so that Mica shows through, and text colors that reach 4.5:1 on them. Call it first in the view.

func Card

func Card(c *ui.Context, body func()) ui.Element

Card is a surface that holds anything.

func Empty

func Empty(c *ui.Context, icon *ui.SVG, title, detail string, actions func()) ui.Element

Empty stands where a page or a list has nothing to show: an icon, a title saying what is missing, a sentence on what brings it when detail is not empty, and the actions that do, the first a ui.PrimaryButton.

func Figure

func Figure(e ui.Element) ui.Element

Figure shows a number that changes in place with digits of one width, so that it holds its width.

func Heading

func Heading(c *ui.Context, s string) ui.Element

Heading names the panel below it.

func Icon

func Icon(shapes string) *ui.SVG

Icon makes an icon of the shapes of a 24-unit Lucide icon.

func IconButton

func IconButton(c *ui.Context, key string, glyph *ui.SVG, label, tip string) ui.Element

IconButton is a button that shows only glyph, with no face until the pointer is over it. label names it to assistive technology and to tests, and shows as its tooltip unless tip says more.

func Link(c *ui.Context, label, url string) ui.Element

Link is ui.Link, lighter on a dark surface, where Windows' accent is too deep for text.

func Muted

func Muted(c *ui.Context, s string) ui.Element

Muted is secondary text: details, captions, values beside a label.

func NarrowPage

func NarrowPage(c *ui.Context, body func()) ui.Element

NarrowPage is a Page whose content grows no wider than ContentWidth, in the middle of a wider window, for pages of settings, whose rows read badly when far apart.

func NavItem(c *ui.Context, id string, icon *ui.SVG, label string, chosen bool, extra func()) ui.Element

NavItem is an item of a ui.Sidebar. The chosen one is tinted with the accent and marked with a pill; MyGo would fill it with the accent while the list has the focus. extra adds to the item's end, as a badge.

func Page

func Page(c *ui.Context, body func()) ui.Element

Page is a page that scrolls, its content one column as wide as the window. Pages that hold a table or an editor lay out their own, with a header row padded Top(c), PageSide.

func PageTitle

func PageTitle(c *ui.Context, s string, back *Back) ui.Element

PageTitle heads a page: in the same place on every page, as tall as a row of buttons beside it, after the page it opened from when back is not nil, as Windows' Settings show where a page is. Escape and Alt+Left then lead back too; a dialog or menu that is open takes Escape first.

func Panel

func Panel(c *ui.Context, rows func()) ui.Element

Panel holds rows as one surface, with a hairline between them.

func Segmented

func Segmented(c *ui.Context, id string, selected *int, labels ...string) ui.Element

Segmented is ui.Segmented with a thumb that slides to the segment chosen. id tells it from the other controls in the window.

func SettingRow

func SettingRow(c *ui.Context, label, detail string, control func()) ui.Element

SettingRow is a label, with a sentence below it when detail is not empty, and a control at its end. One that comes and goes needs a Key, as do those below it in its panel.

func Shell

func Shell(c *ui.Context, sidebar, page func())

Shell lays out a main window: the sidebar and beside it the page, both on the window's material, below the band of the system's window buttons, which moves the window. The app's name and the page's title share a line.

func SidebarHeader

func SidebarHeader(c *ui.Context, name, detail string) ui.Element

SidebarHeader names the app at the top of the sidebar, and moves the window.

func Surface

func Surface(e ui.Element, t *ui.Theme) ui.Element

Surface styles a raised box: a fill one step above the window and a faint ring, darker in the light and lighter in the dark, no shadow.

func Title

func Title(c *ui.Context, s string) ui.Element

Title is the PageTitle of a page that opened from none.

func Top

func Top(c *ui.Context) float32

Top is the room above a page's title: the band of the window buttons.

func Window

Window gives a main window its frame: no title bar, the system's window buttons over the page, and Mica behind it.

Types

type Back

type Back struct {
	// Parent is the title of the page it leads to.
	Parent string
	// Label names the link to assistive technology, as "Back".
	Label string
	Go    func()
}

Back leads from a page to the one it opened from.

Directories

Path Synopsis
Package desk is what the apps do with the desktop around their windows: the theme they show, the main window and the tray icon.
Package desk is what the apps do with the desktop around their windows: the theme they show, the main window and the tray icon.
Package kittest checks in an app's tests that its pages keep to the kit.
Package kittest checks in an app's tests that its pages keep to the kit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL