Skip to content

Commit

Permalink
refactor(samples): Weird behaviour ... demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cheleb committed Jan 20, 2025
1 parent 1728c09 commit 3876bb3
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions examples/client/src/main/scala/samples/Conditional.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ package samples
import dev.cheleb.scalamigen.*
import com.raquo.laminar.api.L.*

val conditional = {
case class Person(
firstname: String,
lastname: String,
age: Int,
extra_str: Option[ExtraString],
extra_int: Option[ExtraInt]
)

case class Person(
firstname: String,
lastname: String,
age: Int,
extra_str: Option[ExtraString],
extra_int: Option[ExtraInt]
)
object Person:
val empty = Person("John", "Doe", 16, None, None)

object Person:
val empty = Person("John", "Doe", 16, None, None)
@Panel("Conditional", false)
case class ConditionalSample(
person: Person
)

@Panel("Conditional", false)
case class ConditionalSample(
person: Person
)
given ConditionalFor[ConditionalSample, ExtraString] with
def check = _.person.age >= 18

given ConditionalFor[ConditionalSample, ExtraString] with
def check = _.person.age >= 18
given ConditionalFor[ConditionalSample, ExtraInt] with
def check = _.person.age >= 18

given ConditionalFor[ConditionalSample, ExtraInt] with
def check = _.person.age >= 18
given Defaultable[Person] with
def default = Person.empty

given Defaultable[Person] with
def default = Person.empty
val conditionalVar = Var(ConditionalSample(Person.empty))

val conditionalVar = Var(ConditionalSample(Person.empty))
given formExtraString: Form[Option[ExtraString]] =
Form.conditionalOn[ConditionalSample, ExtraString](conditionalVar)

given formExtraString: Form[Option[ExtraString]] =
Form.conditionalOn[ConditionalSample, ExtraString](conditionalVar)
given formExtraInt: Form[Option[ExtraInt]] =
Form.conditionalOn[ConditionalSample, ExtraInt](conditionalVar)

given formExtraInt: Form[Option[ExtraInt]] =
Form.conditionalOn[ConditionalSample, ExtraInt](conditionalVar)
val conditional = {

Sample(
"Conditional",
Expand Down

0 comments on commit 3876bb3

Please sign in to comment.