-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new sample for opaque type in Index.scala
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
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} |