-
Notifications
You must be signed in to change notification settings - Fork 2
/
grid.go
114 lines (86 loc) · 2.01 KB
/
grid.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Code generated by go generate; DO NOT EDIT.
package uikit
import (
"github.com/maxence-charriere/go-app/v7/pkg/app"
)
// UIGrid is a component that creates a fully responsive, fluid and nestable grid layout
type UIGrid interface {
app.UI
// Class adds a CSS class to the grid.
Class(v string) UIGrid
// Content sets the main content.
Content(elems ...app.UI) UIGrid
// Option sets a component option.
Option(k string, v interface{}) UIGrid
// Collapse to remove the grid gap entirely.
Collapse() UIGrid
// Divider to separate grid cells with lines.
Divider() UIGrid
// Large to apply a large gap with breakpoints.
Large() UIGrid
// MatchHeight to match the height of the direct child of each cell.
MatchHeight() UIGrid
// Medium to apply a medium gap like the default one, but without a breakpoint.
Medium() UIGrid
// Small to apply a small gap.
Small() UIGrid
}
type grid struct {
app.Compo
Iclass string
Icontent []app.UI
Ioptions map[string]interface{}
}
// Grid returns a grid component.
func Grid() UIGrid {
return &grid{}
}
func (g *grid) Class(v string) UIGrid {
if g.Iclass != "" {
g.Iclass += " "
}
g.Iclass += v
return g
}
func (g *grid) Content(elems ...app.UI) UIGrid {
g.Icontent = app.FilterUIElems(elems...)
return g
}
func (g *grid) Option(k string, v interface{}) UIGrid {
if g.Ioptions == nil {
g.Ioptions = make(map[string]interface{}, 0)
}
g.Ioptions[k] = v
return g
}
func (g *grid) Collapse() UIGrid {
g.Class("uk-grid-collapse")
return g
}
func (g *grid) Divider() UIGrid {
g.Class("uk-grid-divider")
return g
}
func (g *grid) Large() UIGrid {
g.Class("uk-grid-large")
return g
}
func (g *grid) MatchHeight() UIGrid {
g.Class("uk-grid-match")
return g
}
func (g *grid) Medium() UIGrid {
g.Class("uk-grid-medium")
return g
}
func (g *grid) Small() UIGrid {
g.Class("uk-grid-small")
return g
}
func (g *grid) Render() app.UI {
opts, _ := JSONString(g.Ioptions)
return app.Div().
DataSet("uk-grid", opts).
Class(g.Iclass).
Body(g.Icontent...)
}