by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Shane
    @Shailpat3Shane_twitter
    Is this correct way to do file upload
    val fileInput: HTMLInputElement = document.getElementById("imageId").asInstanceOf[HTMLInputElement] This works but using ScalaJs
    Sakib Hadžiavdić
    @sake92
    Shane
    @Shailpat3Shane_twitter
    I have confused let me explain I have input field scalatag and div which is button (called as upload), I select the file first and then click the upload button , which should read the file and it works if instead of passing the val input button, I used getELementById on the input id val fileInput: HTMLInputElement = document.getElementById("imageId").asInstanceOf[HTMLInputElement], Then all work fine but I am trying to avoid using this way, instead pass the val input defined and used object input.render.files(0)
    Shane
    @Shailpat3Shane_twitter
    Hi Sorry it was my bad I was not doing input.render before passing to the function upload :)
    Sakib Hadžiavdić
    @sake92
    Any feedback on lihaoyi/scalatags#205 ? :)
    Todd O'Bryan
    @toddobryan
    Anybody know how to get scalatags building with SBT? I'm trying to create a PR with the crossorigin attribute working.
    Todd O'Bryan
    @toddobryan
    Or, alternatively, how to get IntelliJ to stop treating the project as an SBT project so that I can start using Mill, instead?
    Li Haoyi
    @lihaoyi
    i think the sbt build has been broken for a while
    only thing its meant to do js generate the readme page
    Todd O'Bryan
    @toddobryan
    So, given that you're here... Do you want to support a crossorigin attr, and how do you want to handle attrs with enum values?
    Todd O'Bryan
    @toddobryan

    I was thinking something like this:

      /**
       * The crossorigin attribute, valid on the <audio>, <img>, <link>,
       * <script>, and <video> elements, provides support for CORS, defining how the
       * element handles crossorigin requests, thereby enabling the configuration of the CORS requests
       * for the element's fetched data. Depending on the element, the attribute can be a CORS settings
       * attribute.
       *
       * The crossorigin content attribute on media elements is a CORS settings attribute.
       *
       * These attributes are enumerated, and have the following possible values:
       *  - anonymous
       *  - use-credentials
       *  - "" (empty)
       *  
       *  MDN
       */
      object crossorigin {
        private val co = attr("crossorigin")
        val anonymous = co:="anonymous"
        val usecredentials = co:="use-credentials"
        val empty = co.empty
      }

    but I don't see anything like that in the rest of the codebase, so I don't know if that makes sense.

    Todd O'Bryan
    @toddobryan
    Actually, I guess empty would have to be co:="". I tried attr("crossorigin").empty in the project I'm working on and I got crossorigin="crossorigin" in the HTML.
    Li Haoyi
    @lihaoyi
    sure sounds reasonable
    Li Haoyi
    @lihaoyi
    @/all my book Hands-on Scala Programming is out https://www.handsonscala.com/, with multiple chapters using Scalatags heavily. If you like using Scalatags, you should definitely check it out :)
    Soren
    @srnb_gitlab
    Is it possible to have a project where it outputs a single HTML file with ScalaJS code embedded? I.e. in a <script>blah</script> and not a <script src="blah"></script>
    So far I'm thinking I should just make a JVM project that reads the output from ScalaJS and then an SBT task that runs mySJS/fullOptJS::webpack before the JVM project runs, but I want to know if there's an easier solution
    Marcin Józefowicz
    @marcin-jozefowicz

    Hi!
    Do you know how I can test Text.TypedTag[String] against structure and content? I have spot only method modifiers but I don't know what to do next to get the structure? Any hint will be aprreciated.

    result.modifiers.flatten.map(a => {
          println(a.leftSide)
          println(a.leftSideValue)
        }

    Or maybe there is only to examine output base on generated string ?

    Li Haoyi
    @lihaoyi
    Scalatags doesn’t really expose any stable data structure for you to test against, your best bet might be parsing the output string using JSoup and then querying it to do your tests
    Marcin Józefowicz
    @marcin-jozefowicz
    Thanks @lihaoyi
    Sakib Hadžiavdić
    @sake92
    there is support for Selenium embedded in ScalaTest also :)
    nafg
    @nafg
    How hard would it be to implement a scalatags module that built a plain data structure?
    Li Haoyi
    @lihaoyi
    not terribly hard, we already have modules that build vdom nodes and dom nodes
    Bruno Medeiros
    @bruno-medeiros
    Heya folks, why is this import failing:
    import scalatags.JsDom.all._ (says it cannot find JsDom)
    I have libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.9.1" in build.sbt
    Bruno Medeiros
    @bruno-medeiros
    okay... newbiew mistake, should have been "com.lihaoyi" %%% "scalatags" % "0.9.1"
    Andreas Jim-Hartmann
    @devkat
    Hi all, I’m trying to use an optional attribute:
        val fontFamilyAttr = style.get(FontFamily).map(fontFamily := _)
        tspan(
          fontFamilyAttr,
          chars.mkString
        )
    But I get this error:
    type mismatch;
    [error]  found   : Option[scalatags.generic.AttrPair[org.scalajs.dom.Element,String]]
    [error]     (which expands to)  Option[scalatags.generic.AttrPair[org.scalajs.dom.raw.Element,String]]
    [error]  required: scalatags.JsDom.Modifier
    [error]     (which expands to)  scalatags.generic.Modifier[org.scalajs.dom.raw.Element]
    [error]       fontFamilyAttr,
    The relevant imports look like this:
    import scalatags.JsDom.all.{fontFamily => _, _}
    import scalatags.JsDom.svgAttrs.{OptionFrag => _, SeqFrag => _, _}
    import scalatags.JsDom.svgTags.{OptionFrag => _, SeqFrag => _, _}
    (see lihaoyi/scalatags#209 regarding the disabled imports)
    Any hints are very welcome
    I tried this:
        val fontFamilyAttr = OptionFrag(style.get(FontFamily).map(fontFamily := _))
    No implicit view available from scalatags.generic.AttrPair[org.scalajs.dom.Element,String] => scalatags.generic.Frag[org.scalajs.dom.Element,org.scalajs.dom.Node].
    [error]     val fontFamilyAttr = OptionFrag(style.get(FontFamily).map(fontFamily := _))
    Andreas Jim-Hartmann
    @devkat
    It works with these imports:
    import scalatags.JsDom.all._
    import scalatags.JsDom.svgAttrs.{x, y}
    import scalatags.JsDom.svgTags.{g, text, tspan}
    Soren
    @srnb_gitlab
    How can I use ScalaTags CSS to override default settings?
    I.e. apply a style to <body> instead of a new class
    Win Wang
    @wiwa

    I.e. apply a style to <body> instead of a new class

    Bump. I think the "normal" way is to use a link with href to the static css. But obviously we can't do that :grimacing:

    Win Wang
    @wiwa
    Specifically, trying to use scalatags with http4s, not sure how to deal with CSS in this case :)
    Sakib Hadžiavdić
    @sake92
    what about scalacss maybe?
    Win Wang
    @wiwa
    i could use that but considering how scalatags supports css already, i feel sadness
    Li Haoyi
    @lihaoyi
    scalatags css is just one of many possible approaches, if it doesnt work for your use case don’t use it
    Kevin Meredith
    @kevinmeredith
    :question: Hi - could someone please point me to a basic example of using this library for building a simple <form> that submits application/x-www-form-urlencoded? Thanks!
    Li Haoyi
    @lihaoyi
    isn't the application-x-www-form-urlencoded thing handled by the browser? so it would just be a vanilla HTML <form>
    Kevin Meredith
    @kevinmeredith

    isn't the application-x-www-form-urlencoded thing handled by the browser?

    Yes, that's my understanding per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form.

    so it would just be a vanilla HTML <form>

    Could you please point me to such an example?

    Kevin Meredith
    @kevinmeredith
    Thank you, @lihaoyi , for your help and this library!
    ^^ Oh - I was asking about a simple <form> example in ScalaTags. After reviewing the well-written README, https://www.lihaoyi.com/scalatags/, I don't recall seeing a form example.
    Li Haoyi
    @lihaoyi
    oh it's just a mechanical translation between scalatags and HTML, so I didn't put one in
    in fact, it's so mechanical that often http://simerplaha.github.io/html-to-scalatags-converter/ is enough :P
    i use it quite often when copying HTML from documentation pages of libraries like bootstrap
    Li Haoyi
    @lihaoyi
    works like 97% of the time
    Kevin Meredith
    @kevinmeredith
    Thanks!