Giter Club home page Giter Club logo

Comments (6)

mihajm avatar mihajm commented on May 28, 2024 1

Looks great! Would the new-ish css aspect ratio property work, since it seems to have pretty wide support.
https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio

Another option here is using a directive on the container, as it again alows the user to use any semantic html element they want

<div brnAspectRatio="3/4">
   <img ... />
</div>

from spartan.

goetzrobin avatar goetzrobin commented on May 28, 2024 1

Since tailwind also supports aspect-ratio out of the box I say we stick with the positioning implementation. https://tailwindcss.com/docs/aspect-ratio

I do think the docs should state that there's a CSS property for that and it should be considered first.

from spartan.

mihajm avatar mihajm commented on May 28, 2024 1

Great! Then numbers work and we just check if its 0 or less

from spartan.

goetzrobin avatar goetzrobin commented on May 28, 2024

That's a good point! I'd almost say that would be something to mention in future docs. Prefer CSS and fallback to this component.

While I like the directive approach but we'd have to figure out how to wrap the children in the components we need. Content projection seems easier here. Since there will always be DOM nodes to needed to make it work I'd actually say component.

Would be cool to support a ratio in text form instead of a number. Maybe we can support the most common ones as text?

from spartan.

mihajm avatar mihajm commented on May 28, 2024

Probably easier if its all text tbh as otherwise we need to parse out 16/9 out of 5.3333 since ng will just divide the numbers. We could use template literals to restrict it tho what we want. Otherwise were sort of forced into the position relative + absolute way of solving it.

type Ratio = `${number}/${number}`

Tho I also am up for aliasing a few common ones with declarative strings such as widescreen/phone etc.

I see what you mean with components, it sort of depends on impl here id say since all we need to do is add a single css property to the parent here. If we however wanted to do the relative/absolute approach a component would be easier.

from spartan.

goetzrobin avatar goetzrobin commented on May 28, 2024

It actually does not need to be the two values but can use the number directly.

Writing height / width is just how we naturally think about it.

But with the type you suggested parsing probably wouldn't be too bad either.

I guess we just have to make sure we're not dividing by 0 or the aspect ratio is 0 and we should be good.

Now I am leaning to supporting both 😂

from spartan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.