sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
357 stars 72 forks source link

Support `aspect-ratio` CSS property #259

Open chungyc opened 7 months ago

chungyc commented 7 months ago

Add support for the aspect-ratio CSS property. It specifies a desired aspect ratio for a display element.

I think we can support this by adding an aspectRatio function to Clay.Geometry. Its argument could be a Rational for ratios, a tuple of (auto, ratio) or (ratio, auto), or the usual set of auto, inherit, ... values. Its argument type could be a type class like AspectRatioValue, of which Rational and Value could be made instances. E.g.,

aspectRatio auto
aspectRatio initial
aspectRatio (16%9)
aspectRatio (16%9, auto)

This issue is mainly stating my intention to implement support for aspect-ratio and to track any work related to it, rather than a feature request for someone else to implement.

Note that this is distinct from the aspect-ratio media feature, which is already supported with Clay.Media.aspectRatio.

turion commented 7 months ago

That sounds like a great addition! Note that aspect-ratio: auto 3/4; is also valid CSS. Do you want to submit a PR?

chungyc commented 7 months ago

Do you want to submit a PR?

That's my plan ... eventually.