Skip to main content

encre_css/plugins/
css_property.rs

1//! Define a plugin used to generate CSS properties quickly.
2//!
3//! Used for arbitrary CSS properties like `[mask-type:luminance]`.
4use crate::prelude::build_plugin::*;
5
6pub(crate) const PLUGIN: StaticPlugin = Plugin::Functional(Functional {
7    namespace: "",        // field not used for css-property
8    can_handle: |_| true, // field not used for css-property
9    handle: |context| match context.modifier {
10        Modifier::Builtin { .. } => unreachable!(),
11        Modifier::Arbitrary { value, .. } => {
12            generate_wrapper(context, |context| {
13                for line in value.lines() {
14                    if let Some((prop, value)) = line.split_once(':') {
15                        context.buffer.line(format_args!("{prop}: {value};"));
16                    }
17                }
18            });
19        }
20    },
21    ..Functional::default()
22});