All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.harana.scalajs.react.sparkline.Sparkline.scala Maven / Gradle / Ivy

The newest version!
package com.harana.scalajs.react.sparkline

import com.harana.scalajs.react.macros.JSMacro
import com.harana.scalajs.react.sparkline.Sparkline._
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.html_<^._

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

@JSImport("@data-ui/sparkline", "Sparkline")
@js.native
object SparklineRequire extends js.Any

case class Sparkline(
  ariaLabel: String,
  className: js.UndefOr[String] = js.undefined,
  data: js.UndefOr[js.Array[Double]] = js.undefined,
  height: Int,
  margin: js.UndefOr[Margin] = js.undefined,
  max: js.UndefOr[Double] = js.undefined,
  min: js.UndefOr[Double] = js.undefined,
  onMouseMove: js.UndefOr[OnMouseMove] = js.undefined,
  onMouseLeave: js.UndefOr[OnMouseLeave] = js.undefined,
  styles: js.UndefOr[js.Object] = js.undefined,
  width: Int,
  valueAccessor: js.UndefOr[ValueAccessor] = js.undefined,
){
  def apply(children: VdomNode*) = {
    val props = JSMacro[Sparkline](this)
    val f = JsComponent[js.Object, Children.Varargs, Null](SparklineRequire)
    f(props)(children: _*)
  }
}

object Sparkline {
  type OnMouseMove = (ReactEvent, js.Array[Double], Double, String) => Callback
  type OnMouseLeave = (ReactEvent, js.Array[Double], Double, String) => Callback
  type ValueAccessor = Double => Double

  implicit def toTagMod(s: Sparkline): TagMod = s()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy