-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add support for aspect-ratio
CSS property.
#266
Open
chungyc
wants to merge
8
commits into
sebastiaanvisser:master
Choose a base branch
from
chungyc:aspect-ratio
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
turion
requested changes
Oct 21, 2024
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.
Thank you, your PR is a maintainer's dream :) just a few comments.
chungyc
force-pushed
the
aspect-ratio
branch
4 times, most recently
from
October 21, 2024 23:24
7e49e15
to
f0a3e6e
Compare
Co-authored-by: Manuel Bärenz <[email protected]>
There may come a day when `withFallback` should be used with another type of value in the `Clay.Geometry` module, but until then, it is overkill to use a type class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an
aspectRatio
function for generating theaspect-ratio
CSS property and anAspectRatio
type to represent aspect ratios. To make the ratios feel more likeData.Ratio
ratios, this defines a%
operator on twoInteger
s generating anAspectRatio
. So we could do things like this:To allow for properties such as
aspect-ratio: auto 4/3
, we use awithFallback
function to generate anAspectRatio
:It is not legal to do something like
aspect-ratio: auto auto
. While it would have been nice if we could have enforced this with types, this is hard, so it is enforced as a runtime error instead.The original plan in #259 was based on a type class. This worked correctly, but not nicely, because types could not be inferred completely. For example, if we did
the compiler would not know what type
aspectRatio
should accept yet. And it can't infer that16%9
should beRational
orRatio Int
because it doesn't know whether 16 or 9 areInteger
s orInt
s. We could resolve the deadlock by enabling type defaulting, but lots of code disable it (e.g., when turning on-Wall -Werror
). So we would often have to do something likewhich seemed cumbersome, so I gave up on the approach based on a type class.
Generated Haddock documentation can be seen in clay-haddock.tar.gz. The examples in the documentation may seem odd, but they're written this way so that they can correctly be evaluated in case
doctest
is used one day to test the examples.Resolves #259.