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

lucuma.ui.utils.Render.scala Maven / Gradle / Ivy

There is a newer version: 0.123.0
Show newest version
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA)
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause

package lucuma.ui.utils

import japgolly.scalajs.react.vdom.html_<^.*
import lucuma.core.syntax.display.given
import lucuma.core.util.Display

trait Render[A]:
  def renderVdom(value: A): VdomNode

object Render:
  def apply[A: Render]: Render[A] = summon[Render[A]]

  def by[A](f: A => VdomNode): Render[A] =
    new Render:
      def renderVdom(value: A) = f(value)

  def byShortName[A: Display]: Render[A] = by(_.shortName)

  def byLongName[A: Display]: Render[A] = by(_.longName)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy