Skip to content

Commit cbf052b

Browse files
authored
Scala3 and mui5 updates (#210)
* Remove admin projects * Update to scala3 and add st-material-ui library * Migrate to mui5
1 parent 0ddf15b commit cbf052b

20 files changed

Lines changed: 799 additions & 883 deletions

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project.git = true
33
project.excludeFilters = [
44
]
55

6-
runner.dialect=scala213
6+
runner.dialect=scala3
77

88
maxColumn = 120
99
assumeStandardLibraryStripMargin = false

build.sbt

Lines changed: 45 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ThisBuild / versionScheme := Some("early-semver")
22
// For all Sonatype accounts created on or after February 2021
33
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
4+
ThisBuild / scalaVersion := "3.3.0"
45

56
inThisBuild(
67
List(
@@ -22,6 +23,7 @@ inThisBuild(
2223
resolvers += Resolver.sonatypeRepo("releases")
2324

2425
val playJson = "2.10.0-RC5"
26+
val stMaterialUi = "5.11.16"
2527

2628
// Used only by the lib projects
2729
lazy val baseLibSettings: Project => Project = _.settings(
@@ -30,24 +32,10 @@ lazy val baseLibSettings: Project => Project = _.settings(
3032
"-encoding",
3133
"UTF-8",
3234
"-feature",
33-
"-language:implicitConversions"
34-
// disabled during the migration
35-
// "-Xfatal-warnings"
36-
) ++
37-
(CrossVersion.partialVersion(scalaVersion.value) match {
38-
case Some((3, _)) =>
39-
Seq(
40-
"-unchecked",
41-
"-source:3.0-migration"
42-
)
43-
case _ =>
44-
Seq(
45-
"-deprecation",
46-
"-Xfatal-warnings",
47-
"-Wunused:imports,privates,locals",
48-
"-Wvalue-discard"
49-
)
50-
})
35+
"-language:implicitConversions",
36+
"-unchecked",
37+
"-source:3.0-migration"
38+
)
5139
},
5240
libraryDependencies ++= Seq(
5341
"org.scalatest" %%% "scalatest" % "3.2.15" % Test
@@ -63,76 +51,23 @@ lazy val baseWebSettings: Project => Project =
6351
"-encoding",
6452
"UTF-8",
6553
"-feature",
66-
"-language:implicitConversions"
67-
// disabled during the migration
68-
// "-Xfatal-warnings"
69-
) ++
70-
(CrossVersion.partialVersion(scalaVersion.value) match {
71-
case Some((3, _)) =>
72-
Seq(
73-
"-unchecked",
74-
"-source:3.0-migration"
75-
)
76-
case _ =>
77-
Seq(
78-
"-deprecation",
79-
"-Xfatal-warnings",
80-
"-Wunused:imports,privates,locals",
81-
"-Wvalue-discard",
82-
"-Ymacro-annotations"
83-
)
84-
})
54+
"-language:implicitConversions",
55+
"-unchecked",
56+
"-source:3.0-migration"
57+
)
8558
},
8659
libraryDependencies ++= Seq(
8760
"io.github.cquiroz" %%% "scala-java-time" % "2.3.0",
8861
"org.scala-js" %%% "scala-js-macrotask-executor" % "1.1.1",
89-
"com.alexitc" %%% "sjs-material-ui-facade" % "0.2.0"
62+
"com.olvind.st-material-ui" %%% "st-material-ui-icons-slinky" % stMaterialUi
9063
)
9164
)
9265

