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
- func Apply(cx *core.Scope) error
- func DialogPanel(cx *core.Scope) func() core.Style
- func Frame(children ...core.Node) core.Node
- func Heading(level int) core.Style
- func Indent(depth int) core.Points
- func InspectorGroup(label string, children ...core.Node) core.Node
- func InspectorRow(label string, value func() string, actions ...core.Node) core.Node
- func KeepWindow(cx *core.Scope, minWidth, minHeight core.Points)
- func Message(outgoing bool, body core.Node, extras ...core.Node) core.Node
- func Page(children ...core.Node) core.Node
- func Row(children ...core.Node) core.Node
- func SoftRows(cx *core.Scope) func() core.Style
- func Stack(children ...core.Node) core.Node
- func Theme() *core.Theme
- type AppearanceChoice
- type Banner
- type BranchLabel
- type Card
- type ChildLabel
- type Colors
- func (c Colors) Chrome() core.Color
- func (c Colors) Fill(t Tone) core.Color
- func (c Colors) Flag(n int) core.Color
- func (c Colors) Label() core.Color
- func (c Colors) Line(t Tone) core.Color
- func (c Colors) Page() core.Color
- func (c Colors) Panel() core.Color
- func (c Colors) Selected() core.Color
- func (c Colors) SelectedText() core.Color
- type ConnectionItem
- type Conversation
- type ConversationEntries
- type EmptyState
- type FileExplorer
- type Inspector
- type NavLabel
- type Notice
- type PageFrame
- type PaneWidths
- type SearchField
- type Section
- type Shell
- type SummaryRow
- type Tone
Constants ¶
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.
const FlagCount = 7
FlagCount is how many flag colors there are.
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
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
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
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
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
Indent is the leading inset of a row depth levels inside a tree or an outline: 0 at the top.
func InspectorGroup ¶
InspectorGroup lays out labeled values and their actions on one surface.
func InspectorRow ¶
func KeepWindow ¶ added in v0.5.0
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 ¶
Message renders selectable, searchable Markdown in the gallery's incoming or outgoing layout.
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.
type Banner ¶ added in v0.3.0
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.
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.
type ChildLabel ¶
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.
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
ColorsOf returns the kit's colors for cx. NSGo's own roles are ui.ColorsOf's.
func (Colors) Chrome ¶ added in v0.2.0
Chrome is the ground of the window around its content: the navigation and the toolbar.
func (Colors) Flag ¶ added in v0.4.0
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) Page ¶ added in v0.4.0
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) Selected ¶ added in v0.2.0
Selected is the fill of a chosen row. The row keeps its own text colors.
func (Colors) SelectedText ¶ added in v0.2.0
SelectedText is the color of a chosen item that changes its text, such as a tab.
type ConnectionItem ¶ added in v0.3.0
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.
type Conversation ¶
type Conversation struct {
State *chat.ConversationState
Transcript []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.
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.
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.
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.
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.
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 ¶ added in v0.3.0
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.
type Notice ¶
Notice displays one dismissible message above the workspace. Its overlay measures the card in normal flow, including wrapped text on narrow screens.
type PageFrame ¶ added in v0.4.0
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.
type PaneWidths ¶
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.
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.
type Shell ¶
type Shell struct {
Brand string
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.
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.