diff --git a/examples/client/src/main/scala/HelloWorld.scala b/examples/client/src/main/scala/HelloWorld.scala index 59e3c67..a0d285d 100644 --- a/examples/client/src/main/scala/HelloWorld.scala +++ b/examples/client/src/main/scala/HelloWorld.scala @@ -17,6 +17,7 @@ object App extends App { private val demos = Seq( samples.simple, + samples.sealedClasses, samples.either, samples.enums, samples.person, diff --git a/examples/client/src/main/scala/samples/Sealed.scala b/examples/client/src/main/scala/samples/Sealed.scala new file mode 100644 index 0000000..21f9d23 --- /dev/null +++ b/examples/client/src/main/scala/samples/Sealed.scala @@ -0,0 +1,29 @@ +package samples + +import dev.cheleb.scalamigen.{*, given} + +import com.raquo.laminar.api.L.* + +import com.raquo.airstream.state.Var + +sealed trait Animal +case class Horse(name: String, age: Int) extends Animal +case class Lama(name: String, age: Int, splitDistance: Int) extends Animal + +case class Owner(name: String, pet: Animal) + +val sealedClasses = Sample( + "Sealed", { + + val eitherVar = Var(Owner("Agnes", Horse("Scala le chat", 6))) + + div( + child <-- eitherVar.signal.map { item => + div( + s"$item" + ) + }, + eitherVar.asForm + ) + } +) diff --git a/examples/client/src/main/scala/samples/Tree.scala b/examples/client/src/main/scala/samples/Tree.scala index 53a70a8..830bec6 100644 --- a/examples/client/src/main/scala/samples/Tree.scala +++ b/examples/client/src/main/scala/samples/Tree.scala @@ -17,7 +17,8 @@ object Tree: case (Empty, Node(_, _, _)) => false case (Node(_, left1, right1), Node(_, left2, right2)) => isSameStructure(left1, left2) && isSameStructure(right1, right2) -implicit def treeInstance[A](using + +given treeInstance[A](using default: Defaultable[A] )(using Form[A]): Form[Tree[A]] = new Form[Tree[A]] { self =>