-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayout.go
More file actions
51 lines (41 loc) · 1.5 KB
/
layout.go
File metadata and controls
51 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Package layout implements the markup defined in
https://github.com/material-components/material-components-web/tree/master/packages/mdc-layout-grid
See ExampleGrid for usage.
*/
package layout
import (
"fmt"
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
// Grid is the mandatory layout grid element with class mdc-layout-grid.
func Grid() app.HTMLDiv {
return app.Div().Class("mdc-layout-grid")
}
// Inner is the mandatory wrapping grid cell with class mdc-layout-grid__inner.
func Inner() app.HTMLDiv {
return app.Div().Class("mdc-layout-grid__inner")
}
// Cell is the mandatory layout grid cell with class mdc-layout-grid__cell.
// Use CellModified to specify alignment and span width.
func Cell() app.HTMLDiv {
return app.Div().Class("mdc-layout-grid__cell")
}
// CellModified is the mandatory innermost layout div with class mdc-layout-grid__cell.
// It allows optional classes for alignment ( top, middle, bottom ) and span width ( 1-12 ).
// If align and span values are out of range, no additional classes are added.
func CellModified(align string, span int) app.HTMLDiv {
classes := []string{"mdc-layout-grid__cell"}
switch align {
case "top", "middle", "bottom":
classes = append(classes, "mdc-layout-grid__cell--align-"+align)
}
if span > 0 && span < 13 {
classes = append(classes, fmt.Sprintf("mdc-layout-grid__cell--span-%d", span))
}
return app.Div().Class(classes...)
}
// CellWide is equivalent to CellModified("middle", 12)
func CellWide() app.HTMLDiv {
return CellModified("middle", 12)
}