-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement CSS columns #304
base: master
Are you sure you want to change the base?
Conversation
yisibl
commented
Sep 23, 2022
- Spec: https://www.w3.org/TR/css-multicol-1/#columns
Co-authored-by: Jason <[email protected]>
Co-authored-by: Jason <[email protected]>
Co-authored-by: Jason <[email protected]>
@devongovett PTAL |
|
||
/// A [`<length>`](https://www.w3.org/TR/css-values-4/#lengths) value | ||
/// without a unit specified. | ||
Unitless(CSSNumber), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this needed for? Aren't unitless lengths only allowed for zero, and compute to pixels? So why not just store as pixels?
derive(serde::Serialize, serde::Deserialize), | ||
serde(tag = "type", content = "value", rename_all = "kebab-case") | ||
)] | ||
pub enum LengthOrAuto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably make a generic type that allows "auto" or a type parameter. Happy to implement that separately.
let state = input.state(); | ||
let with_or_count = LengthOrAuto::parse(input)?; | ||
|
||
if let LengthOrAuto::Length(Length::Value(LengthValue::Unitless(..))) = with_or_count { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than parsing as a unitless length, you could instead first try parsing the column count, and if that fails, try parsing the length. When parsing shorthands where order doesn't matter, it can be useful to structure the code using a loop
, trying to parse each property until values are found. There are many examples, here's one.
68a1bff
to
3930139
Compare