Documentation ¶
Overview ¶
appbar implements a material appbar component.
See: https://material.io/components/web/catalog/appbar/
Example ¶
package main import ( "fmt" "log" "syscall/js" "github.com/vecty-components/material/components/appbar" "github.com/vecty-components/material/components/internal/mdctest" ) func main() { // Create a new instance of a material appbar component. c := appbar.New() printName(c) // Set up a DOM HTMLElement suitable for a appbar. js.Global().Get("document").Get("body").Set("innerHTML", mdctest.HTML(c.Component().Type.MDCClassName)) rootElem := js.Global().Get("document").Get("body").Get("firstElementChild") // Start the component, which associates it with an HTMLElement. err := c.Start(rootElem) if err != nil { log.Fatalf("Unable to start component %s: %v\n", c.Component().Type, err) } printName(c) err = c.Stop() if err != nil { log.Fatalf("Unable to stop component %s: %v\n", c.Component().Type, err) } printName(c) } func printName(c *appbar.A) { fmt.Printf("%s\n", c.Component().Type) } func init() { // We emulate a DOM here since tests run in NodeJS. // Not needed when running in a browser. err := mdctest.Init() if err != nil { log.Fatalf("Unable to setup test environment: %v", err) } }
Output: MDCToolbar MDCToolbar MDCToolbar
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A ¶
type A struct {
// contains filtered or unexported fields
}
A is a material appbar component.
func (*A) Start ¶
Start initializes the component with an existing HAMLElement, rootElem. Start should only be used on a newly created component, or after calling Stop.
Click to show internal directories.
Click to hide internal directories.