Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

yisibl
Copy link
Contributor

@yisibl yisibl commented Sep 23, 2022

  columns = <'column-width'> || <'column-count'>

@yisibl
Copy link
Contributor Author

yisibl commented Oct 17, 2022

@devongovett PTAL


/// A [`<length>`](https://www.w3.org/TR/css-values-4/#lengths) value
/// without a unit specified.
Unitless(CSSNumber),
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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.

@devongovett devongovett force-pushed the master branch 3 times, most recently from 68a1bff to 3930139 Compare August 20, 2023 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants