-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(ast/values) implement sizing properties
- Loading branch information
Showing
5 changed files
with
131 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,28 @@ | ||
pub(crate) use crate::traits::StyleValue; | ||
pub(crate) use hdx_proc_macro::*; | ||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::super::*; | ||
use crate::test_helpers::*; | ||
|
||
#[test] | ||
fn size_test() { | ||
assert_size!(Width, 12); | ||
assert_size!(Height, 12); | ||
assert_size!(MinWidth, 12); | ||
assert_size!(MinHeight, 12); | ||
assert_size!(MaxWidth, 12); | ||
assert_size!(MaxHeight, 12); | ||
} | ||
|
||
#[test] | ||
fn test_writes() { | ||
assert_parse!(Width, "0"); | ||
assert_parse!(Width, "1px"); | ||
assert_parse!(Width, "fit-content"); | ||
assert_parse!(Width, "fit-content(20rem)"); | ||
assert_parse!(Width, "fit-content(0)"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
use hdx_parser::{Parse, Parser, Peek, Result as ParserResult, Token}; | ||
use hdx_writer::{CssWriter, Result as WriterResult, WriteCss}; | ||
|
||
pub use crate::css::units::*; | ||
|
||
mod func { | ||
use hdx_parser::custom_function; | ||
custom_function!(CalcSize, atom!("calc-size")); | ||
custom_function!(FitContent, atom!("fit-content")); | ||
} | ||
|
||
#[derive(Debug, PartialEq, Hash, Clone, Copy)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize), serde())] | ||
pub struct CalcSize; | ||
|
||
impl<'a> Peek<'a> for CalcSize { | ||
fn peek(parser: &Parser<'a>) -> Option<hdx_lexer::Token> { | ||
parser.peek::<func::CalcSize>() | ||
} | ||
} | ||
|
||
impl<'a> Parse<'a> for CalcSize { | ||
fn parse(parser: &mut Parser<'a>) -> ParserResult<Self> { | ||
parser.parse::<func::CalcSize>()?; | ||
todo!(); | ||
} | ||
} | ||
|
||
impl<'a> WriteCss<'a> for CalcSize { | ||
fn write_css<W: CssWriter>(&self, _sink: &mut W) -> WriterResult { | ||
todo!(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters