Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:55
    scala-steward opened #215
  • Sep 20 11:11
    scala-steward opened #214
  • Sep 18 00:38
    scala-steward opened #213
  • Sep 15 22:41
    scala-steward opened #212
  • Sep 11 13:07
    scala-steward opened #211
  • Sep 09 16:41
    Atry added as member
  • Sep 09 16:41
    Atry added as member
  • Sep 07 08:34
    scala-steward opened #210
  • Sep 06 16:11
    tw-data-china-go-cd removed as member
  • Sep 06 16:10
    kugua456 removed as member
  • Sep 06 16:08
    Atry removed as member
  • Sep 06 16:08
    Atry removed as member
  • Sep 04 09:16

    Atry on master

    Update sbt-sonatype to 2.6 Merge pull request #209 from sc… (compare)

  • Sep 04 09:16
    Atry closed #209
  • Sep 04 09:15

    Atry on master

    Update sbt to 1.3.0 Merge pull request #208 from sc… (compare)

  • Sep 04 09:15
    Atry closed #208
  • Sep 04 06:51
    scala-steward opened #209
  • Sep 04 06:50
    scala-steward opened #208
  • Sep 01 07:21

    Atry on master

    Support xmlns Merge pull request #207 from At… (compare)

  • Sep 01 07:21
    Atry closed #207
Justin Maat
@jxm262
   if (condition) 
       render dom element
   else 
        don’t render dom element
I’m coming from JavaScript/React world, so I may not be understanding something simple
杨博 (Yang Bo)
@Atry
<div>
  {
    if (a.each == “a”) {
      Constants(<div>someVal</div>)
    } else {
      Constants.empty
    }
  }
</div>
Justin Maat
@jxm262
ah ha!
Constants.empty
I overlooked this. Thanks so much!!
杨博 (Yang Bo)
@Atry
I think you can't do this in JavaScript/React world
Because if/else statement does not have a value in JavaScript
Justin Maat
@jxm262
well with react I do this quite often, but return null
render() {
    <div>
         { (condition) 
                 ? <div></div> 
                 : null
         }
    </div>
}
杨博 (Yang Bo)
@Atry
In Scala, the above code equals to
<div>
  {
    val v: Constants[Div] = if (a.each == “a”) {
      Constants(<div>someVal</div>)
    } else {
      Constants.empty
    }

    v
  }
</div>
Justin Maat
@jxm262
yup got it.
the Constants.empty is what I was missing
cool cool , thanks!
杨博 (Yang Bo)
@Atry
Another option:
<div>
  {
    if (a.each == “a”) {
      <div>someVal</div>
    } else {
      <!-- no someVal -->
    }
  }
</div>
Justin Maat
@jxm262
hmm.. you mean with code comment ?
i think i’d rather not include it in the markup at all though.
杨博 (Yang Bo)
@Atry
Not "code comment", it's HTML comment.
Justin Maat
@jxm262
yeah that’s what i mean, sorry
杨博 (Yang Bo)
@Atry
Note that you have to upgrade your Binding.scala to 5.4.0, because HTML comment is a newly added feature
Justin Maat
@jxm262
ok cool, yeah i’ll upgrade soon. I think there were a couple other things different in the new version I saw as well
Simon Hafner
@reactormonk
How would I attach the upgradeElement required by https://getmdl.io/started/index.html#dynamic ?
杨博 (Yang Bo)
@Atry
I don't know. I guess you can simply invoke the required function next to your HTML literal

Simon Hafner
@reactormonk
@Atry might be a timing issue - I'll have to be invoked after component has been written to the dom.
Simon Hafner
@reactormonk
@Atry how would that function look like on e.g. https://github.com/ThoughtWorksInc/Binding.scala#step-3-create-a-dom-method-that-contains-data-binding-expressions ? Alternatively, I could also add a changelistener that would simply call upgradeDom, but I'm not sure how good that is for performance.
杨博 (Yang Bo)
@Atry
@reactormonk I don't know your purpose. Do you want to invoke the method before or after the component added to DOM?
Simon Hafner
@reactormonk
@Atry after.
Simon Hafner
@reactormonk
Can I use binding.scala with scalatags syntax directly?
杨博 (Yang Bo)
@Atry
@reactormonk : Yes. You can add a -Xprint:all flag to Scala compiler and see what is generated by Binding.scala
Anthony Homan
@anthonyhoman
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
Binding.scala 5.4.0+ 's style attribute expects a String
杨博 (Yang Bo)
@Atry
Or you can use style attribute prefix: <div style:backgroundColor="red"></div>
Anthony Homan
@anthonyhoman
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
Anthony Homan
@anthonyhoman
I decided I want to dynamically update my <style> element in my document <head> element
Anthony Homan
@anthonyhoman
However, I can't find a clean way to set up the binding. My ScalaCSS code returns a <style> element filled in with all of my styles, but I can't call dom.render on the document.head as it will replace the other content in my <head> element (like <title> <link>, etc.)
So I tried coming up with some sort of BindingSeq[Node] that would contain the original static content of my <head> element plus the dynamically updating <style> element, but I can't find the right syntax
I can get a Binding[List[Node]], but I can't find a way to create my own BindingSeq[Node] from a list
杨博 (Yang Bo)
@Atry
val list = Seq(1, 2, 3)
val bs: BindingSeq[Int] = Constants(list: _*)
@anthonyhoman: Try Constants