layoutcss_parser/utilities/
p_recursive.rs

1use indoc::formatdoc;
2use crate::harmonic::get_harmonic;
3
4use std::collections::HashSet;
5pub fn p_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
6    let harmonic_value = get_harmonic(&value, harmonic_ratio);
7    set.insert(formatdoc!(
8        r#"
9        [layout~="p-recursive:{value}"] *{{
10            padding: {harmonic_value};
11            --pl: padding: {harmonic_value};
12            --pr: padding: {harmonic_value};
13        }}
14        "#
15    ));
16}
17
18pub fn pt_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
19    let harmonic_value = get_harmonic(&value, harmonic_ratio);
20    set.insert(formatdoc!(
21        r#"
22        [layout~="pt-recursive:{value}"] *{{
23            padding-top: {harmonic_value};
24        }}
25        "#
26    ));
27}
28
29pub fn pb_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
30    let harmonic_value = get_harmonic(&value, harmonic_ratio);
31    set.insert(formatdoc!(
32        r#"
33        [layout~="pb-recursive:{value}"] *{{
34            padding-bottom: {harmonic_value};
35        }}
36        "#
37    ));
38}
39
40pub fn pl_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
41    let harmonic_value = get_harmonic(&value, harmonic_ratio);
42    set.insert(formatdoc!(
43        r#"
44        [layout~="pl-recursive:{value}"] *{{
45            padding-left: {harmonic_value};
46            --pl: {harmonic_value};
47        }}
48        "#
49    ));
50}
51
52pub fn pr_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
53    let harmonic_value = get_harmonic(&value, harmonic_ratio);
54    set.insert(formatdoc!(
55        r#"
56        [layout~="pr-recursive:{value}"] *{{
57            padding-right: {harmonic_value};
58            --pr: {harmonic_value};
59        }}
60        "#
61    ));
62}
63
64pub fn px_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
65    let harmonic_value = get_harmonic(&value, harmonic_ratio);
66    set.insert(formatdoc!(
67        r#"
68        [layout~="px-recursive:{value}"] *{{
69            padding-left: {harmonic_value};
70            padding-right: {harmonic_value};
71            --pl: {harmonic_value};
72            --pr: {harmonic_value};
73        }}
74        "#
75    ));
76}
77
78pub fn py_recursive_css(value: &str, harmonic_ratio: f64, set: &mut HashSet<String>) {
79    let harmonic_value = get_harmonic(&value, harmonic_ratio);
80    set.insert(formatdoc!(
81        r#"
82        [layout~="py-recursive:{value}"] *{{
83            padding-top: {harmonic_value};
84            padding-bottom: {harmonic_value};
85        }}
86        "#
87    ));
88}