workspaceui

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspaceui composes NSGo's themed controls into a reusable workspace. Applications supply destinations, content and actions. All colors follow the current theme.

Index

Constants

View Source
const (
	// SpaceXS is between a mark and what it marks, and inside a small cell.
	SpaceXS core.Points = 4
	// SpaceS is a pane's inset from its edges, and between a bar's
	// controls.
	SpaceS core.Points = 8
	// SpaceM is between a pane's blocks.
	SpaceM core.Points = 12
	// SpaceL is a reading pane's inset.
	SpaceL core.Points = 16
	// SpaceXL is a page's inset.
	SpaceXL core.Points = 24
)

The kit's spacing: the steps an app's paddings and gaps take, so that no app writes one as a number (the standard for an app, rule 2). They are the steps the kit's own parts and NSGo's controls stand on.

View Source
const FlagCount = 7

FlagCount is how many flag colors there are.

View Source
const FontFamily = `"Inter Variable", Inter, sans-serif`

FontFamily is the family the kit sets its text in: Inter, then the system's sans-serif face. NSGo finds a registered font by the family its file names, and the variable file Apply registers names "Inter Variable"; "Inter" is a system's own static faces.

Variables

This section is empty.

Functions

func Apply added in v0.2.0

func Apply(cx *core.Scope) error

Apply gives cx, and every view built from it, the Frostyard theme, and registers Inter with the platform. An app calls it once at its root, before it builds a view, and puts its views in a Frame. The theme is set even when it returns an error: the text then falls back to the system's sans-serif face.

func DialogPanel added in v0.3.0

func DialogPanel(cx *core.Scope) func() core.Style

DialogPanel is the ground of a panel that floats over the window: a dialog, an alert, the command palette, a popover and a toast (their StyleFunc). It is Frostyard's panel, opaque. NSGo's own is the page's color at 92% over a blur, and a platform that draws no blur, as Linux, shows the view under the panel through it. NSGo's menu takes no style, so a menu keeps NSGo's ground.

func Frame added in v0.2.0

func Frame(children ...core.Node) core.Node

Frame is the root view of a window. It fills the window, paints the theme's ground under everything in it, and sets the text's color and the kit's font family, which the texts inside it inherit.

func Heading added in v0.5.0

func Heading(level int) core.Style

Heading is the type of a heading in a document an app draws, such as a note's: level 1 the largest, 24 points, then 2 less a level to level 6, 14, each semibold. A level outside 1 to 6 is the nearest of them. An app's own chrome takes NSGo's type styles, not these.

func Indent added in v0.4.0

func Indent(depth int) core.Points

Indent is the leading inset of a row depth levels inside a tree or an outline: 0 at the top.

func InspectorGroup

func InspectorGroup(label string, children ...core.Node) core.Node

InspectorGroup lays out labeled values and their actions on one surface.

func InspectorRow

func InspectorRow(label string, value func() string, actions ...core.Node) core.Node

func KeepWindow added in v0.5.0

func KeepWindow(cx *core.Scope, minWidth, minHeight core.Points)

KeepWindow shows the app's window as the device kept it, and keeps it as it changes (the standard for an app, rule 8): its size, and its place where the platform reports one. The size kept is the window's own where the platform reports it, and the content's elsewhere. It is kept in the app's storage under "window". A window under minWidth by minHeight is not kept, nor a maximized one's size, which leaves the size it had before. A browser's window is the browser's: there KeepWindow does nothing. Call it once, from the root.

func Message

func Message(outgoing bool, body core.Node, extras ...core.Node) core.Node

Message renders selectable, searchable Markdown in the gallery's incoming or outgoing layout.

func Page

func Page(children ...core.Node) core.Node

Page gives settings, forms and detail screens a readable measure on a wide window.

func Row

func Row(children ...core.Node) core.Node

func SoftRows added in v0.3.0

func SoftRows(cx *core.Scope) func() core.Style

SoftRows is the style of the rows of NSGo's list (List.RowStyleFunc): rounded, a hover fill under the pointer, and the Frostyard soft fill when chosen. A chosen row keeps its own text colors (ADR-0014).

