Skip to main content

peacock_crest/style/prop_validation/
position_horizontal.rs

1use super::{CssValue, TokenExpected};
2use crate::Unit;
3
4#[derive(Debug, Clone)]
5pub struct CssLeft(Unit);
6
7#[derive(Debug, Clone)]
8pub struct CssRight(Unit);
9
10#[derive(Debug, Clone, strum_macros::EnumString, strum_macros::Display)]
11pub enum KeywordPositionHorizontal {
12    #[strum(to_string = "auto", serialize = "auto")]
13    Auto,
14}
15
16impl From<Unit> for CssLeft {
17    fn from(value: Unit) -> Self {
18        Self(value)
19    }
20}
21
22impl Into<Unit> for CssLeft {
23    fn into(self) -> Unit {
24        self.0
25    }
26}
27
28impl From<Unit> for CssRight {
29    fn from(value: Unit) -> Self {
30        Self(value)
31    }
32}
33
34impl Into<Unit> for CssRight {
35    fn into(self) -> Unit {
36        self.0
37    }
38}
39
40impl CssValue for CssLeft {
41    type Keyword = KeywordPositionHorizontal;
42
43    fn type_name() -> &'static str {
44        "CssLeft"
45    }
46
47    fn type_token() -> TokenExpected {
48        TokenExpected::Dimension | TokenExpected::Percentage | TokenExpected::Ident
49    }
50}
51
52impl CssValue for CssRight {
53    type Keyword = KeywordPositionHorizontal;
54
55    fn type_name() -> &'static str {
56        "CssRight"
57    }
58
59    fn type_token() -> TokenExpected {
60        TokenExpected::Dimension | TokenExpected::Percentage | TokenExpected::Ident
61    }
62}