These are chat archives for ThoughtWorksInc/Binding.scala

24th
May 2016
Anthony Homan
@anthonyhoman
May 24 2016 01:31
is anyone using ScalaCSS with Binding.scala?
Since Binding.scala is using Scalatags under the hood, I thought it would be a pretty common pairing, but I'm struggling with the integration of the two
If I have an ScalaCSS inline stylesheet something like this:
  object ExampleStyles extends StyleSheet.Inline {
    import dsl._
    val bg = style(
      backgroundColor.blue
    )
  }
Then how do I use the "bg" style in Binding.scala?
The following attempt shows that I need to convert from scalacss.StyleA to org.scalajs.dom.raw.CSSStyleDeclaration:
<div style={ ExampleStyles.bg }>
Getting lost in the abstraction layers and can't quite figure out what is expected here
杨博 (Yang Bo)
@Atry
May 24 2016 01:39
Binding.scala 5.4.0+ 's style attribute expects a String
杨博 (Yang Bo)
@Atry
May 24 2016 01:46
Or you can use style attribute prefix: <div style:backgroundColor="red"></div>
Anthony Homan
@anthonyhoman
May 24 2016 04:17
Nevermind...I see I had a fundamental misreading of what ScalaCSS means by "inline styles". I think of setting styles directly on elements. ScalaCSS seems to mean setting the generated class name on an element and then including the .css content separately
In my example above it should be something like this:
<div class={ ExampleStyles.bg.htmlClass }>
And then somewhere you need to populate a css file using the output from ExampleStyles.render[String]
As far as I can tell, my best bet would be to use an sbt code generator to fill in my .css files in my Play Assets folder with the output of my ScalaCSS stylesheets