func Stack

func Stack(children ...core.Node) core.Node

func Theme added in v0.2.0

func Theme() *core.Theme

Theme returns the Frostyard look as an NSGo theme: Frostyard for the dark appearance and Frostyard light for the light one, with the colors of docs/specs/frostyard-theme.md. It keeps NSGo's corners. Each call returns a theme of its own.

Types

type AppearanceChoice added in v0.2.0

type AppearanceChoice struct {
	// Value is the appearance chosen; nil is the system's.
	Value    func() core.Appearance
	OnChange func(core.Appearance)
}

AppearanceChoice is the setting that shows an app light, dark or as the system does: a segmented control of the three. A press shows the choice at once (Scope.SetAppearance) and then calls OnChange, where the app saves it. At its start an app sets a saved choice itself, with SetAppearance, after Apply.

func (AppearanceChoice) Render added in v0.2.0

func (a AppearanceChoice) Render(cx *core.Scope) core.Node
type Banner struct {
	Tone Tone
	Icon func() *core.SVG
	Text string
	// Action names the button; empty leaves it out.
	Action   string
	OnAction func()
}

Banner is a notice inside a pane: a tone's fill and line, an icon in the tone's color, a sentence, and at most one button at its end. It is for what a pane has to say about its content (blocked images, a failed send); Notice is for the app's own messages over the window.

func (Banner) Render added in v0.3.0

func (b Banner) Render(cx *core.Scope) core.Node

type BranchLabel

type BranchLabel struct {
	Text     string
	Icon     func() *core.SVG
	Expanded func() bool
	Trailing core.Node
}

BranchLabel is the content of a sidebar group row. A nil Expanded reserves the chevron's space for a group that has no children.

func (BranchLabel) Render

func (b BranchLabel) Render(cx *core.Scope) core.Node

type Card

type Card struct{ Children []core.Node }

Card keeps one item's content and actions together on a themed surface.

func (Card) Render

func (c Card) Render(cx *core.Scope) core.Node

type ChildLabel

type ChildLabel struct {
	Text     string
	Icon     func() *core.SVG
	Depth    int
	Last     bool
	Trailing core.Node
}

ChildLabel indents the entire row content and draws a connector back to its parent's icon. Last ends the guide at this child's midpoint.

func (ChildLabel) Render

func (r ChildLabel) Render(cx *core.Scope) core.Node

type Colors added in v0.2.0

type Colors struct {
	// contains filtered or unexported fields
}

Colors reads the Frostyard colors NSGo has no role for from cx's palette, in the appearance shown. Read them inside a StyleFunc, so that a view follows a change of appearance. Under a theme other than Theme they are the zero color.

func ColorsOf added in v0.2.0

func ColorsOf(cx *core.Scope) Colors

ColorsOf returns the kit's colors for cx. NSGo's own roles are ui.ColorsOf's.

func (Colors) Chrome added in v0.2.0

func (c Colors) Chrome() core.Color

Chrome is the ground of the window around its content: the navigation and the toolbar.

func (Colors) Fill added in v0.2.0

func (c Colors) Fill(t Tone) core.Color

Fill is the ground of a banner, a tag or a badge of tone t.

func (Colors) Flag added in v0.4.0

func (c Colors) Flag(n int) core.Color

Flag is flag n's color, 1 to FlagCount: red, orange, yellow, green, blue, purple and gray, each a little lighter in the dark theme. A number outside them is the first.

func (Colors) Label added in v0.2.0

func (c Colors) Label() core.Color

Label is the color of a section's caption.

func (Colors) Line added in v0.2.0

func (c Colors) Line(t Tone) core.Color

Line is the hairline around a fill of tone t.

func (Colors) Page added in v0.4.0

func (c Colors) Page() core.Color

Page is the ground of a page that is not the app's own, such as a message from its sender: white in both themes, so that the page reads as its author made it, and a part of it not yet painted is not a hole in the window.

func (Colors) Panel added in v0.2.0

