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 Orientation {
Portrait
Landscape
}
Constructors
-
Portrait -
Landscape
pub type WindowSize {
WindowSize(width: Int, height: Int)
}
Constructors
-
WindowSize(width: Int, height: Int)
Values
pub fn above(
element: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn align_bottom() -> Decoration(@internal Aligned, msg)
pub fn align_left() -> Decoration(@internal Aligned, msg)
pub fn align_right() -> Decoration(@internal Aligned, msg)
pub fn align_top() -> Decoration(@internal Aligned, msg)
pub fn alpha(o: Float) -> Decoration(@internal Aligned, msg)
pub fn attr_none() -> Decoration(@internal Aligned, msg)
pub fn behind_content(
element: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn below(
element: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn center_x() -> Decoration(@internal Aligned, msg)
pub fn center_y() -> Decoration(@internal Aligned, msg)
pub fn classify_device(window: WindowSize) -> Device
pub fn clip() -> Decoration(@internal Aligned, msg)
pub fn clip_x() -> Decoration(@internal Aligned, msg)
pub fn clip_y() -> Decoration(@internal Aligned, msg)
pub fn column(
attributes: List(Decoration(@internal Aligned, msg)),
children: List(Element(msg)),
) -> Element(msg)
pub fn cursor() -> Decoration(@internal Aligned, msg)
pub fn default_focus() -> FocusStyle
pub fn el(
attributes: List(Decoration(@internal Aligned, msg)),
child: Element(msg),
) -> Element(msg)
pub fn fill_portion(portion: Int) -> Length
pub fn focus_style(style: FocusStyle) -> Opt
pub fn focused(
decs: List(Decoration(a, b)),
) -> Decoration(@internal Aligned, msg)
pub fn force_hover() -> Opt
pub fn height(
length: Length,
) -> Decoration(@internal Aligned, msg)
pub fn hovered(
decs: List(Decoration(a, b)),
) -> Decoration(@internal Aligned, msg)
pub fn html_attribute(
a: attribute.Attribute(c),
) -> Decoration(d, c)
Render a Lustre attribute with legos
pub fn image(
attributes: List(Decoration(@internal Aligned, msg)),
src src: String,
description description: String,
) -> 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: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn indexed_table(
attributes: List(Decoration(@internal Aligned, msg)),
data data: List(data),
columns columns: List(IndexedColumn(data, msg)),
) -> Element(msg)
pub fn layout(
attributes: List(Decoration(@internal Aligned, msg)),
child: Element(msg),
) -> element.Element(msg)
pub fn layout_with(
options: List(Opt),
attributes: List(Decoration(@internal Aligned, msg)),
child: Element(msg),
) -> element.Element(msg)
pub fn link(
attributes: List(Decoration(@internal Aligned, msg)),
url url: String,
label label: Element(msg),
) -> Element(msg)
pub fn map_attribute(
attribute: Decoration(@internal Aligned, a),
transform: fn(a) -> b,
) -> Decoration(@internal Aligned, b)
pub fn mouse_down(
decs: List(Decoration(a, b)),
) -> Decoration(@internal Aligned, msg)
pub fn mouse_over(
decs: List(Decoration(a, b)),
) -> Decoration(@internal Aligned, msg)
pub fn move_down(
distance: Float,
) -> Decoration(@internal Aligned, msg)
pub fn move_left(
distance: Float,
) -> Decoration(@internal Aligned, msg)
pub fn move_right(
distance: Float,
) -> Decoration(@internal Aligned, msg)
pub fn move_up(
distance: Float,
) -> Decoration(@internal Aligned, msg)
pub fn new_tab_link(
attributes: List(Decoration(@internal Aligned, msg)),
url url: String,
label label: Element(msg),
) -> Element(msg)
pub fn no_static_style_sheet() -> Opt
pub fn on_left(
element: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn on_right(
element: Element(msg),
) -> Decoration(@internal Aligned, msg)
pub fn padding(pixels: Int) -> Decoration(@internal Aligned, msg)
pub fn padding_each(
top top: Int,
right right: Int,
bottom bottom: Int,
left left: Int,
) -> Decoration(@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,
) -> Decoration(@internal Aligned, msg)
pub fn paragraph(
attributes: List(Decoration(@internal Aligned, msg)),
children: List(Element(msg)),
) -> Element(msg)
pub fn pointer() -> Decoration(@internal Aligned, msg)
pub fn prose(
attributes: List(Decoration(@internal Aligned, msg)),
children: List(Element(msg)),
) -> Element(msg)
pub fn rotate(angle: Float) -> Decoration(@internal Aligned, msg)
pub fn row(
attributes: List(Decoration(@internal Aligned, msg)),
children: List(Element(msg)),
) -> Element(msg)
pub fn scale(factor: Float) -> Decoration(@internal Aligned, msg)
pub fn scrollbar_x() -> Decoration(@internal Aligned, msg)
pub fn scrollbar_y() -> Decoration(@internal Aligned, msg)
pub fn scrollbars() -> Decoration(@internal Aligned, msg)
pub fn space_evenly() -> Decoration(@internal Aligned, msg)
pub fn spacing(pixels: Int) -> Decoration(@internal Aligned, msg)
pub fn spacing_xy(
x: Int,
y: Int,
) -> Decoration(@internal Aligned, msg)
pub fn table(
attrs: List(Decoration(@internal Aligned, msg)),
data data: List(data),
columns columns: List(TableColumn(data, msg)),
) -> 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,
) -> Decoration(@internal Aligned, msg)
pub fn transparent(
is_transparent: Bool,
) -> Decoration(@internal Aligned, msg)
pub fn width(length: Length) -> Decoration(@internal Aligned, msg)
pub fn wrapped_row(
attrs: List(Decoration(@internal Aligned, msg)),
children: List(Element(msg)),
) -> Element(msg)