Documentation
¶
Overview ¶
persistentdrawer implements a material persistentdrawer component.
See: https://material.io/components/web/catalog/drawers/
Example ¶
package main import ( "fmt" "log" "agamigo.io/material/internal/mdctest" "agamigo.io/material/persistentdrawer" "github.com/gopherjs/gopherjs/js" ) func main() { // Create a new instance of a material persistentdrawer component. c := persistentdrawer.New() printName(c) printState(c) c.Open = true printState(c) // Set up a DOM HTMLElement suitable for a persistentdrawer. 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) } } func printName(c *persistentdrawer.PD) { fmt.Printf("%s\n", c.Component().Type) } func printState(c *persistentdrawer.PD) { 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: MDCPersistentDrawer MDC Open: false MDC Open: true MDC Open: true MDC Open: false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PD ¶
type PD struct { Open bool `js:"open"` // contains filtered or unexported fields }
PD is a material persistentdrawer component.
func (*PD) 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.