scalatags icon indicating copy to clipboard operation
scalatags copied to clipboard

Are pseudo elements supported?

Open chipsenkbeil opened this issue 8 years ago • 3 comments

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 avatar Dec 22 '16 20:12 chipsenkbeil

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 avatar Dec 22 '16 21:12 chipsenkbeil

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

afterContent := "'\\f107'"

chipsenkbeil avatar Dec 23 '16 02:12 chipsenkbeil

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

lihaoyi avatar Feb 04 '17 16:02 lihaoyi