-
Notifications
You must be signed in to change notification settings - Fork 4
/
TargetImpl.scala
53 lines (46 loc) · 1.4 KB
/
TargetImpl.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import scala.meta._
sealed trait TargetImpl {
def imports: List[Import]
def C: Defn.Object
def implicitClass: Defn.Class
}
object TargetImpl {
object ScalaJsReact extends TargetImpl {
override def imports = List(
q"import japgolly.scalajs.react.vdom.html_<^._",
q"import japgolly.scalajs.react.vdom.{TagOf, TopNode}"
)
override def C =
q"""
object C extends Classes[TagMod] {
protected override def op(clz: String) = ^.cls := clz
}
"""
override def implicitClass =
q"""
implicit class ConvertableToTagOfExtensionMethods[T, N <: TopNode](self: T)(implicit toTagOf: T => TagOf[N])
extends Classes[TagOf[N]] {
protected override def op(clz: String): TagOf[N] = toTagOf(self).apply(^.cls := clz)
}
"""
}
object Scalatags extends TargetImpl {
override def imports = List(
q"import scalatags.Text.all._"
)
override def C =
q"""
object C extends Classes[Modifier] {
protected override def op(clz: String) = cls := clz
}
"""
override def implicitClass =
q"""
implicit class ConvertableToTagOfExtensionMethods[O <: String](self: ConcreteHtmlTag[O])
extends Classes[ConcreteHtmlTag[O]] {
protected override def op(clz: String): ConcreteHtmlTag[O] =
self(cls := clz)
}
"""
}
}