-
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 sealed classes example and update sample component
- Loading branch information
Showing
11 changed files
with
246 additions
and
247 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
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 |
---|---|---|
|
@@ -7,58 +7,59 @@ import magnolia1.* | |
|
||
import io.github.iltotore.iron.* | ||
import io.github.iltotore.iron.constraint.all.* | ||
import samples.model.Password | ||
import java.time.LocalDate | ||
|
||
// Define some models | ||
@NoPanel | ||
case class Person( | ||
@FieldName("First Name") | ||
name: String, | ||
password: Password, | ||
birthDate: LocalDate, | ||
fav: Pet, | ||
pet: Option[Pet], | ||
email: Option[String], | ||
age: BigInt, | ||
size: Double | ||
) | ||
case class Pet( | ||
name: String, | ||
age: BigInt, | ||
House: House, | ||
size: Double :| Positive | ||
) | ||
val person = { | ||
// Define some models | ||
|
||
case class House(capacity: Int) | ||
@NoPanel | ||
case class Person( | ||
@FieldName("First Name") | ||
name: String, | ||
password: Password, | ||
birthDate: LocalDate, | ||
fav: Pet, | ||
pet: Option[Pet], | ||
email: Option[String], | ||
age: BigInt, | ||
size: Double | ||
) | ||
case class Pet( | ||
name: String, | ||
age: BigInt, | ||
House: House, | ||
size: Double :| Positive | ||
) | ||
|
||
// Provide default for optional | ||
given Defaultable[Pet] with | ||
def default = Pet("No pet", 0, House(0), 1) | ||
case class House(capacity: Int) | ||
|
||
// Instance your model | ||
val vlad = | ||
Person( | ||
"", | ||
Password("not a password"), | ||
LocalDate.of(1431, 11, 8), | ||
Pet("Batman", 666, House(2), 169), | ||
Some(Pet("Wolfy", 12, House(1), 42)), | ||
Some("[email protected]"), | ||
48, | ||
1.85 | ||
) | ||
// Provide default for optional | ||
given Defaultable[Pet] with | ||
def default = Pet("No pet", 0, House(0), 1) | ||
|
||
val personVar = Var(vlad) | ||
// Instance your model | ||
val vlad = | ||
Person( | ||
"", | ||
Password("not a password"), | ||
LocalDate.of(1431, 11, 8), | ||
Pet("Batman", 666, House(2), 169), | ||
Some(Pet("Wolfy", 12, House(1), 42)), | ||
Some("[email protected]"), | ||
48, | ||
1.85 | ||
) | ||
|
||
val person = Sample( | ||
"Person", | ||
div( | ||
child <-- personVar.signal.map { item => | ||
div( | ||
s"$item" | ||
) | ||
}, | ||
personVar.asForm | ||
val personVar = Var(vlad) | ||
Sample( | ||
"Person", | ||
div( | ||
child <-- personVar.signal.map { item => | ||
div( | ||
s"$item" | ||
) | ||
}, | ||
personVar.asForm | ||
) | ||
) | ||
) | ||
} |
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
Oops, something went wrong.