2026-04-11 14:11:11 +02:00
|
|
|
import gleam/option.{type Option, None, Some}
|
|
|
|
|
import lustre/attribute.{class}
|
|
|
|
|
import lustre/element.{type Element}
|
|
|
|
|
import lustre/element/html
|
|
|
|
|
import lustre/event
|
|
|
|
|
|
|
|
|
|
pub fn click_cell(
|
|
|
|
|
tag: Option(String),
|
2026-04-12 21:19:28 +02:00
|
|
|
id: Option(String),
|
|
|
|
|
value: String,
|
|
|
|
|
on_click: fn(Option(String)) -> msg,
|
2026-04-11 14:11:11 +02:00
|
|
|
) -> Element(msg) {
|
|
|
|
|
html.div([class("participant-login"), event.on_click(on_click(id))], [
|
|
|
|
|
html.div([class("participant-name")], [
|
|
|
|
|
html.text(
|
|
|
|
|
"► "
|
|
|
|
|
<> case tag {
|
|
|
|
|
Some(text) -> "[#" <> text <> "] "
|
|
|
|
|
None -> ""
|
|
|
|
|
}
|
|
|
|
|
<> value,
|
|
|
|
|
),
|
|
|
|
|
]),
|
|
|
|
|
])
|
|
|
|
|
}
|
2026-04-12 21:19:28 +02:00
|
|
|
|
|
|
|
|
pub fn click_cell_pair(
|
|
|
|
|
tag: Option(String),
|
|
|
|
|
pair: Option(#(String, String)),
|
2026-04-13 12:17:50 +02:00
|
|
|
display_value: Bool,
|
2026-04-12 21:19:28 +02:00
|
|
|
on_click: fn(Option(#(String, String))) -> msg,
|
|
|
|
|
) -> Element(msg) {
|
|
|
|
|
let value = case pair {
|
|
|
|
|
Some(pair) -> {
|
|
|
|
|
let #(_, value) = pair
|
|
|
|
|
value
|
|
|
|
|
}
|
|
|
|
|
None -> ""
|
|
|
|
|
}
|
|
|
|
|
html.div([class("participant-login"), event.on_click(on_click(pair))], [
|
|
|
|
|
html.div([class("participant-name")], [
|
|
|
|
|
html.div([], [
|
|
|
|
|
html.text(
|
|
|
|
|
"► "
|
|
|
|
|
<> case tag {
|
|
|
|
|
Some(text) -> "[#" <> text <> "] "
|
|
|
|
|
None -> ""
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
]),
|
2026-04-13 12:17:50 +02:00
|
|
|
case display_value {
|
|
|
|
|
True -> html.text(value)
|
|
|
|
|
False -> element.none()
|
|
|
|
|
},
|
2026-04-12 21:19:28 +02:00
|
|
|
]),
|
|
|
|
|
])
|
|
|
|
|
}
|