scala-dom-types
scala-dom-types copied to clipboard
[WIP] Add grid styles
I started adding grid styles but according to MDN they are still a candidate or a working-draft. So I am not sure whether they belong into sdt. Or can we maybe add something like an experimental
package to mark unstable APIs? This is what scalajs does too for some experimental APIs in the browser (for example serviceworker).
based on #37
Thanks! I merged #37 btw, you can rebase on master.
Regarding W3C spec status, I don't think that alone is enough to justify putting this under "experimental" in this particular case. The new CSS Grid spec has been implemented by browsers pretty uniformly for quite some time now (disregarding the earlier Microsoft spec, which I don't think we should cover), and realistically I don't think it will change in backwards-incompatible ways by the time it is eventually formally accepted.
In this regard, scala-js-dom is subject to stricter self-imposed standards than I personally care to make SDT subject to at this point.
My bigger concern with CSS Grid is that our bindings would be perhaps not typed very strictly – mostly just string codecs for all the composite values – but I think it is more or less inevitable given the complexity of native CSS grid syntax and our limited tolerance to introducing an opinionated way to encode such complexity in SDT bindings.
So, similarly to how we handled SVG, I don't think we need experimental
for this, and I definitely welcome this eventual addition to SDT.
We should definitely put everything in a separate GridStyles
trait though. That way it's easy for the consuming library to opt out if they want to provide an alternative (perhaps more opinionated) grid interface.
Also, please don't forget to add any new traits to CompileTest
.
Agreed that we should put them in a separate trait. We can make this trait generic on the different value-types we have in the grid directives. Then consuming libraries and applications can implement them in a more type-safe way. We can just default to String for now and improve if we have time and need for it :)
Will update the PR soonish!
Stumbled across this PR when I was trying to find out how to apply grid styles :-)
Should I try to move those changes in a separate trait and make the CI run?
Hey @jberggg, I've recently made pretty significant changes to how CSS properties are encoded in Scala DOM Types. You can see that in version 0.16.0-RC2 in master
, but as RC2
suggests, this version is not a regular release, it's not used by Laminar, Outwatch or any other library yet.
So what I'm saying is, for CSS grid to land in SDT, someone would need to translate the changes in this PR to the new encoding seen in master
. It shouldn't be hard though.
However, if you are interested in using CSS grid in Laminar, note that you'll need to wait until after the summer for me to release the next Laminar version.
In the meantime you might want to copy over the CSS properties from this PR into your project using like this.
So uh sorry I didn't actually explicitly answer your question (in case it was directed at me): you're welcome to adapt this PR (yes, a separate trait for grid-specific props would be best), but you should be aware that it will take a long time for the changes to actually be released / become usable from Laminar.
Hey @raquo
Ah good to know. Thank you for the update. I'm playing around with Outwatch for a personal project. So this addition is not urgent at all and I'm aware that you can "manually" set CSS properties. When I find free time I will have a look at the new encoding style and might give it a try. It's not top priority so please do not expect too much 😃
Scala DOM Types has been refactored and its structure is now completely different, so I'm closing this old PR. If anyone wants to take another shot at this in the future, please open a new issue or PR.