legos/ui
Types
pub type Decoration(a, b) =
@internal Attribute(a, b)
pub type Device {
Device(class: DeviceClass, orientation: Orientation)
}
Constructors
-
Device(class: DeviceClass, orientation: Orientation)
pub type DeviceClass {
Phone
Tablet
Desktop
BigDesktop
}
Constructors
-
Phone
-
Tablet
-
Desktop
-
BigDesktop
pub type FocusStyle =
@internal FocusStyle
pub type HtmlAttribute(msg)
pub type IndexedColumn(data, msg) {
IndexedColumn(
header: @internal Element(msg),
width: @internal Length,
view: fn(Int, data) -> @internal Element(msg),
)
}
Constructors
-
IndexedColumn( header: @internal Element(msg), width: @internal Length, view: fn(Int, data) -> @internal Element(msg), )
pub type Orientation {
Portrait
Landscape
}
Constructors
-
Portrait
-
Landscape
pub type TableColumn(data, msg) {
TableColumn(
header: @internal Element(msg),
width: @internal Length,
view: fn(data) -> @internal Element(msg),
)
}
Constructors
-
TableColumn( header: @internal Element(msg), width: @internal Length, view: fn(data) -> @internal Element(msg), )
pub type WindowSize {
WindowSize(width: Int, height: Int)
}
Constructors
-
WindowSize(width: Int, height: Int)
Values
pub fn above(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn align_bottom() -> @internal Attribute(
@internal Aligned,
msg,
)
pub fn align_left() -> @internal Attribute(@internal Aligned, msg)
pub fn align_right() -> @internal Attribute(
@internal Aligned,
msg,
)
pub fn behind_content(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn below(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn classify_device(window: WindowSize) -> Device
pub fn column(
attributes: List(@internal Attribute(@internal Aligned, msg)),
children: List(@internal Element(msg)),
) -> @internal Element(msg)
pub fn default_focus() -> @internal FocusStyle
pub fn el(
attributes: List(@internal Attribute(@internal Aligned, msg)),
child: @internal Element(msg),
) -> @internal Element(msg)
pub fn fill_portion(portion: Int) -> @internal Length
pub fn focus_style(style: @internal FocusStyle) -> @internal Opt
pub fn focused(
decs: List(@internal Attribute(a, b)),
) -> @internal Attribute(@internal Aligned, msg)
pub fn force_hover() -> @internal Opt
pub fn height(
length: @internal Length,
) -> @internal Attribute(@internal Aligned, msg)
pub fn hovered(
decs: List(@internal Attribute(a, b)),
) -> @internal Attribute(@internal Aligned, msg)
pub fn html(node: @internal Element(e)) -> @internal Element(e)
Render a Lustre element with legos
pub fn html_attribute(
a: @internal Attribute(c),
) -> @internal Attribute(d, c)
Render a Lustre attribute with legos
pub fn image(
attributes: List(@internal Attribute(@internal Aligned, msg)),
src src: String,
description description: String,
) -> @internal Element(msg)
Both a source and a description are required for images.
The description is used for people using screen readers.
Leaving the description blank will cause the image to be ignored by assistive technology. This can make sense for images that are purely decorative and add no additional information.
So, take a moment to describe your image as you would to someone who has a harder time seeing.
pub fn in_front(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn indexed_table(
attributes: List(@internal Attribute(@internal Aligned, msg)),
data data: List(data),
columns columns: List(IndexedColumn(data, msg)),
) -> @internal Element(msg)
pub fn layout(
attributes: List(@internal Attribute(@internal Aligned, msg)),
child: @internal Element(msg),
) -> @internal Element(msg)
pub fn layout_with(
options: List(@internal Opt),
attributes: List(@internal Attribute(@internal Aligned, msg)),
child: @internal Element(msg),
) -> @internal Element(msg)
pub fn link(
attributes: List(@internal Attribute(@internal Aligned, msg)),
url url: String,
label label: @internal Element(msg),
) -> @internal Element(msg)
pub fn map_attribute(
attribute: @internal Attribute(@internal Aligned, a),
transform: fn(a) -> b,
) -> @internal Attribute(@internal Aligned, b)
pub fn mouse_down(
decs: List(@internal Attribute(a, b)),
) -> @internal Attribute(@internal Aligned, msg)
pub fn mouse_over(
decs: List(@internal Attribute(a, b)),
) -> @internal Attribute(@internal Aligned, msg)
pub fn move_right(
distance: Float,
) -> @internal Attribute(@internal Aligned, msg)
pub fn new_tab_link(
attributes: List(@internal Attribute(@internal Aligned, msg)),
url url: String,
label label: @internal Element(msg),
) -> @internal Element(msg)
pub fn no_static_style_sheet() -> @internal Opt
pub fn on_left(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn on_right(
element: @internal Element(msg),
) -> @internal Attribute(@internal Aligned, msg)
pub fn padding_each(
top top: Int,
right right: Int,
bottom bottom: Int,
left left: Int,
) -> @internal Attribute(@internal Aligned, msg)
If you find yourself defining unique paddings all the time, you might consider defining
edges =
(
top: 0,
right: 0,
bottom: 0,
left: 0,
)
And then just do
paddingEach(edges |> { .._, right: 5 })
pub fn padding_xy(
x: Int,
y: Int,
) -> @internal Attribute(@internal Aligned, msg)
pub fn paragraph(
attributes: List(@internal Attribute(@internal Aligned, msg)),
children: List(@internal Element(msg)),
) -> @internal Element(msg)
pub fn pct_screen(pct: Int) -> @internal Length
Fill a percent of the safe-viewport size
pub fn prose(
attributes: List(@internal Attribute(@internal Aligned, msg)),
children: List(@internal Element(msg)),
) -> @internal Element(msg)
pub fn row(
attributes: List(@internal Attribute(@internal Aligned, msg)),
children: List(@internal Element(msg)),
) -> @internal Element(msg)
pub fn scrollbar_x() -> @internal Attribute(
@internal Aligned,
msg,
)
pub fn scrollbar_y() -> @internal Attribute(
@internal Aligned,
msg,
)
pub fn scrollbars() -> @internal Attribute(@internal Aligned, msg)
pub fn space_evenly() -> @internal Attribute(
@internal Aligned,
msg,
)
pub fn spacing_xy(
x: Int,
y: Int,
) -> @internal Attribute(@internal Aligned, msg)
pub fn table(
attrs: List(@internal Attribute(@internal Aligned, msg)),
data data: List(data),
columns columns: List(TableColumn(data, msg)),
) -> @internal Element(msg)
Show some tabular data.
Start with a list of records and specify how each column should be rendered.
So, if we have a list of persons
:
type Person {
Person(first_name: String, last_name: String)
}
let persons = [
Person("David", "Bowie"),
Person("Florence", "Welch"),
]
We could render it using
table([],
data: persons,
columns: [
Column(
header: Element.text("First Name"),
width: fill(),
view: fn(person) { Element.text(person.first_name) },
),
Column(
header: Element.text("Last Name"),
width: fill(),
view: fn(person) { Element.text(person.last_name) },
),
]),
Note: Sometimes you might not have a list of records directly in your model. In this case it can be really nice to write a function that transforms some part of your model into a list of records before feeding it into Element.table
.
pub fn transition(
properties: List(String),
duration_ms: Int,
) -> @internal Attribute(@internal Aligned, msg)
pub fn transparent(
is_transparent: Bool,
) -> @internal Attribute(@internal Aligned, msg)
pub fn wrapped_row(
attrs: List(@internal Attribute(@internal Aligned, msg)),
children: List(@internal Element(msg)),
) -> @internal Element(msg)