encre_css/plugins/accessibility/screen_reader/
mod.rs1#![doc = include_str!("README.md")]
2#![doc(alias = "accessibility")]
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: "sr-only" | "not-sr-only",
14 ..
15 }
16 )
17 }
18
19 fn handle(&self, context: &mut ContextHandle) {
20 match context.modifier {
21 Modifier::Builtin { value, .. } => match *value {
22 "sr-only" => context.buffer.lines([
23 "position: absolute;",
24 "width: 1px;",
25 "height: 1px;",
26 "padding: 0;",
27 "margin: -1px;",
28 "overflow: hidden;",
29 "clip: rect(0, 0, 0, 0);",
30 "white-space: nowrap;",
31 "border-width: 0;",
32 ]),
33 "not-sr-only" => context.buffer.lines([
34 "position: static;",
35 "width: auto;",
36 "height: auto;",
37 "padding: 0;",
38 "margin: 0;",
39 "overflow: visible;",
40 "clip: auto;",
41 "white-space: normal;",
42 ]),
43 _ => unreachable!(),
44 },
45 Modifier::Arbitrary { .. } => unreachable!(),
46 }
47 }
48}