encre_css/plugins/border/outline_width/
mod.rs1#![doc = include_str!("README.md")]
2#![doc(alias = "border")]
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, .. } => value.parse::<usize>().is_ok(),
12 Modifier::Arbitrary {
13 hint,
14 value,
15 prefix,
16 } => {
17 prefix.is_empty()
18 && (*hint == "length"
19 || *hint == "line-width"
20 || (hint.is_empty()
21 && (is_matching_length(value) || is_matching_line_width(value))))
22 }
23 }
24 }
25
26 fn handle(&self, context: &mut ContextHandle) {
27 match context.modifier {
28 Modifier::Builtin { value, .. } => {
29 context
30 .buffer
31 .line(format_args!("outline-width: {value}px;"));
32 }
33 Modifier::Arbitrary { value, .. } => {
34 context.buffer.line(format_args!("outline-width: {value};"));
35 }
36 }
37 }
38}