encre_css/plugins/transform/transform_origin/
mod.rs1#![doc = include_str!("README.md")]
2#![doc(alias = "transform")]
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 match context.modifier {
11 Modifier::Builtin { value, .. } => [
12 "center",
13 "top",
14 "top-right",
15 "right",
16 "bottom-right",
17 "bottom",
18 "bottom-left",
19 "left",
20 "top-left",
21 ]
22 .contains(value),
23 Modifier::Arbitrary { value, .. } => is_matching_position(value),
24 }
25 }
26
27 fn handle(&self, context: &mut ContextHandle) {
28 match context.modifier {
29 Modifier::Builtin { value, .. } => {
30 context
31 .buffer
32 .line(format_args!("transform-origin: {};", value.replace('-', " ")));
33 }
34 Modifier::Arbitrary { value, .. } => {
35 context
36 .buffer
37 .line(format_args!("transform-origin: {value};"));
38 }
39 }
40 }
41}