Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import scala.scalajs.js
import scalacss.ScalaCssReact._
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.all._
import org.scalajs.dom.document
import org.scalajs.dom.raw.{ HTMLInputElement, HTMLElement }
import bootstrap.Icons
import scala.language.postfixOps
import scalacss.{ Color, ValueT }
import scalacss.Defaults._
object Styles extends StyleSheet.Inline {
import dsl._
// This is a style for a container
// with a <label> and an <input type=checkbox> in it
val example = styleC {
val top = styleS(display.block)
val lbl = styleS(fontWeight.bold)
val chk = styleS(backgroundColor.red, marginLeft(1 ex))
top.named('outer) :*: lbl.named('label) :*: chk.named('checkbox)
}
}
object Foo {
def featureActiveCheckbox(on: Boolean): ReactElement =
Styles.example('outer)(outerStyle =>
_('label)(labelStyle =>
_('checkbox)(inputStyle =>
<.div(outerStyle,
<.label(labelStyle, "Feature Active:"),
<.input(inputStyle, ^.typ := "checkbox", ^.value := on))
)))
}
/**
Fails with:
[error] found : Symbol
[error] required: Symbol with shapeless.tag.Tagged[String("outer")]
[error] Styles.example('outer)(outerStyle =>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.