93-
lazy val scalablytypedFacades = (project in file("scalablytyped-facades"))
94-
.configure(_.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin, ScalablyTypedConverterGenSourcePlugin))
95-
.settings(
96-
scalaVersion := "2.13.8",
97-
crossScalaVersions := Seq("2.13.8", "3.2.2"),
98-
name := "scalablytyped-facades",
99-
useYarn := true,
100-
Test / requireJsDomEnv := true,
101-
stTypescriptVersion := "3.9.3",
102-
stOutputPackage := "net.wiringbits.facades",
103-
// material-ui is provided by a pre-packaged library
104-
stIgnore ++= List(
105-
"@material-ui/core",
106-
"@material-ui/styles",
107-
"@material-ui/icons",
108-
"react-router",
109-
"react-router-dom"
110-
),
111-
Compile / npmDependencies ++= Seq(
112-
"@material-ui/core" -> "3.9.4", // note: version 4 is not supported yet
113-
"@material-ui/styles" -> "3.0.0-alpha.10", // note: version 4 is not supported yet
114-
"@material-ui/icons" -> "3.0.2",
115-
"@types/classnames" -> "2.2.10",
116-
"react-router" -> "5.1.2",
117-
"react-router-dom" -> "5.1.2"
118-
),
119-
stFlavour := Flavour.Slinky,
120-
stReactEnableTreeShaking := Selection.All,
121-
stUseScalaJsDom := true,
122-
stMinimize := Selection.AllExcept("@types/classnames"),
123-
// docs are huge and unnecessary
124-
Compile / doc / sources := Nil,
125-
// disabled because it somehow triggers many warnings
126-
scalaJSLinkerConfig ~= (_.withSourceMap(false))
127-
)
128-
12966
/** The common stuff for the server/client modules
13067
*/
13168
lazy val webappCommon = (crossProject(JSPlatform, JVMPlatform) in file("webapp-common"))
13269
.configure(baseLibSettings)
13370
.settings(
134-
scalaVersion := "2.13.8",
135-
crossScalaVersions := Seq("2.13.8", "3.2.2"),
13671
name := "webapp-common"
13772
)
13873
.jsConfigure(_.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin))
@@ -156,18 +91,46 @@ lazy val webappCommon = (crossProject(JSPlatform, JVMPlatform) in file("webapp-c
15691
*/
15792
lazy val slinkyUtils = (project in file("slinky-utils"))
15893
.configure(baseLibSettings, baseWebSettings)
159-
.configure(_.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin))
160-
.dependsOn(webappCommon.js, scalablytypedFacades)
94+
.configure(_.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin, ScalablyTypedConverterPlugin))
95+
.dependsOn(webappCommon.js)
16196
.settings(
162-
scalaVersion := "2.13.8",
163-
crossScalaVersions := Seq("2.13.8", "3.2.2"),
16497
name := "slinky-utils",
165-
Test / fork := false // sjs needs this to run tests
98+
Test / fork := false, // sjs needs this to run tests
99+
stTypescriptVersion := "3.9.3",
100+
useYarn := true,
101+
stFlavour := Flavour.Slinky,
102+
Compile / stMinimize := Selection.All,
103+
stIgnore ++= List(
104+
"react-proxy",
105+
"@mui/material",
106+
"@mui/icons-material",
107+
"@mui/joy",
108+
"@emotion/react",
109+
"@emotion/styled",
110+
"react-router",
111+
"react-router-dom"
112+
),
113+
Compile / npmDependencies ++= Seq(
114+
"react" -> "18.2.0",
115+
"react-dom" -> "18.2.0",
116+
"csstype" -> "2.6.11",
117+
"react-proxy" -> "1.1.8",
118+
"@mui/material" -> "5.11.16",
119+
"@mui/icons-material" -> "5.11.16",
120+
"@mui/joy" -> "5.0.0-alpha.74",
121+
"@emotion/react" -> "11.10.6",
122+
"@emotion/styled" -> "11.10.6",
123+
"react-router" -> "5.1.2",
124+
"react-router-dom" -> "5.1.2"
125+
),
126+
Compile / npmDevDependencies ++= Seq(
127+
"@types/react" -> "18.0.33",
128+
"@types/react-dom" -> "18.0.11",
129+
)
166130
)
167131

168132
lazy val root = (project in file("."))
169133
.aggregate(
170-
scalablytypedFacades,
171134
webappCommon.jvm,
172135
webappCommon.js,
173136
slinkyUtils
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package net.wiringbits.webapp.utils.slinkyUtils
2+
3+
import com.olvind.mui.muiMaterial.stylesCreateThemeMod.Theme
4+
import com.olvind.mui.muiSystem.styleFunctionSxStyleFunctionSxMod.SystemCssProperties
5+
6+
object Utils {
7+
type CSSPropertiesUtils = SystemCssProperties[Theme]
8+
}

slinky-utils/src/main/scala/net/wiringbits/webapp/utils/slinkyUtils/components/core/AlertDialog.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.wiringbits.webapp.utils.slinkyUtils.components.core
22

3-
import com.alexitc.materialui.facade.materialUiCore.{components => mui, materialUiCoreStrings => muiStrings}
3+
import com.olvind.mui.muiMaterial.components as mui
44
import slinky.core.{FunctionalComponent, KeyAddingStage}
55

66
object AlertDialog {
@@ -19,14 +19,13 @@ object AlertDialog {
1919
val component: FunctionalComponent[Props] = FunctionalComponent[Props] { props =>
2020
mui
2121
.Dialog(props.visible)
22-
.onClose(_ => props.onClose())(
22+
.onClose((_, _) => props.onClose())(
2323
mui.DialogTitle(props.title),
2424
mui.DialogContent(mui.DialogContentText(props.message)),
2525
mui.DialogActions(
26-
mui
27-
.Button()
28-
.variant(muiStrings.contained)
29-
.color(muiStrings.primary)
26+
mui.Button.normal
27+
.variant("contained")
28+
.color("primary")
3029
.onClick(_ => props.onClose())(props.closeText)
3130
)
3231
)

slinky-utils/src/main/scala/net/wiringbits/webapp/utils/slinkyUtils/components/core/AsyncComponent.scala

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package net.wiringbits.webapp.utils.slinkyUtils.components.core
22

3-
import com.alexitc.materialui.facade.materialUiCore.{components => mui}
4-
import slinky.core.FunctionalComponent
3+
import com.olvind.mui.muiMaterial.components as mui
4+
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits.*
55
import slinky.core.facade.{Hooks, ReactElement}
6-
import slinky.web.html._
6+
import slinky.core.{FunctionalComponent, KeyAddingStage}
77

8-
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits._
98
import scala.concurrent.Future
109
import scala.util.{Failure, Success}
1110

@@ -55,6 +54,28 @@ object AsyncComponent {
5554
watchedObjects: Iterable[Any] = List("")
5655
)
5756

57+
def apply[D](
58+
fetch: () => Future[D],
59+
render: D => ReactElement,
60+
onDataLoaded: D => Unit = (_: D) => (),
61+
progressIndicator: () => ReactElement = () => loader,
62+
progressIndicatorWhileReloadingData: Boolean = false,
63+
retryLabel: String = "Retry",
64+
watchedObjects: Iterable[Any] = List("")
65+
): KeyAddingStage = {
66+
component[D](
67+
Props(
68+
fetch,
69+
render,
70+
onDataLoaded,
71+
progressIndicator,
72+
progressIndicatorWhileReloadingData,
73+
retryLabel,
74+
watchedObjects
75+
)
76+
)
77+
}
78+
5879
/** @tparam D
5980
* The data to fetch and render
6081
* @return
@@ -95,17 +116,17 @@ object AsyncComponent {
95116
}
96117

97118
private def loader: ReactElement = {
98-
div(
119+
mui.Box(
99120
mui.CircularProgress()
100121
)
101122
}
102123

103124
private def error[D](msg: String, props: Props[D], reload: () => Unit): ReactElement = {
104-
div(
125+
mui.Box(
105126
mui
106127
.Typography()
107-
.color(com.alexitc.materialui.facade.materialUiCore.mod.PropTypes.Color.secondary)(msg),
108-
mui.Button.onClick(_ => reload())(props.retryLabel)
128+
.color("secondary")(msg),
129+
mui.Button.normal.onClick(_ => reload())(props.retryLabel)
109130
)
110131
}
111132
}

slinky-utils/src/main/scala/net/wiringbits/webapp/utils/slinkyUtils/components/core/ConfirmDialog.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.wiringbits.webapp.utils.slinkyUtils.components.core
22

3-
import com.alexitc.materialui.facade.materialUiCore.mod.PropTypes
4-
import com.alexitc.materialui.facade.materialUiCore.{components => mui}
3+
import com.olvind.mui.muiMaterial.components as mui
54
import slinky.core.{FunctionalComponent, KeyAddingStage}
65

76
object ConfirmDialog {
@@ -41,14 +40,13 @@ object ConfirmDialog {
4140
val component: FunctionalComponent[Props] = FunctionalComponent[Props] { props =>
4241
mui
4342
.Dialog(props.visible)
44-
.onClose(_ => props.onCancel())(
43+
.onClose((_, _) => props.onCancel())(
4544
mui.DialogTitle(props.title),
4645
mui.DialogContent(mui.DialogContentText(props.message)),
4746
mui.DialogActions(
48-
mui.Button().color(PropTypes.Color.secondary).onClick(_ => props.onCancel())(props.cancelText),
49-
mui
50-
.Button()
51-
.color(PropTypes.Color.primary)
47+
mui.Button.normal.color("secondary").onClick(_ => props.onCancel())(props.cancelText),
48+
mui.Button.normal
49+
.color("primary")
5250
.onClick(_ => props.onConfirm())(props.confirmText)
5351
)
5452
)

0 commit comments

Comments
 (0)