encre_css/plugins/flexbox/flex_direction/
mod.rs

1#![doc = include_str!("README.md")]
2#![doc(alias = "flexbox")]
3use crate::prelude::build_plugin::*;
4
5#[derive(Debug)]
6pub(crate) struct PluginDefinition;
7
8impl Plugin for PluginDefinition {
9    fn can_handle(&self, context: ContextCanHandle) -> bool {
10        matches!(
11            context.modifier,
12            Modifier::Builtin {
13                value: "row" | "row-reverse" | "col" | "col-reverse",
14                ..
15            }
16        )
17    }
18
19    fn handle(&self, context: &mut ContextHandle) {
20        match context.modifier {
21            Modifier::Builtin { value, .. } => match *value {
22                "row" => context.buffer.line("flex-direction: row;"),
23                "row-reverse" => context.buffer.line("flex-direction: row-reverse;"),
24                "col" => context.buffer.line("flex-direction: column;"),
25                "col-reverse" => context.buffer.line("flex-direction: column-reverse;"),
26                _ => unreachable!(),
27            },
28            Modifier::Arbitrary { .. } => unreachable!(),
29        }
30    }
31}