Skip to content

Instantly share code, notes, and snippets.

@fomkin
Created May 9, 2020 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fomkin/0acbaf2e00a12a1fde15218499d031b8 to your computer and use it in GitHub Desktop.
Save fomkin/0acbaf2e00a12a1fde15218499d031b8 to your computer and use it in GitHub Desktop.

CSS in Korolev

val myClass = CssClassDecl("myClass")

val myCss1: CssDecl = css"""
  /* Any valid CSS */
  .$myClass {
    ...
  }
  """

val myCss2 = CssDecl("css-file-from-resources.css", myClass)

...

body(
  myCss1, myCss2, // actually in any place in virtual DOM
  div(
    myClass
  )  
)

Pros:

  • Korolev knows more about symantics of the app.
  • More opportunities for creating redistributable components.
  • Dynamic CSS. Allows to add comples rules ad-hoc.

Cons:

  • You need to decalre classes outside of body of CSS. It's in spirit of Korolev (like ElementId), but mind-blowing for common programmer.
  • Dynamic CSS. Allows to add comples rules ad-hoc. May be bad for runtime performance.
  • Dynamic CSS. Lack of global optimization.
  • No syntax highlighting in IDE in myCss1 case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment