Pages and layout
A page is a list of blocks: sections, grids, tabs, tables, forms, metrics. Each user gets only the blocks of resources they may view; a container left empty disappears.
go
func Overview() *panel.Page {
return &panel.Page{
Name: "overview",
Label: "Overview",
Layout: []*panel.Block{
panel.Section(panel.TableBlock("products").Filter("status", models.Draft).Actions("reprice")).
Label("Drafts").Description("Products waiting to be published."),
panel.Grid(
panel.Section(panel.TableBlock("categories")).Label("Categories"),
panel.Section(panel.TableBlock("suppliers")).Label("Suppliers"),
).Weights(1, 2),
panel.Tabs(
panel.Tab("Published", panel.TableBlock("products").Filter("status", models.Published)),
panel.Tab("Archived", panel.TableBlock("products").Filter("status", models.Archived)),
panel.Tab("Suppliers", panel.TableBlock("suppliers")),
),
},
}
}Grid columns
| Code | Result |
|---|---|
panel.Grid(children...) | one row, a column per child |
panel.Grid(children...).Columns(4) | 4 equal columns, children wrap |
panel.Grid(children...).Weights(2, 10) | one row, a weight per child: 2/12 and 10/12 |
When a user may not see a child, its weight goes with it and the row stays full. On narrow screens every block takes the whole row.