com-lihaoyi / scalatags

ScalaTags is a small XML/HTML construction library for Scala.
https://com-lihaoyi.github.io/scalatags/
MIT License
758 stars 117 forks source link

Attribute selectors supported? #151

Open chipsenkbeil opened 7 years ago

chipsenkbeil commented 7 years ago

I want to be able to write something like

.myClass input[type="radio"] {
  /* ... */
}

There doesn't appear to be any documentation for attribute selectors nor do I see anything for them in the source code.

chipsenkbeil commented 7 years ago

Looks like I can do the following for now:

object MyStyle extends CascadingStyleSheet {
  lazy val myClass: Cls = cls(
    Selector("input[type='radio']")(
      // My specific CSS content
    )
  )
}
lihaoyi commented 7 years ago

lol I didn't even realize you could do that.

I guess we could document it, or maybe even include it as part of the base-syntax if we could find a nice way of representing. Maybe input(type:= "radio") or something. This might clash with the existing use of input.apply to mean building up a frag, so it might take some refactoring to separate the inputs we see in CascadingStyleSheet from the inputs we see in scalatags.Text.all._ so we can make that syntax work