Skip to main content

peacock_crest/style/prop_validation/
overflow.rs

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