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

Are pseudo elements supported? #149

Open chipsenkbeil opened 7 years ago

chipsenkbeil commented 7 years ago

You've got pseudo-selectors. Are psuedo-elements (https://developer.mozilla.org/en-US/docs/Web/CSS/pseudo-elements) supported in any form? Wanted to add ::after to an element.

I see mention of ::after here: https://github.com/lihaoyi/scalatags/blob/master/scalatags/shared/src/main/scala/scalatags/generic/Styles.scala#L575

chipsenkbeil commented 7 years ago

I was trying to do the following, which almost works:

object MyStylesheet extends CascadingStyleSheet {
  import scalatags.Text.styles2.{content => afterContent}

  val someClass = cls(
    &.pseudoExtend(":after")(
      display := "inline-block",
      afterContent := "\\f107",
      opacity := 0.5,
      color := "#102429",
      fontSize := "inherit"
    )
  )
}

However, the content block gets converted into content: \f107; when I invoke styleSheetText. Without the quotes, it ends up breaking in the browser. If I try to insert quotes into the string, they get escaped into &quote;.

chipsenkbeil commented 7 years ago

Looks like I can get around the problem by embedding single quotes.

afterContent := "'\\f107'"
lihaoyi commented 7 years ago

They're not really supported right now, but I'd love a patch to make them work