Skip to content

Commit

Permalink
feat: Add new sample for opaque type in Index.scala
Browse files Browse the repository at this point in the history
Add a new sample for opaque type in the Index.scala file. This sample demonstrates the usage of an opaque type in a case class called Person, which includes a name and a password. The sample also includes a simpleVar variable that holds an instance of Person and renders it in the UI.
  • Loading branch information
cheleb committed Oct 6, 2024
1 parent 301827a commit 5ac6fe4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/client/src/main/scala/Index.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ object App extends App {

private val demos = Seq(
samples.simple,
samples.opaque,
samples.either,
samples.validation,
samples.enums,
Expand Down
36 changes: 36 additions & 0 deletions examples/client/src/main/scala/samples/OpaqueType.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package samples

import com.raquo.laminar.api.L.*
import dev.cheleb.scalamigen.*

val opaque = {

case class Person(
name: String,
password: Password
)

val simpleVar = Var(Person("Vlad", Password("123456")))
Sample(
"Opaque Type",
simpleVar.asForm,
div(
child <-- simpleVar.signal.map { item =>
div(
s"$item"
)
}
),
"""
|case class Person(
| name: String,
| weight: Int,
| hairsCount: BigInt :| GreaterEqual[100000],
| kind: Boolean = true)
|
|val simpleVar = Var(Person("Vlad", 66, BigInt(100000).refineUnsafe))
|
|simpleVar.asForm
""".stripMargin
)
}

0 comments on commit 5ac6fe4

Please sign in to comment.