command

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 2 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 command is a list of commands with a search input: the server renders the list, and the CommandInput island filters it and runs an item from the keyboard.

Index

Constants

This section is empty.

Variables

View Source
var CommandFixtures = gx.Fixtures[CommandProps]{
	"Default": {Id: "command-default", Groups: []Group{
		{Heading: "Suggestions", Items: []Item{
			{Label: "Calendar", Keywords: "date day"},
			{Label: "Search emoji", Keywords: "smile"},
			{Label: "Calculator", Disabled: true},
		}},
		{Heading: "Settings", Items: []Item{
			{Label: "Profile", Shortcut: "⌘P", Href: "#profile"},
			{Label: "Billing", Shortcut: "⌘B", Href: "#billing"},
			{Label: "Settings", Shortcut: "⌘S", Value: "settings"},
		}},
	}},
	"OneGroup": {Id: "command-one", Label: "Go to", Placeholder: "Search pages...", Groups: []Group{
		{Heading: "Pages", Items: []Item{
			{Label: "Home", Href: "#home"},
			{Label: "About", Href: "#about"},
		}},
	}},
}

Functions

func Command

func Command(p CommandProps) gx.Node

func CommandInput

func CommandInput(p CommandInputProps, opts ...gx.IslandOption) gx.Node

CommandInput renders the island of CommandInput.ts (REQ-ISL-01). The browser mounts it with the props as JSON. An option sets the time of the load.

Types

type CommandInputProps

type CommandInputProps struct {
	// List is the id of the list of items.
	List string `json:"list"`
	// Empty is the id of the element that shows when no item matches.
	Empty string `json:"empty"`
	// Label is the accessible name of the input.
	Label string `json:"label"`
	// Placeholder is the text of the empty input.
	Placeholder string `json:"placeholder"`
	// Classes holds the classes of the parts. They are Go constants, so
	// the stylesheet build sees them.
	Classes InputClasses `json:"classes"`
}

CommandInputProps are the props of the island that draws the search input. The island filters the items of the list with the id List.

type CommandProps

type CommandProps struct {
	// Id is the id of the root element.
	Id string
	// Label is the accessible name of the search input and of the list.
	Label string
	// Placeholder is the text of the empty search input.
	Placeholder string
	// EmptyText is the text that shows when no item matches.
	EmptyText string
	// Groups are the groups of items, in order.
	Groups []Group
	// Class adds classes to the root element.
	Class string
	// Attrs adds HTML attributes to the root element.
	Attrs gx.Attrs
}

type Group

type Group struct {
	// Heading is the text above the items.
	Heading string
	// Items are the items of the group, in order. A group with no item
	// that renders does not render.
	Items []Item
}

Group is one group of items with a heading.

type InputClasses

type InputClasses struct {
	Root  string `json:"root"`
	Input string `json:"input"`
}

InputClasses are the classes of the parts that the island draws.

type Item

type Item struct {
	// Label is the text of the item. An item with an empty Label does not
	// render.
	Label string
	// Value is the value of the command-select event. Empty means Label.
	Value string
	// Href makes the item a link to a page. Empty makes it a button.
	Href gx.URL
	// Keywords are more words that the search finds.
	Keywords string
	// Shortcut is the key hint at the end of the item.
	Shortcut string
	// Disabled takes the item out of the list of choices.
	Disabled bool
}

Item is one command.

Jump to

Keyboard shortcuts

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