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

Added routing example #195

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ lazy val nonpm =
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.NoModule) }
)

lazy val routing =
(project in file("routing"))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(
name := "routing",
libraryDependencies ++= Seq(
"be.doeraene" %%% "url-dsl" % "0.4.0",
"org.scala-js" %%% "scalajs-dom" % "2.2.0"
)
)

lazy val subcomponents =
(project in file("subcomponents"))
.enablePlugins(ScalaJSPlugin)
Expand Down Expand Up @@ -220,6 +232,7 @@ lazy val exampleProjects: List[String] =
// "mainlauncher", // Keep out of main build until 0.7.0 is released
"mario",
"nonpm",
"routing",
"subcomponents",
"websocket",
"zio"
Expand Down
19 changes: 19 additions & 0 deletions examples/routing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Tyrian routing with Url-DSL

This is an example of how to do routing in Tyrian using third party library [url-dsl](https://github.com/sherpal/url-dsl). You should also add [scala-js-dom](https://github.com/scala-js/scala-js-dom) to your list of dependencies in order to get access to `dom.window.location.href` property.

To run the program in a browser you will need to have yarn (or npm) installed.

On first run:

```sh
yarn install
```

and from then on

```sh
yarn start
```

Then navigate to [http://localhost:1234/](http://localhost:1234/)
15 changes: 15 additions & 0 deletions examples/routing/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>Hello Tyrian</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>

<body>
<div id="myapp"></div>
<script type="module" src="./tyrianapp.js"></script>
</body>

</html>
Loading
Loading