func (c Colors) Panel() core.Color

Panel is the ground of a card, a menu and a dialog.

func (Colors) Selected added in v0.2.0

func (c Colors) Selected() core.Color

Selected is the fill of a chosen row. The row keeps its own text colors.

func (Colors) SelectedText added in v0.2.0

func (c Colors) SelectedText() core.Color

SelectedText is the color of a chosen item that changes its text, such as a tab.

type ConnectionItem added in v0.3.0

type ConnectionItem struct {
	Tone Tone
	Text func() string
}

ConnectionItem is the item at the foot of a navigation that says where the app is connected: a dot in the tone's color and a line of text. Success is a live connection, Warning one being made again.

func (ConnectionItem) Render added in v0.3.0

func (c ConnectionItem) Render(cx *core.Scope) core.Node

type Conversation

type Conversation struct {
	State      *chat.ConversationState
	Transcript []core.Node
	Footer     core.Node
	// FooterMode selects an application-owned decision or read-only footer.
	// The empty mode uses Footer. Reactive updates within a mode keep its editor.
	FooterMode func() string
	Alternate  func(*core.Scope, string) core.Node
}

Conversation uses the gallery's scroll-following transcript, jump control and glass composer. A caller can substitute a read-only footer while retaining the same transcript.

func (Conversation) Render

func (v Conversation) Render(cx *core.Scope) core.Node

type ConversationEntries

type ConversationEntries[T any] struct {
	Items      func() []T
	Key        func(T) string
	Content    func(*core.Scope, func() T) core.Node
	Reveal     func() string
	OnRevealed func(string)
}

ConversationEntries mounts each application-supplied item once per key. Reveal names a mounted item to scroll to after layout. The caller owns paging, ordering and the meaning of each entry.

func (ConversationEntries[T]) Render

func (v ConversationEntries[T]) Render(*core.Scope) core.Node

type EmptyState added in v0.3.0

type EmptyState struct {
	Icon        func() *core.SVG
	Title, Hint string
	// Actions are the buttons under the hint: what to do about the pane
	// being empty, the first of them the pane's one filled button. They
	// wrap in a narrow pane.
	Actions []core.Node
}

EmptyState is what a pane shows with nothing in it: an icon, a line that says so, and a hint of what to do.

func (EmptyState) Render added in v0.3.0

func (e EmptyState) Render(cx *core.Scope) core.Node

type FileExplorer

type FileExplorer struct {
	Header, Tree, Preview core.Node
	HasPreview            func() bool
	BackToTree            func()
	// TreeWidth is the tree's width as the explorer opens, and
	// OnTreeWidthChange hears a drag of its edge change it: an app keeps
	// the width with it.
	TreeWidth         core.Points
	OnTreeWidthChange func(core.Points)
}

FileExplorer gives a directory tree and its preview separate scroll areas. Compact windows show one pane at a time and keep the tree within reach.

func (FileExplorer) Render

func (e FileExplorer) Render(cx *core.Scope) core.Node

type Inspector

type Inspector struct {
	Icon      func() *core.SVG
	Title     string
	Available func() bool
	Content   func(*core.Scope) core.Node
	// Open is whether the panel shows as the shell opens, in a window
	// wide enough to dock it. OnOpenChange hears a person open and close
	// it with its button: an app keeps the panel's state with them. What
	// the shell closes by itself is not told: a panel no longer
	// available, or one the auxiliary panel takes the room of.
	Open         bool
	OnOpenChange func(bool)
}

Inspector supplies contextual content for the shell's optional right panel. Available controls which destinations offer it. Content is built on demand.

type NavLabel struct {
	Icon   func() *core.SVG
	Text   string
	Count  int
	Unread bool
	// Tint colors the icon: a flag's row in its flag's color. Nil is the
	// accent, as every other row's.
	Tint func() core.Color
}

NavLabel is the content of a row of NSGo's sidebar (SidebarItem.Content): an icon, a name, and a count at the row's end in figures of one width. A count of 0 is not shown. An Unread count takes the text's color and a heavier weight; any other is muted.

