These are chat archives for japgolly/scalacss

18th
Mar 2015
SRGOM
@SRGOM
Mar 18 2015 04:44
lol- I do compulsive coding myself haha
but not as well as you do!
David Barri
@japgolly
Mar 18 2015 05:24
hihi thanks :D
Per Wiklander
@PerWiklander
Mar 18 2015 06:14
@japgolly what would be the best way of making addClassNames safer? Having a bunch of val btn = “btn” definitions in a bootstrap facade?
David Barri
@japgolly
Mar 18 2015 07:46
Yes either that or using ScalaCSS itself to create those definitions and then composing them.
I mean like this

object BootstrapFacade {
  sealed abstract class ButtonType(cls: String)
  object Default extends ButtonType("btn-default")
  object Warning extends ButtonType("btn-warning")
  // ...

  val button = styleF[ButtonType](bt => addClassNames("btn", bt.cls))
}

// Somewhere else....

object MyStyles extends StyleSheet {
  val myButton = style(
    margin(12 px, auto),
    BootstrapFacade.button(Warning)
  )
}
(styleF means style Function)
You could also do like this:
val defaultButton = style(addClassNames("btn", "btn-default"))
val warningButton = style(addClassNames("btn", "btn-warning"))
David Barri
@japgolly
Mar 18 2015 07:51
Then of course you'd start using standard Scala stuff to simply the boilerplate.
Otto Chrons
@ochrons
Mar 18 2015 07:52
I believe this facade business is very important for the success of Scala.js
the more ready-made plug'n'play facades there are, the easier the uptake
David Barri
@japgolly
Mar 18 2015 07:52
Ah that's true.
Well all of this lib's style stuff is reusable and composable so it will be possible.
I think it will just need a bit of time to work out the nicest ways of doing so.
Otto Chrons
@ochrons
Mar 18 2015 07:54
ideally we would have a "Bootstrap.jar" for Scala.js which would include everything you need
David Barri
@japgolly
Mar 18 2015 07:54
(Like above example, there are plenty of working ways it could be done)
Otto Chrons
@ochrons
Mar 18 2015 07:54
right now the actual JS/CSS is still external
David Barri
@japgolly
Mar 18 2015 07:54
Hmm, that would be quite cool
Hey on a side note,
Otto Chrons
@ochrons
Mar 18 2015 07:55
so having something like the npm module system but what would actually be simple to use :)
David Barri
@japgolly
Mar 18 2015 07:55
actually ignore my side note :)
Otto Chrons
@ochrons
Mar 18 2015 07:55
webjars are close, but not good enough
David Barri
@japgolly
Mar 18 2015 07:56
yeah webjars are super trivial
They're fine for now but eventually we'll need something better as Scala.js gets used and explored more
Otto Chrons
@ochrons
Mar 18 2015 07:57
getting the JS out of webjar is simple enough, but often you need other resources and that's where it gets complicated
just yesterday there were requests on this kind of functionality in the scala-js issues and also in gitter
David Barri
@japgolly
Mar 18 2015 07:59
Yeah I saw the jspm.io issue - i'd never heard of it before
Otto Chrons
@ochrons
Mar 18 2015 08:00
the whole JS module thing is going to get more complicated with the advent of ES6 modules
there are now too many module systems for JS :)
so this would be something to think about regarding scalacss too
if I want to publish a component with some CSS, how does that integrate
David Barri
@japgolly
Mar 18 2015 08:05
Well the library itself has an easy time of it as it's just a normal library dependency - JS/CSS files required.
I even embedded some handy CSS.
CssReset.scala is what would normally be a CSS module/dependency normalize.css.
It will be very different for libraries like Bootstrap etc
Otto Chrons
@ochrons
Mar 18 2015 08:06
yea I'm more concerned about the resource file
David Barri
@japgolly
Mar 18 2015 08:07
yeah i'm staying out of that one
That stuff is significant work
Otto Chrons
@ochrons
Mar 18 2015 08:08
agreed, but it needs to be done at some point
JS devs are accustomed to module management systems already, even on the frontend
David Barri
@japgolly
Mar 18 2015 08:09
For my work project (which I haven't touched for 2 weeks :'( ) I use grunt & bower despite it being a Scala.js project
Asset bundling is a one-time thing. It's static until you change or upgrade dependencies.
Asset pipelines that run constantly aren't really necessary.
Alberto Paro
@aparo
Mar 18 2015 08:10
@japgolly also my project uses bower + gruntjs
Otto Chrons
@ochrons
Mar 18 2015 08:10
and there are the various sbt-web plugins that manage assets, but it's very Play centric
David Barri
@japgolly
Mar 18 2015 08:11
hehe @aparo I'm glad I'm not the only oddball :P
Mmmm, I don't use Play.
I think whatever solution for ScalaJS module management should
  1. Work in SBT.
  2. Have no assumptions or dependencies on Play.
And 3. Should probably replace jsDependencies and provide full support.
Alberto Paro
@aparo
Mar 18 2015 08:13
using or integrating bower could be very useful, but I don't know how it will play with the other components
David Barri
@japgolly
Mar 18 2015 08:13
Bower's actually pretty good hey
Well maybe a Scala/SBT wrapper would be an idea?
Alberto Paro
@aparo
Mar 18 2015 08:14
I think that the bower logic, it's now so complex
Otto Chrons
@ochrons
Mar 18 2015 08:14
bower is good for plain JS/CSS deps, but what about when you have a nice facade for an existing JS lib
say, somebody does a sjs facade for three.js and wants to bundle everything together
David Barri
@japgolly
Mar 18 2015 08:15
Ideally that facade should report its requirements for something that a Scala-Bower (for eg) plugin can understand and work with
Otto Chrons
@ochrons
Mar 18 2015 08:15
it's not going to be a bower package, since it is needed by ScalaJS build
David Barri
@japgolly
Mar 18 2015 08:16
Then it would need to pull out what it needs from bower to bundle up with everything else and you've spent a year writing this plugin :D
Otto Chrons
@ochrons
Mar 18 2015 08:16
something like that :D
Alberto Paro
@aparo
Mar 18 2015 08:16
object MyPrettyPackageSystem extends ScalaJSFunctionaties with bower
you can package the facades linked with bower component
David Barri
@japgolly
Mar 18 2015 08:19
Well because this stuff is hard and complex, it would probably and I don't think there is any resource available to work on this full time for a long time, I think a solution will have to be either minimal, or something that uses the existing JS ecosystem tools under-the-cover.
Otto Chrons
@ochrons
Mar 18 2015 08:20
like the sbt-web plugins mostly do
David Barri
@japgolly
Mar 18 2015 08:20
What does sbt-web do and how?
I use xsbt-web but that's verrry different
Otto Chrons
@ochrons
Mar 18 2015 08:21
sbt-web is a basis for all kinds of plugins that basically run JS stuff in SBT
it was taken out of Play originally, so that's why it's still very Play specific
in essence it's a web asset pipeline
David Barri
@japgolly
Mar 18 2015 08:22
Does it do any dependency fetching?
Otto Chrons
@ochrons
Mar 18 2015 08:23
dunno, it has support for webjars
David Barri
@japgolly
Mar 18 2015 08:23
Might be an interesting starting point
Hey @ochrons that prototype scala.js site you made
How did you do it? Just hand editing files or was there any useful github online editor?
Otto Chrons
@ochrons
Mar 18 2015 08:25
pure manual HTML/CSS editing :)
David Barri
@japgolly
Mar 18 2015 08:25
Ohhhhhh
I need to write doc for this project now, features are mostly all done
I just want to edit markdown online or something
Otto Chrons
@ochrons
Mar 18 2015 08:25
using the materialize-css framework and then looking at various website implementations for ideas
try gitbook, planning to transform SPA tutorial into that
although that's not so much online editing
github wiki is ok, too, for simple stuff
but it's difficult to make sequential stuff with it as you need to manually add next/prev links
David Barri
@japgolly
Mar 18 2015 08:28
For some reason I hate github wikis. They piss me off.
gitbook looks interesting, thanks
actually gitbook looks pretty cool, thanks man!
I think i'll give it a try
Otto Chrons
@ochrons
Mar 18 2015 08:30
nice, let me know how it works out :)
then I can avoid all the pitfalls you stumble into :)
David Barri
@japgolly
Mar 18 2015 08:32
Will do :+1:
Justin du Coeur, AKA Mark Waks
@jducoeur
Mar 18 2015 12:02
@japgolly Okay, the class-name-adding thing is really sweet, and addresses my single biggest pain point with Bootstrap. I think you've just convinced me to adopt this. (When I've got a spare day to do so: this calls for a real rethink of how I do styles.)
David Barri
@japgolly
Mar 18 2015 21:33
@jducoeur Awesome! This project is about making lives easier so hopefully I'm succeeding. :)
Elegantly dealing with shit like bootstrap is a big motivator for me too
I want to use it for now but I want to jump ship easily and quickly later.
This should facilitate that.
Otto Chrons
@ochrons
Mar 18 2015 21:34
hearhear!