Documentation ¶
Overview ¶
temporarydrawer implements a material temporarydrawer component.
See: https://material.io/components/web/catalog/drawers/
Example ¶
package main import ( "fmt" "log" "agamigo.io/material/internal/mdctest" "agamigo.io/material/temporarydrawer" "github.com/gopherjs/gopherjs/js" ) func main() { // Create a new instance of a material temporarydrawer component. c := temporarydrawer.New() printName(c) printState(c) c.Open = true printState(c) // Set up a DOM HTMLElement suitable for a temporarydrawer. 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) } printState(c) c.Open = false printState(c) err = c.Stop() if err != nil { log.Fatalf("Unable to stop component %s: %v\n", c.Component().Type, err) } printState(c) } func printName(c *temporarydrawer.TD) { fmt.Printf("%s\n", c.Component().Type) } func printState(c *temporarydrawer.TD) { fmt.Println() fmt.Printf("MDC Open: %v\n", c.Component().Get("open")) } 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: MDCTemporaryDrawer MDC Open: false MDC Open: true MDC Open: true MDC Open: false MDC Open: false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TD ¶
type TD struct { Open bool `js:"open"` // contains filtered or unexported fields }
TD is a material temporarydrawer component.
func (*TD) Start ¶
Start initializes the component with an existing HTMLElement, 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.