encre_css/plugins/background/background_repeat/
mod.rs

1#![doc = include_str!("README.md")]
2#![doc(alias("background", "bg"))]
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: "repeat"
14                    | "no-repeat"
15                    | "repeat-x"
16                    | "repeat-y"
17                    | "repeat-round"
18                    | "repeat-space",
19                ..
20            }
21        )
22    }
23
24    fn handle(&self, context: &mut ContextHandle) {
25        match context.modifier {
26            Modifier::Builtin { value, .. } => context.buffer.line(format_args!(
27                "background-repeat: {};",
28                match *value {
29                    "repeat-round" => "round",
30                    "repeat-space" => "space",
31                    _ => value,
32                }
33            )),
34            Modifier::Arbitrary { .. } => unreachable!(),
35        }
36    }
37}