Current section
Files
Jump to
Current section
Files
src/m3e/bottom_sheet_trigger.gleam
//// BottomSheetTrigger is an element, nested within a clickable element, used to trigger a bottom sheet.
////
//// This file was generated by m3e/generator
////
//// DO NOT EDIT
////
import gleam/float
import gleam/function
import gleam/list
import gleam/option.{type Option, None}
import lustre/attribute.{type Attribute}
import lustre/element.{type Element}
import m3e/attr
// --- Types ---
/// BottomSheetTrigger is a View Model for this component
///
/// ## Fields:
///
/// - detent: The zero‑based index of the detent the sheet should open to.
/// - secondary: Marks this trigger as a secondary trigger for accessibility. Secondary triggers do not receive ARIA ownership.
/// - for: The identifier of the interactive control to which this element is attached.
///
pub opaque type BottomSheetTrigger {
BottomSheetTrigger(
detent: Option(Float),
secondary: Secondary,
for: Option(String),
)
}
/// Secondary is marks this trigger as a secondary trigger for accessibility. Secondary triggers do not receive ARIA ownership.
///
pub type Secondary {
IsSecondary
IsNotSecondary
}
// --- Defaults ---
pub const default_detent: Option(Float) = None
pub const default_secondary: Secondary = IsNotSecondary
pub const default_for: Option(String) = None
// --- Configuration ---
/// Config is a public record for configuring this component.
///
pub type Config {
Config(detent: Option(Float), secondary: Secondary, for: Option(String))
}
/// default_config is the default configuration for this component.
///
pub fn default_config() -> Config {
Config(detent: None, secondary: IsNotSecondary, for: None)
}
// --- Constructors ---
/// from_config creates a new BottomSheetTrigger from the given configuration.
///
pub fn from_config(config: Config) -> BottomSheetTrigger {
BottomSheetTrigger(
detent: config.detent,
secondary: config.secondary,
for: config.for,
)
}
/// new creates a new BottomSheetTrigger with the default configuration.
///
pub fn new() -> BottomSheetTrigger {
from_config(default_config())
}
// --- Setters ---
/// detent sets the value of detent for this BottomSheetTrigger.
///
pub fn detent(
record: BottomSheetTrigger,
detent: Option(Float),
) -> BottomSheetTrigger {
BottomSheetTrigger(..record, detent: detent)
}
/// secondary sets the value of secondary for this BottomSheetTrigger.
///
pub fn secondary(
record: BottomSheetTrigger,
secondary: Secondary,
) -> BottomSheetTrigger {
BottomSheetTrigger(..record, secondary: secondary)
}
/// for sets the value of for for this BottomSheetTrigger.
///
pub fn for(
record: BottomSheetTrigger,
for: Option(String),
) -> BottomSheetTrigger {
BottomSheetTrigger(..record, for: for)
}
// --- Renderers ---
/// render creates a Lustre Element for a BottomSheetTrigger
///
pub fn render(
model: BottomSheetTrigger,
attributes: List(Attribute(msg)),
children: List(Element(msg)),
) -> Element(msg) {
element.element(
"m3e-bottom-sheet-trigger",
list.flatten([
[
attr.option(
model.detent,
fn(_) { "detent" },
float.to_string,
default_detent,
),
attr.boolean("secondary", model.secondary == IsSecondary),
attr.option(model.for, fn(_) { "for" }, function.identity, default_for),
],
attributes,
])
|> list.filter(fn(a) { a != attribute.none() }),
children,
)
}
/// render_config creates a Lustre Element from a BottomSheetTrigger Config
///
pub fn render_config(
c: Config,
attributes: List(Attribute(msg)),
children: List(Element(msg)),
) -> Element(msg) {
render(from_config(c), attributes, children)
}