encre_css/plugins/layout/display/
mod.rs

1#![doc = include_str!("README.md")]
2#![doc(alias = "layout")]
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: "hidden"
14                    | "contents"
15                    | "list-item"
16                    | "block"
17                    | "inline-block"
18                    | "flex"
19                    | "inline-flex"
20                    | "inline"
21                    | "table"
22                    | "inline-table"
23                    | "table-cell"
24                    | "table-caption"
25                    | "table-column"
26                    | "table-column-group"
27                    | "table-footer-group"
28                    | "table-header-group"
29                    | "table-row-group"
30                    | "table-row"
31                    | "flow-root"
32                    | "grid"
33                    | "inline-grid",
34                ..
35            }
36        )
37    }
38
39    fn handle(&self, context: &mut ContextHandle) {
40        if let Modifier::Builtin {
41            value: "hidden", ..
42        } = context.modifier
43        {
44            context.buffer.line("display: none;");
45        } else if let Modifier::Builtin { value, .. } = context.modifier {
46            context.buffer.line(format_args!("display: {value};"));
47        }
48    }
49}