use super::COMPONENT_NAME;
use sauron::{html::*, *};
pub(super) enum SelectionSplits {
SelectAll(String),
SelectRight(String, String),
SelectMiddle(String, String, String),
SelectLeft(String, String),
NotSelected(String),
}
impl SelectionSplits {
pub(super) fn view<MSG>(&self) -> Node<MSG> {
let class_ns = |class_names| attributes::class_namespaced(COMPONENT_NAME, class_names);
match self {
Self::SelectAll(line) => span([class_ns("selected")], [text(line)]),
Self::SelectRight(first, second) => span(
[],
[
span([], [text(first)]),
span([class_ns("selected")], [text(second)]),
],
),
Self::SelectMiddle(first, second, third) => span(
[],
[
span([], [text(first)]),
span([class_ns("selected")], [text(second)]),
span([], [text(third)]),
],
),
Self::SelectLeft(first, second) => span(
[],
[
span([class_ns("selected")], [text(first)]),
span([], [text(second)]),
],
),
Self::NotSelected(line) => span([], [text(line)]),
}
}
pub(super) fn view_with_style<MSG>(&self, node_style: Attribute<MSG>) -> Node<MSG> {
let class_ns = |class_names| attributes::class_namespaced(COMPONENT_NAME, class_names);
match self {
Self::SelectAll(line) => span([class_ns("selected"), node_style], [text(line)]),
Self::SelectRight(first, second) => span(
[node_style],
[
span([], [text(first)]),
span([class_ns("selected")], [text(second)]),
],
),
Self::SelectMiddle(first, second, third) => span(
[node_style],
[
span([], [text(first)]),
span([class_ns("selected")], [text(second)]),
span([], [text(third)]),
],
),
Self::SelectLeft(first, second) => span(
[node_style],
[
span([class_ns("selected")], [text(first)]),
span([], [text(second)]),
],
),
Self::NotSelected(line) => span([node_style], [text(line)]),
}
}
}