Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 09 04:00
    notyy commented #222
  • Oct 09 03:59
    notyy closed #222
  • Oct 09 03:59
    notyy commented #222
  • Oct 08 20:28
    Atry commented #223
  • Oct 08 20:28

    Atry on master

    docs: fix typo Merge pull request #223 from Ja… (compare)

  • Oct 08 20:28
    Atry closed #223
  • Oct 08 20:20
    Jason-Cooke opened #223
  • Oct 07 03:30
    glmars commented #222
  • Oct 06 04:05
    notyy opened #222
  • Oct 04 11:29
    datalchemist commented #217
  • Oct 04 11:02
    datalchemist commented #217
  • Oct 04 06:58

    Atry on scalafmt

    (compare)

  • Oct 04 06:46

    Atry on master

    Run scalafmt Merge branch 'master' into scal… Merge pull request #221 from Th… (compare)

  • Oct 04 06:46
    Atry closed #221
  • Oct 04 06:46
    Atry synchronize #221
  • Oct 04 06:46

    Atry on scalafmt

    Update scalafmt to 2.0.1 Update sbt to 1.3.2 Merge pull request #215 from sc… and 2 more (compare)

  • Oct 04 06:06
    Atry commented #217
  • Oct 04 05:30
    glmars commented #217
  • Oct 04 05:09
    Atry closed #191
  • Oct 04 05:09

    Atry on master

    Update scalafmt to 2.0.1 Merge pull request #203 from sc… (compare)

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
Anthony Homan
@anthonyhoman
Hmm, still can't get it...my problem seems to be something to do with this:
If I create a BindingSeq[Node] as follows, and render it into document.head, it works as expected:
@dom def head = {
      <title>My Title</title>
      <link>Some Link</link>
    }
    dom.render(document.head, head)