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 ¶
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.
Items []Item
}
Group is one group of items with a heading.
type InputClasses ¶
InputClasses are the classes of the parts that the island draws.
type Item ¶
type Item struct {
// Label is the text of the item.
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.