func (n NavLabel) Render(cx *core.Scope) core.Node

type Notice

type Notice struct {
	Kind          ui.ToastType
	Title, Detail string
	OnDismiss     func()
}

Notice displays one dismissible message above the workspace. Its overlay measures the card in normal flow, including wrapped text on narrow screens.

func (Notice) Render

func (n Notice) Render(cx *core.Scope) core.Node

type PageFrame added in v0.4.0

type PageFrame struct {
	Page core.Node
	Size core.Style
}

PageFrame sets a page that is not the app's own, such as a message from its sender, inside a hairline with rounded corners on the kit's page ground: in the dark theme it reads as a page placed in the window. Size is the frame's own size in its parent, as a style: ui.FillRest, or a height.

func (PageFrame) Render added in v0.4.0

func (f PageFrame) Render(cx *core.Scope) core.Node

type PaneWidths

type PaneWidths struct{ Navigation, Inspector, Auxiliary core.Points }

type SearchField added in v0.3.0

type SearchField struct {
	// Placeholder is also what assistive technology reads.
	Placeholder string
	// Keys is the shortcut shown while the field is empty, such as "mod+f";
	// empty shows none.
	Keys     string
	Value    func() string
	OnChange func(string)
	OnSubmit func(string)
	Ref      *core.Ref
}

SearchField is a search box, which NSGo has none of: a search icon, the platform's text field, and at its end the keys that focus it while it is empty, or a button that clears it while it holds text. The app binds Keys itself and focuses Ref.

func (SearchField) Render added in v0.3.0

func (f SearchField) Render(cx *core.Scope) core.Node

type Section

type Section struct {
	Title         string
	Count         func() int
	InitiallyOpen bool
	Content       func(*core.Scope) core.Node
}

Section groups cards under a full-width disclosure. Its content is built only while open, so a folded archive costs a single header.

func (Section) Render

func (s Section) Render(cx *core.Scope) core.Node

type Shell

type Shell struct {
	Brand                                                  string
	Header, Actions, SidebarHeader, SidebarFooter, Content []core.Node
	Sections                                               func() []ui.SidebarSection
	Selected                                               func() string
	Navigate                                               func(string)
	// Disclose handles branch rows without navigating away or closing the compact rail.
	Disclose       func(id string) bool
	Inspector      *Inspector
	Auxiliary      *Inspector
	Widths         PaneWidths
	OnWidthsChange func(PaneWidths)
}

Shell shows a resizable navigation sidebar and a content pane. On compact windows the navigation can take the full width and closes after a selection.

func (Shell) Render

func (s Shell) Render(cx *core.Scope) core.Node

type SummaryRow added in v0.3.0

type SummaryRow struct {
	// Unread shows the dot and sets the subject in a heavier weight.
	Unread bool
	// Name is whose avatar it is: Image, or the initials of Name.
	Name  string
	Image core.ImageSource
	// Title is the first line, usually the sender; When ends it.
	Title, When string
	Subject     string
	// Marks end the subject's line: small icons and a count.
	Marks []core.Node
	// Preview shows on up to PreviewLines lines; 0 leaves it out.
	Preview      string
	PreviewLines int
	// Scale multiplies the row's text sizes, for an app's own text size
	// setting; 0 is 1. The dot and the avatar keep their sizes.
	Scale float32
}

SummaryRow is the content of a row of a list of things with a sender or an owner, such as messages: a gutter for the unread dot, an avatar, then the title with When at the row's end, the subject with the row's marks at its end, and up to PreviewLines lines of preview. The row keeps its text inside its width: a long title or subject is cut, not the date or a mark.

func (SummaryRow) Render added in v0.3.0

func (r SummaryRow) Render(cx *core.Scope) core.Node

type Tone added in v0.2.0

type Tone uint8

Tone is the meaning a fill or a line carries: none, the accent, or one of the three states.

const (
	Neutral Tone = iota
	Accent
	Success
	Warning
	Danger
)

Jump to

Keyboard shortcuts

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