use elvis_core::{derive::Setter, style::FlexStyle, value::layouts::Alignment, Class, Node};
use elvis_derive::IntoNode;
#[derive(Default, Setter)]
pub struct Align {
pub child: Node,
pub align: Alignment,
}
impl Into<Node> for Align {
fn into(self) -> Node {
Node::default().children(vec![self.child]).style(self.align)
}
}
#[derive(Default, Setter)]
pub struct Center {
#[skip]
pub child: Node,
}
impl Center {
pub fn child(mut self, n: impl Into<Node>) -> Self {
self.child = n.into();
self
}
}
impl Into<Node> for Center {
fn into(self) -> Node {
Node::default()
.children(vec![self.child])
.class(vec![Class::Flex, Class::Center])
}
}
#[derive(Default, Setter)]
pub struct Col {
pub children: Vec<Node>,
}
impl Into<Node> for Col {
fn into(self) -> Node {
Node::default()
.children(self.children)
.class(vec![Class::Flex, Class::Col])
}
}
#[derive(Default, IntoNode, Setter)]
pub struct Flex {
pub child: Node,
pub style: FlexStyle,
}
#[derive(Default, Setter)]
pub struct Row {
pub children: Vec<Node>,
}
impl Into<Node> for Row {
fn into(self) -> Node {
Node::default()
.children(self.children)
.class(vec![Class::Flex, Class::Row])
}
}