Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style prop to ScrollView, as already available for View #324

Closed
wants to merge 11 commits into from
55 changes: 20 additions & 35 deletions .github/workflows/sbt.yml
Expand Up @@ -10,55 +10,43 @@ on:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Style checks
run: sbt styleCheck
- name: Install NPM Dependencies
run: npm install; cd native; npm install; cd ..
- name: Test with SBT (fastopt)
run: sbt scalajsReactInterop/test +tests/test +native/test
- name: Test with SBT (fullopt)
run: sbt "set Global/scalaJSStage := FullOptStage" scalajsReactInterop/test +tests/test +native/test
test-windows:
runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false

matrix:
os: [ubuntu-latest, windows-latest]
scalajs: ["0.6.31", "1.0.0-RC2"]
steps:
- name: Configure git to disable Windows line feeds
run: "git config --global core.autocrlf false"
shell: bash
- uses: actions/checkout@master
# Pre-installed SBT on Windows-runner is unstable so use more polished 3rd-party action olafurpg/setup-scala.
- name: Set up JDK 1.8 and SBT
uses: olafurpg/setup-scala@v7
with:
java-version: 1.8
- name: Style checks
run: sbt styleCheck
- name: Install NPM Dependencies
run: npm install; cd native; npm install; cd ..
run: npm install; cd tests; npm install; cd ..; cd native; npm install; cd ..
shell: bash
- name: Test with SBT (fastopt)
run: sbt scalajsReactInterop/test +tests/test +native/test
- name: Test core and native (fastopt + fullopt)
run: sbt +tests/test +native/test "set scalaJSStage in Global := FullOptStage" +tests/test +native/test
env:
SCALAJS_VERSION: ${{ matrix.scalajs }}
shell: bash
- name: Test with SBT (fullopt)
run: sbt "set Global/scalaJSStage := FullOptStage" scalajsReactInterop/test +tests/test +native/test
- name: Test Scala.js React Interop (fastopt + fullopt)
if: matrix.scalajs == '0.6.31'
run: sbt scalajsReactInterop/test "set scalaJSStage in Global := FullOptStage" scalajsReactInterop/test
env:
SCALAJS_VERSION: ${{ matrix.scalajs }}
shell: bash
build-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 1.8 and SBT
uses: olafurpg/setup-scala@v7
with:
java-version: 1.8
- name: Install NPM Dependencies
Expand All @@ -71,24 +59,21 @@ jobs:
BUNDLESIZE_TOKEN: N2JjZDIxYjA1OGU1YzkwOWVkZWYzOWQ5MWYyZjRhYTgyMzE3MzY3Mgo=
build-intellij-plugin:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 1.8 and SBT
uses: olafurpg/setup-scala@v7
with:
java-version: 1.8
- name: Build IntelliJ Plugin
run: sbt coreIntellijSupport/updateIntellij coreIntellijSupport/compile
publish:
# Currently publication doesn't depend on testing results for Windows platform, since primary developers use Linux,
# but it may be changed in the future.
needs: [test, build-docs, build-intellij-plugin]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 1.8 and SBT
uses: olafurpg/setup-scala@v7
with:
java-version: 1.8
- run: git fetch --unshallow
Expand Down
10 changes: 10 additions & 0 deletions .scalafmt.conf
@@ -0,0 +1,10 @@
version = 2.3.0
project.git = true
maxColumn = 120
align = more
assumeStandardLibraryStripMargin = true
rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, SortModifiers]
rewrite.redundantBraces.stringInterpolation = true
spaces.afterTripleEquals = true
continuationIndent.defnSite = 2
includeCurlyBraceInSelectChains = false
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@
+ Add novalidate attribute to form [PR #315](https://github.com/shadaj/slinky/pull/315)
+ Add apply method for constructing CustomTag and CustomAttributes [PR #318](https://github.com/shadaj/slinky/pull/318)
+ Fix types for the useCallback hook and fix its reference equality behavior [PR #302](https://github.com/shadaj/slinky/pull/302)
+ Use js.Object instead of js.Dynamics on attribute style [PR #322](https://github.com/shadaj/slinky/pull/322)
+ Add support for Scala.js 1.0.0-RC2 [PR #321](https://github.com/shadaj/slinky/pull/321)
+ Rewrite the class component logic to patch the component definition once to handle JS data instead of on every initialization [PR #321](https://github.com/shadaj/slinky/pull/321)
+ Add missing inherited props to native ScrollView component [PR #324](https://github.com/shadaj/slinky/pull/324)

## [v0.6.3](https://slinky.dev)
### Highlights :tada:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -7,7 +7,9 @@
<a href="https://www.scala-js.org">
<img src="https://www.scala-js.org/assets/badges/scalajs-0.6.17.svg"/>
</a>
<img src="https://img.shields.io/maven-central/v/me.shadaj/slinky-core_sjs0.6_2.12.svg"/>
<a href="https://maven-central-latest.netlify.com/.netlify/functions/latest-link?org=me.shadaj&name=slinky-core_sjs0.6_2.12&format=libraryDependencies%20%2B%3D%20%22me.shadaj%22%20%25%25%25%20%22slinky-core%22%20%25%20%22VERSION%22">
<img src="https://maven-central-latest.netlify.com/.netlify/functions/latest-link?org=me.shadaj&name=slinky-core_sjs0.6_2.12&formatRedirect=https%3A%2F%2Fimg.shields.io%2Fbadge%2Fmaven--central-VERSIONDOUBLEDASHED-orange.svg"/>
</a>
<a href="https://gitter.im/shadaj/slinky?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
<img src="https://badges.gitter.im/shadaj/slinky.svg"/>
</a>
Expand Down Expand Up @@ -40,7 +42,7 @@ Slinky is split up into several submodules:
+ `tests` contains the unit tests for the above modules (except native and vr which have local tests)
+ `docs` and `docsMacros` contains the documentation site, which is a Slinky app itself

To run the main unit tests, run `sbt tests/test`.
To run the main unit tests, first install the dependencies by running `npm install` inside the `tests` folder, then from the base folder run `sbt tests/test`. Similarly for React Native tests, run `npm install` inside the `native` folder, then from the base folder run `sbt native/test`.

Note to IntelliJ IDEA users. When you try to import Slinky SBT definition in IDEA and encounter an exception like
`java.nio.file.NoSuchFileException: /Users/someuser/.slinkyPluginIC/sdk/192.6817.14/plugins`, you should
Expand Down
192 changes: 117 additions & 75 deletions build.sbt
Expand Up @@ -4,34 +4,39 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
turbo := true

ThisBuild / libraryDependencies += compilerPlugin(scalafixSemanticdb)
addCommandAlias("style", "Compile/scalafix; Test/scalafix")
addCommandAlias("styleCheck", "Compile/scalafix --check; Test/scalafix --check")
addCommandAlias("style", "compile:scalafix; test:scalafix; compile:scalafmt; test:scalafmt; scalafmtSbt")
addCommandAlias(
"styleCheck",
"compile:scalafix --check; test:scalafix --check; compile:scalafmtCheck; test:scalafmtCheck; scalafmtSbtCheck"
)

val scala212 = "2.12.10"
val scala213 = "2.13.1"

ThisBuild / scalaVersion := scala212

lazy val slinky = project.in(file(".")).aggregate(
readWrite,
core,
web,
history,
reactrouter,
testRenderer,
native,
vr,
hot,
scalajsReactInterop
).settings(
publish := {},
publishLocal := {}
)
lazy val slinky = project
.in(file("."))
.aggregate(
readWrite,
core,
web,
history,
reactrouter,
testRenderer,
native,
vr,
hot,
scalajsReactInterop
)
.settings(
publish := {},
publishLocal := {}
)

addCommandAlias(
"publishSignedAll",
(slinky: ProjectDefinition[ProjectReference])
.aggregate
(slinky: ProjectDefinition[ProjectReference]).aggregate
.map(p => s"+ ${p.asInstanceOf[LocalProject].project}/publishSigned")
.mkString(";")
)
Expand Down Expand Up @@ -86,83 +91,120 @@ lazy val macroAnnotationSettings = Seq(
},
libraryDependencies ++= {
if (scalaVersion.value == scala213) Seq.empty
else Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full))
else Seq(compilerPlugin(("org.scalamacros" % "paradise" % "2.1.0").cross(CrossVersion.full)))
}
)

lazy val generator = project

lazy val readWrite = project.settings(librarySettings, crossScalaSettings)

lazy val core = project.settings(
Compile / resourceGenerators += Def.task {
val rootFolder = (Compile / resourceManaged).value / "META-INF"
rootFolder.mkdirs()

IO.write(
rootFolder / "intellij-compat.json",
s"""{
| "artifact": "me.shadaj % slinky-core-ijext_2.12 % ${version.value}"
|}""".stripMargin
)

Seq(rootFolder / "intellij-compat.json")
},
macroAnnotationSettings, librarySettings, crossScalaSettings
).dependsOn(readWrite)

lazy val web = project.settings(
Compile / sourceGenerators += Def.taskDyn[Seq[File]] {
val rootFolder = (Compile / sourceManaged).value / "slinky/web"
rootFolder.mkdirs()

val html = (generator / Compile / runMain).toTask(Seq("slinky.generator.Generator", "web/html.json", (rootFolder / "html").getAbsolutePath, "slinky.web.html").mkString(" ", " ", "")).map { _ =>
(rootFolder / "html" ** "*.scala").get
}

val svg = (generator / Compile / runMain).toTask(Seq("slinky.generator.Generator", "web/svg.json", (rootFolder / "svg").getAbsolutePath, "slinky.web.svg").mkString(" ", " ", "")).map { _ =>
(rootFolder / "svg" ** "*.scala").get
}

html.zip(svg).flatMap(t => t._1.flatMap(h => t._2.map(s => h ++ s)))
}.taskValue,
Compile / packageSrc / mappings ++= {
val base = (Compile / sourceManaged).value
val files = (Compile / managedSources).value
files.map { f => (f, f.relativeTo(base).get.getPath) }
},
librarySettings,
crossScalaSettings,
).dependsOn(core)
lazy val core = project
.settings(
Compile / resourceGenerators += Def.task {
val rootFolder = (Compile / resourceManaged).value / "META-INF"
rootFolder.mkdirs()

IO.write(
rootFolder / "intellij-compat.json",
s"""{
| "artifact": "me.shadaj % slinky-core-ijext_2.12 % ${version.value}"
|}""".stripMargin
)

Seq(rootFolder / "intellij-compat.json")
},
macroAnnotationSettings,
librarySettings,
crossScalaSettings
)
.dependsOn(readWrite)

lazy val web = project
.settings(
Compile / sourceGenerators += Def
.taskDyn[Seq[File]] {
val rootFolder = (Compile / sourceManaged).value / "slinky/web"
rootFolder.mkdirs()

val html = (generator / Compile / runMain)
.toTask(
Seq("slinky.generator.Generator", "web/html.json", (rootFolder / "html").getAbsolutePath, "slinky.web.html")
.mkString(" ", " ", "")
)
.map { _ =>
(rootFolder / "html" ** "*.scala").get
}

val svg = (generator / Compile / runMain)
.toTask(
Seq("slinky.generator.Generator", "web/svg.json", (rootFolder / "svg").getAbsolutePath, "slinky.web.svg")
.mkString(" ", " ", "")
)
.map { _ =>
(rootFolder / "svg" ** "*.scala").get
}

html.zip(svg).flatMap(t => t._1.flatMap(h => t._2.map(s => h ++ s)))
}
.taskValue,
Compile / packageSrc / mappings ++= {
val base = (Compile / sourceManaged).value
val files = (Compile / managedSources).value
files.map { f =>
(f, f.relativeTo(base).get.getPath)
}
},
librarySettings,
crossScalaSettings
)
.dependsOn(core)

lazy val history = project.settings(librarySettings, crossScalaSettings)

lazy val reactrouter = project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, web, history)
lazy val reactrouter =
project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, web, history)

lazy val testRenderer = project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core)

lazy val native = project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, testRenderer % Test)
lazy val native =
project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, testRenderer % Test)

lazy val vr = project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, testRenderer % Test)
lazy val vr =
project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core, testRenderer % Test)

lazy val hot = project.settings(macroAnnotationSettings, librarySettings, crossScalaSettings).dependsOn(core)

lazy val scalajsReactInterop = project.settings(macroAnnotationSettings, librarySettings).dependsOn(core, web % Test)
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.31")

lazy val tests = project.settings(librarySettings, macroAnnotationSettings, crossScalaSettings).dependsOn(core, web, hot)
lazy val scalajsReactInterop = project
.settings(
macroAnnotationSettings,
librarySettings,
publish / skip := scalaJSVersion != "0.6.31"
)
.dependsOn(core, web % Test)

lazy val tests =
project.settings(librarySettings, macroAnnotationSettings, crossScalaSettings).dependsOn(core, web, hot)

lazy val docsMacros = project.settings(macroAnnotationSettings).dependsOn(web, hot)

lazy val docs = project.settings(librarySettings, macroAnnotationSettings).dependsOn(web, hot, docsMacros, reactrouter, history)
lazy val docs =
project.settings(librarySettings, macroAnnotationSettings).dependsOn(web, hot, docsMacros, reactrouter, history)

ThisBuild / updateIntellij := {}

lazy val coreIntellijSupport = project.enablePlugins(SbtIdeaPlugin).settings(
org.jetbrains.sbtidea.Keys.buildSettings
).settings(
intellijBuild := "192.6817.14",
intellijInternalPlugins += "java",
intellijExternalPlugins += "org.intellij.scala".toPlugin,
packageMethod := PackagingMethod.Standalone(),
intellijMainJars ++= maybeToolsJar
)
lazy val coreIntellijSupport = project
.enablePlugins(SbtIdeaPlugin)
.settings(
org.jetbrains.sbtidea.Keys.buildSettings
)
.settings(
intellijBuild := "192.6817.14",
intellijInternalPlugins += "java",
intellijExternalPlugins += "org.intellij.scala".toPlugin,
packageMethod := PackagingMethod.Standalone(),
intellijMainJars ++= maybeToolsJar
)
11 changes: 8 additions & 3 deletions core/build.sbt
Expand Up @@ -4,6 +4,11 @@ name := "slinky-core"

libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value

scalacOptions += "-P:scalajs:sjsDefinedByDefault"

scalacOptions -= "-Xfatal-warnings" // Needed by useCallback due to false positive warning on implicit evidence
scalacOptions ++= {
if (scalaJSVersion.startsWith("0.6.")) Seq("-P:scalajs:sjsDefinedByDefault")
else Nil
}

// Needed by useCallback due to false positive warning on implicit evidence
scalacOptions -= "-Ywarn-unused:implicits"
scalacOptions -= "-Wunused:implicits"