Skip to content

Commit

Permalink
Clean samples
Browse files Browse the repository at this point in the history
  • Loading branch information
cheleb committed Nov 25, 2023
1 parent 12e98bd commit 693f63a
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 257 deletions.
40 changes: 2 additions & 38 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import java.nio.charset.StandardCharsets
import org.scalajs.linker.interface.ModuleSplitStyle

lazy val currentYear: String =
java.util.Calendar.getInstance().get(java.util.Calendar.YEAR).toString

val scala33 = "3.3.1"

inThisBuild(
Expand Down Expand Up @@ -37,7 +34,6 @@ inThisBuild(
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-Wunused:all",
"-Xfatal-warnings"
)
)
Expand Down Expand Up @@ -102,7 +98,8 @@ val usedScalacOptions = Seq(
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-Xmax-inlines:64"
"-Xmax-inlines:64",
"-Wunused:all"
)
lazy val core = scalajsProject("core", false)
.settings(
Expand Down Expand Up @@ -222,36 +219,3 @@ Global / onLoad := {

(Global / onLoad).value
}
enablePlugins(
SiteScaladocPlugin,
SitePreviewPlugin,
ScalaUnidocPlugin,
GhpagesPlugin
)

ScalaUnidoc / siteSubdirName := ""
addMappingsToSiteDir(
ScalaUnidoc / packageDoc / mappings,
ScalaUnidoc / siteSubdirName
)
git.remoteRepo := "[email protected]:cheleb/laminar-form-derivation.git"
ghpagesNoJekyll := true
Compile / doc / scalacOptions ++= Seq(
"-siteroot",
"docs",
"-project",
"Laminar Form Derivation",
"-groups",
"-project-version",
version.value,
"-revision",
version.value,
"-default-templates",
"static-site-main",
"-project-footer",
s"Copyright (c) 2022-$currentYear, Olivier NOUGUIER",
"-Ygenerate-inkuire",
"-skip-by-regex:demo\\..*",
"-skip-by-regex:samples\\..*",
"-snippet-compiler:compile"
)
2 changes: 1 addition & 1 deletion docs/_docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Installation

```sbt
libraryDependencies += "dev.cheleb" %% "laminar-form-derivation" % "0.1.0"
libraryDependencies += "dev.cheleb" %%% "laminar-form-derivation" % "{{ version }}"
```

### Requirements
Expand Down
8 changes: 8 additions & 0 deletions docs/_docs/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```scala mdoc
import java.time.Instant

def now() = Instant.now()
object Foo extends App{
println(now())
}
```
71 changes: 25 additions & 46 deletions examples/client/src/main/scala/HelloWorld.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package demo
package samples

import org.scalajs.dom
import com.raquo.laminar.api.L.*
import be.doeraene.webcomponents.ui5.*
import samples.tree

case class Sample(name: String, component: HtmlElement)

object App extends App {

val sample = Var(samples.enums)
val sample = Var(samples.enums.component)

private def item(name: String) = SideNavigation.item(
_.text := name,
dataAttr("component-name") := name
)

private val demos = Seq(
samples.simple,
samples.either,
samples.enums,
samples.person,
samples.validation,
samples.list,
samples.tree
)

val myApp =
div(
Expand All @@ -23,51 +39,14 @@ object App extends App {
_.events.onSelectionChange
.map(_.detail.item.dataset.get("componentName")) --> Observer[
Option[String]
] {
case e @ Some("Either") =>
sample.set(samples.either)
case e @ Some("Enums") =>
sample.set(samples.enums)
case v @ Some("Person") =>
sample.set(samples.person)
case v @ Some("Validation") =>
sample.set(samples.validation)
case v @ Some("Lists") =>
sample.set(
samples.component
)
case v @ Some("Tree") =>
sample.set(tree.component)
case _ =>
sample.set(div("????"))
] { name =>
val el = name
.flatMap(n => demos.find(_.name == n))
.getOrElse(samples.simple)
sample.set(el.component)

},
Seq(
SideNavigation.item(
_.text := "Either",
dataAttr("component-name") := "Either"
),
SideNavigation.item(
_.text := "Enums",
dataAttr("component-name") := "Enums"
),
SideNavigation.item(
_.text := "Person",
dataAttr("component-name") := "Person"
),
SideNavigation.item(
_.text := "Validation",
dataAttr("component-name") := "Validation"
),
SideNavigation.item(
_.text := "List",
dataAttr("component-name") := "Lists"
),
SideNavigation.item(
_.text := "Tree",
dataAttr("component-name") := "Tree"
)
)
demos.map(_.name).map(item)
)
),
div(
Expand Down
4 changes: 2 additions & 2 deletions examples/client/src/main/scala/WebSocketDemo.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package polyui
package samples

import com.raquo.laminar.api.L.{*, given}
import com.raquo.laminar.api.L.*
import be.doeraene.webcomponents.ui5.*
import be.doeraene.webcomponents.ui5.configkeys.*
import io.laminext.websocket._
Expand Down
32 changes: 17 additions & 15 deletions examples/client/src/main/scala/samples/EitherSample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ import com.raquo.laminar.api.L.*

import com.raquo.airstream.state.Var

val either = {
val either = Sample(
"Either", {

case class EitherSample(
either: Either[Cat, Dog],
optionalInt: Option[Int]
)
case class EitherSample(
either: Either[Cat, Dog],
optionalInt: Option[Int]
)

val eitherVar = Var(EitherSample(Left(Cat("Scala le chat", 6)), Some(1)))
val eitherVar = Var(EitherSample(Left(Cat("Scala le chat", 6)), Some(1)))

div(
child <-- eitherVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(eitherVar)
)
}
div(
child <-- eitherVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(eitherVar)
)
}
)
60 changes: 31 additions & 29 deletions examples/client/src/main/scala/samples/EnumSample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@ import com.raquo.laminar.api.L.*

import com.raquo.airstream.state.Var

val enums = {

enum Color(code: String):
case Black extends Color("000")
case White extends Color("FFF")
case Isabelle extends Color("???")

case class Basket(@EnumValues(Color.values) color: Color, cat: Cat)

case class Cat(
name: String,
age: Int,
@EnumValues(Color.values)
color: Color
)

val eitherVar = Var(
Basket(Color.Black, Cat("Scala", 10, Color.White))
)

div(
child <-- eitherVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(eitherVar)
)
}
val enums = Sample(
"Enums", {

enum Color(val code: String):
case Black extends Color("000")
case White extends Color("FFF")
case Isabelle extends Color("???")

case class Basket(@EnumValues(Color.values) color: Color, cat: Cat)

case class Cat(
name: String,
age: Int,
@EnumValues(Color.values)
color: Color
)

val eitherVar = Var(
Basket(Color.Black, Cat("Scala", 10, Color.White))
)

div(
child <-- eitherVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(eitherVar)
)
}
)
32 changes: 16 additions & 16 deletions examples/client/src/main/scala/samples/ListElement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import dev.cheleb.scalamigen.{*, given}

import com.raquo.laminar.api.L.*

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.Positive

case class Person2(name: String, age: Int)

case class ListElement(
Expand All @@ -16,17 +13,20 @@ case class ListElement(
val listPersonVar = Var(ListElement(List(1, 2, 3).map(Person2("Vlad", _))))
val listIntVar = Var(List(1, 2, 3))

val component = div(
child <-- listPersonVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(listPersonVar),
child <-- listIntVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(listIntVar)
val list = Sample(
"List",
div(
child <-- listPersonVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(listPersonVar),
child <-- listIntVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(listIntVar)
)
)
19 changes: 10 additions & 9 deletions examples/client/src/main/scala/samples/Persons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package samples

import dev.cheleb.scalamigen.{*, given}

import org.scalajs.dom
import com.raquo.laminar.api.L.*
import magnolia1.*
import be.doeraene.webcomponents.ui5.*

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*
Expand Down Expand Up @@ -45,11 +43,14 @@ val vlad =

val personVar = Var(vlad)

def person = div(
child <-- personVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(personVar)
val person = Sample(
"Person",
div(
child <-- personVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(personVar)
)
)
23 changes: 23 additions & 0 deletions examples/client/src/main/scala/samples/SimpleSample.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package samples

import dev.cheleb.scalamigen.{*, given}

import com.raquo.laminar.api.L.*

import com.raquo.airstream.state.Var

val simple = Sample(
"Simple", {

val eitherVar = Var(Cat("Scala le chat", 6))

div(
child <-- eitherVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(eitherVar)
)
}
)
Loading

0 comments on commit 693f63a

Please sign in to comment.