twig/layout
Types
Phantom type for grid cell attributes.
pub type GridCellAttr
Phantom type for horizontal alignment attributes.
pub type HAlign {
Start
End
Left
Center
Right
}
Constructors
-
Start -
End -
Left -
Center -
Right
Represents a length value in various units.
Pt— points, e.g.Pt(12.0)→12.0ptMm— millimeters, e.g.Mm(10.0)→10.0mmCm— centimeters, e.g.Cm(2.5)→2.5cmIn— inches, e.g.In(1.0)→1.0inEm— relative to font size, e.g.Em(2.0)→2.0em
pub type Length {
Pt(Float)
Mm(Float)
Cm(Float)
In(Float)
Em(Float)
}
Constructors
-
Pt(Float) -
Mm(Float) -
Cm(Float) -
In(Float) -
Em(Float)
Values
pub fn align(
alignment: Alignment,
children: List(twig.Content),
) -> twig.Content
Align content horizontally and vertically.
Example
align(Both(Center, Horizon), [text("Hello"), text("World")])
// -> "#align(center + horizon)[Hello\nWorld]"
pub fn cell_align(a: Alignment) -> twig.Attr(GridCellAttr)
Sets the alignment of a grid cell.
Example
grid_cell([cell_align(Both(Center, Horizon))], [text("Hello")])
// -> "#grid.cell(align: center + horizon)[Hello]"
pub fn colspan(n: Int) -> twig.Attr(GridCellAttr)
Sets the number of columns a grid cell spans.
Example
grid_cell([colspan(2)], [text("Hello")])
// -> "#grid.cell(colspan: 2)[Hello]"
pub fn columns(cs: List(TrackSize)) -> twig.Attr(GridAttr)
Sets the column widths of a grid.
Example
columns([Fr(1.0), Fr(2.0)])
// -> "columns: (1.0fr, 2.0fr)"
pub fn grid(
attrs: List(twig.Attr(GridAttr)),
children: List(twig.Content),
) -> twig.Content
Creates a grid element.
grid([columns([Fr(1.0), Fr(2.0)])], [text.text("Hello"), text.text("World")])
// -> "#grid(columns: (1.0fr, 2.0fr), \"Hello\", \"World\")"
pub fn grid_cell(
attrs: List(twig.Attr(GridCellAttr)),
children: List(twig.Content),
) -> twig.Content
Creates a grid cell element.
Example
grid_cell([colspan(2), rowspan(2)], [text("Hello")])
// -> "#grid.cell(colspan: 2, rowspan: 2)[Hello]"
pub fn gutter(g: List(TrackSize)) -> twig.Attr(GridAttr)
Sets the gutter size of a grid.
Example
gutter([Fr(1.0), Fr(2.0)])
// -> "gutter: (1.0fr, 2.0fr)"
pub fn h(amount: Length) -> twig.Content
Inserts horizontal spacing into the document.
Example
h(Em(5.0))
// -> "#h(5.0em)"
h(Pt(12.0))
// -> "#h(12.0pt)"
pub fn rows(rs: List(TrackSize)) -> twig.Attr(GridAttr)
Sets the row heights of a grid.
Example
rows([Fr(1.0), Fr(2.0)])
// -> "rows: (1.0fr, 2.0fr)"
pub fn rowspan(n: Int) -> twig.Attr(GridCellAttr)
Sets the number of rows a grid cell spans.
Example
grid_cell([rowspan(2)], [text("Hello")])
// -> "#grid.cell(rowspan: 2)[Hello]"
pub fn v(amount: Length) -> twig.Content
Inserts vertical spacing into the document.
Example
v(Em(5.0))
// -> "#v(5.0em)"
v(Pt(12.0))
// -> "#v(12.0pt)"
pub fn x(n: Int) -> twig.Attr(GridCellAttr)
Sets the x position of a grid cell.
Example
grid_cell([x(1)], [text("Hello")])
// -> "#grid.cell(x: 1)[Hello]"
pub fn y(n: Int) -> twig.Attr(GridCellAttr)
Sets the y position of a grid cell.
Example
grid_cell([y(2)], [text("Hello")])
// -> "#grid.cell(y: 2)[Hello]"