Widget catalog

Feedback and overlays

Widgets that report progress and results, and the ones that float above the page, shown with the overlay.Show... functions.

control.ProgressBar

Shows how much is done as a bar that fills from the left. A new value slides into place. With Indeterminate it shows work of unknown length as a band that crosses the bar again and again, and a screen reader hears a busy indicator with no value. The band moves only while it is seen, and stands in the middle when the window asks for less motion.

Package github.com/bankai-tensei/gowaku/widgets/control

control.ProgressBarcontrol.ProgressBar
basic.SizedBox{Width: 260, Child: basic.Column{Size: layout.MainMin, Cross: layout.CrossStretch, Spacing: theme.Space16, Children: []core.Widget{
	control.ProgressBar{Value: 0.62, Label: "Library sync"},
	control.ProgressBar{Value: 0.25, Label: "Upload"},
	control.ProgressBar{Indeterminate: true, Label: "Connecting"},
}}}

control.ProgressRing

Shows how much is done as a ring that fills clockwise from twelve, with a child in its middle. With Indeterminate it is a spinner for work of unknown length: an arc turns around the ring. A screen reader hears a busy indicator with no value, named Loading in the language of the window when it has no label. The arc turns only while it is seen, and stands at twelve when the window asks for less motion.

Package github.com/bankai-tensei/gowaku/widgets/control

control.ProgressRingcontrol.ProgressRing
themed(func(th *theme.Theme) core.Widget {
	return basic.Row{Size: layout.MainMin, Spacing: theme.Space24, Cross: layout.CrossCenter, Children: []core.Widget{
		control.ProgressRing{Value: 0.32, Label: "Album art"},
		control.ProgressRing{Value: 0.75, Size: 48, Color: th.Color.Success, Label: "Lyrics", Child: basic.Text{
			Content: "75", Style: colored(th.Text.Caption, th.Color.Ink2),
		}},
		control.ProgressRing{Indeterminate: true, Label: "Syncing"},
	}}
})

control.Skeleton

Stands in for content that is still loading. One band of light crosses the window, only while a skeleton is seen, and stops when the OS asks for less motion. SkeletonGroup tells assistive technology that it is loading.

Package github.com/bankai-tensei/gowaku/widgets/control · Also control.SkeletonShape, control.SkeletonText, control.SkeletonGroup

control.Skeletoncontrol.Skeleton
themed(func(th *theme.Theme) core.Widget {
	return basic.Container{Width: 320, Color: th.Color.Card, Radius: th.Radius.Group, Padding: geom.All(theme.Space16), Child: control.SkeletonGroup{
		Label: "Loading messages",
		Child: basic.Row{Cross: layout.CrossStart, Spacing: theme.Space12, Children: []core.Widget{
			control.Skeleton{Shape: control.SkeletonCircle, Width: 40},
			basic.Expanded{Child: basic.Column{Size: layout.MainMin, Cross: layout.CrossStart, Spacing: theme.Space8, Children: []core.Widget{
				control.Skeleton{Width: 96, Height: 14},
				control.SkeletonText{Lines: 3},
			}}},
		}},
	}}
})

overlay.Tooltip

A short label that shows when the pointer rests on its child or the keyboard moves to it. Assistive technology gets it as the description.

Package github.com/bankai-tensei/gowaku/widgets/overlay

overlay.Tooltipoverlay.Tooltip
tool := func(label, tip string) core.Widget {
	return overlay.Tooltip{Message: tip, Child: control.Button{Label: label, Style: control.ButtonQuiet, OnPress: func() {}}}
}
return basic.Row{Size: layout.MainMin, Spacing: theme.Space4, Children: []core.Widget{
	tool("Bold", "Bold (Ctrl+B)"),
	tool("Italic", "Italic (Ctrl+I)"),
	tool("Link", "Insert a link (Ctrl+K)"),
}}

overlay.Toast

A short message at the bottom of the window for a few seconds, with an optional action such as Undo. Show it with ShowToast.

Package github.com/bankai-tensei/gowaku/widgets/overlay

overlay.Toastoverlay.Toast
basic.Builder{Content: func(ctx core.BuildContext) core.Widget {
	return control.Button{Label: "Move to trash", OnPress: func() {
		overlay.ShowToast(ctx, overlay.Toast{Message: "Moved 3 notes to the trash", Action: "Undo", OnAction: func() {}})
	}}
}}

control.InfoBar

A notice that stays in the page: info, success, warning or error, with a close button and one action. The parent shows it with Open.

Package github.com/bankai-tensei/gowaku/widgets/control · Also control.InfoSeverity

control.InfoBarcontrol.InfoBar
control.InfoBar{
	Open: true, Severity: control.SeverityWarning,
	Title: "You are offline", Message: "Changes are saved on this device and sync when you reconnect.",
	OnClose: closed,
},
control.InfoBar{
	Open: true, Severity: control.SeverityError,
	Title: "Could not save", Message: "The disk is full.",
	Action: "Retry", OnAction: func() {}, OnClose: closed,
},

overlay.Dialog

A card that stops the work for an answer. Show it with ShowDialog; the focus stays inside. Glass blurs what is behind.

Package github.com/bankai-tensei/gowaku/widgets/overlay

overlay.Dialogoverlay.Dialog
basic.Builder{Content: func(ctx core.BuildContext) core.Widget {
	return control.Button{Label: "Delete", Style: control.ButtonDanger, OnPress: func() {
		overlay.ShowDialog(ctx, func(dismiss func()) core.Widget {
			return overlay.Dialog{
				Title:   "Delete this note?",
				Message: "It cannot be undone.",
				Actions: []core.Widget{
					control.Button{Label: "Cancel", OnPress: dismiss},
					control.Button{Label: "Delete", Style: control.ButtonDanger, OnPress: dismiss},
				},
			}
		})
	}}
}}

overlay.Sheet

A panel that slides in from the bottom or the side of the window. Show it with ShowSheet.

Package github.com/bankai-tensei/gowaku/widgets/overlay · Also overlay.SheetEdge

overlay.Sheetoverlay.Sheet
basic.Builder{Content: func(ctx core.BuildContext) core.Widget {
	return control.Button{Label: "Share", OnPress: func() {
		overlay.ShowSheet(ctx, overlay.Sheet{Label: "Share note"}, func(dismiss func()) core.Widget {
			return basic.Column{Size: layout.MainMin, Spacing: theme.Space8, Children: []core.Widget{
				basic.Text{Content: "Anyone with the link can read this note."},
				basic.Row{Main: layout.MainEnd, Spacing: theme.Space8, Children: []core.Widget{
					control.Button{Label: "Cancel", OnPress: dismiss},
					control.Button{Label: "Copy link", Style: control.ButtonPrimary, OnPress: dismiss},
				}},
			}}
		})
	}}
}}