-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
923d8fe
commit bc4e41e
Showing
27 changed files
with
2,539 additions
and
263 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ignore" : ["sjs.test.js"] | ||
} |
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 |
---|---|---|
|
@@ -32,3 +32,5 @@ npm-debug.log | |
|
||
|
||
#project | ||
*.test.js | ||
*.test.js.map |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const react = require('react'); | ||
// Resolution for requestAnimationFrame not supported in jest error : | ||
// https://github.com/facebook/react/issues/9102#issuecomment-283873039 | ||
global.window = global; | ||
window.addEventListener = () => {}; | ||
window.requestAnimationFrame = () => { | ||
throw new Error('requestAnimationFrame is not supported in Node'); | ||
}; | ||
|
||
module.exports = react; |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
sbt.version=0.13.13 | ||
sbt.version=0.13.15 | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.16") | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.0.0-M1") | ||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") | ||
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "1.1.1") | ||
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "1.3.0") | ||
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package sri.web.router | ||
|
||
import sri.core.{CreateElement, JSProps} | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.JSExportStatic | ||
import scala.scalajs.js.| | ||
|
||
/** | ||
* Thank you react-router and history dev :) | ||
*/ | ||
class RouteChangePrompt | ||
extends RouterAwareComponentP[RouteChangePrompt.Props] { | ||
|
||
override def componentWillMount(): Unit = { | ||
if (props.blockTransition) enable(props.message) | ||
} | ||
|
||
def render() = { | ||
null | ||
} | ||
|
||
var unblock: js.Function0[_] = null | ||
|
||
def enable(message: String | js.Function2[Location, String, _]) = { | ||
if (unblock != null) { | ||
unblock() | ||
} | ||
unblock = navigation.config.history.block(props.message) | ||
} | ||
|
||
override def componentWillReceiveProps(nextJSProps: JSProps { | ||
type ScalaProps = RouteChangePrompt.Props | ||
}): Unit = { | ||
if (nextJSProps.scalaProps.blockTransition) { | ||
if (!props.blockTransition || (props.message != nextJSProps.scalaProps.message)) { | ||
enable(nextJSProps.scalaProps.message) | ||
} | ||
|
||
} else disable() | ||
} | ||
|
||
def disable() = { | ||
if (unblock != null) { | ||
unblock() | ||
unblock = null | ||
} | ||
} | ||
|
||
override def componentWillUnmount(): Unit = { | ||
disable() | ||
} | ||
} | ||
|
||
object RouteChangePrompt { | ||
|
||
@JSExportStatic | ||
val contextTypes = navigationContext | ||
|
||
case class Props(blockTransition: Boolean, | ||
message: String | js.Function2[Location, String, _]) | ||
|
||
def apply(blockTransition: Boolean, | ||
message: String | js.Function2[Location, String, _]) = | ||
CreateElement[RouteChangePrompt](Props(blockTransition, message)) | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package sri.web.router | ||
|
||
case class RouteNotFound(page: String, | ||
case class RouteNotFound(page: RouterScreenKey, | ||
action: NavigationAction = NavigationAction.REPLACE) |
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.