-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
14 changed files
with
4,918 additions
and
32 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
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,29 +1,50 @@ | ||
<!DOCTYPE html><html lang="en"> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
<title>My Trame Client</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Welcome to My Trame Client</h1> | ||
<button class="add">Add</button> | ||
<button class="subtract">Subtract</button> | ||
<div class="count">from HTML</div> | ||
<div> | ||
<h1>Hello Trame !</h1> | ||
<div class="card"> | ||
<button id="counter" type="button"></button> | ||
<button id="play" type="button">Auto update</button> | ||
<button id="subtract" type="button">-1</button> | ||
<button id="random" type="button">Random</button> | ||
</div> | ||
</div> | ||
</main> | ||
<script crossorigin="anonymous" src="https://www.unpkg.com/@kitware/trame/dist/trame.umd.js"></script> | ||
<script | ||
crossorigin="anonymous" | ||
src="https://www.unpkg.com/@kitware/trame/dist/trame.umd.js" | ||
></script> | ||
<script> | ||
const trame = new Trame(); | ||
trame.connect().then((config) => { | ||
console.log(config); | ||
|
||
trame.state.watch(["count"], (count) => { | ||
document.querySelector(".count").innerHTML = count; | ||
}); | ||
document.querySelector(".add").addEventListener("click", () => trame.trigger("add")); | ||
document.querySelector(".subtract").addEventListener("click", () => trame.trigger("subtract")); | ||
const trame = new Trame(); | ||
trame.connect().then((config) => { | ||
trame.refs["counter"] = { | ||
reset(value) { | ||
trame.state.set("count", value); | ||
}, | ||
}; | ||
const element = document.querySelector("#counter"); | ||
trame.state.watch(["count"], (count) => { | ||
element.innerHTML = `count is ${count}`; | ||
}); | ||
element.addEventListener("click", () => trame.trigger("add")); | ||
document | ||
.querySelector("#play") | ||
.addEventListener("click", () => trame.trigger("toggle_play")); | ||
document | ||
.querySelector("#subtract") | ||
.addEventListener("click", () => trame.trigger("subtract")); | ||
document | ||
.querySelector("#random") | ||
.addEventListener("click", () => trame.trigger("random")); | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
</html> |
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,25 @@ | ||
# Vite project | ||
|
||
This example use npm package to illustrate how to use the trame client. | ||
|
||
## Trame setup | ||
|
||
```bash | ||
python3 -m venv .venv | ||
source .venv/bin/activate | ||
pip install trame | ||
``` | ||
|
||
## Build the client | ||
|
||
```bash | ||
cd client | ||
npm i | ||
npm run build | ||
``` | ||
|
||
## Running example | ||
|
||
```bash | ||
python ./server.py --content ./client/dist | ||
``` |
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,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,6 @@ | ||
export function setupCounter(element, trame) { | ||
trame.state.watch(["count"], (count) => { | ||
element.innerHTML = `count is ${count}`; | ||
}); | ||
element.addEventListener("click", () => trame.trigger("add")); | ||
} |
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,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> |
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,35 @@ | ||
import "./style.css"; | ||
// import Trame from "@kitware/trame"; | ||
import Trame from "../../../dist/trame.mjs"; | ||
import { setupCounter } from "./counter.js"; | ||
|
||
document.querySelector("#app").innerHTML = ` | ||
<div> | ||
<h1>Hello Trame !</h1> | ||
<div class="card"> | ||
<button id="counter" type="button"></button> | ||
<button id="play" type="button">Auto update</button> | ||
<button id="subtract" type="button">-1</button> | ||
<button id="random" type="button">Random</button> | ||
</div> | ||
</div> | ||
`; | ||
|
||
const trame = new Trame(); | ||
trame.connect().then(() => { | ||
setupCounter(document.querySelector("#counter"), trame); | ||
trame.refs["counter"] = { | ||
reset(value) { | ||
trame.state.set("count", value); | ||
}, | ||
}; | ||
document | ||
.querySelector("#play") | ||
.addEventListener("click", () => trame.trigger("toggle_play")); | ||
document | ||
.querySelector("#subtract") | ||
.addEventListener("click", () => trame.trigger("subtract")); | ||
document | ||
.querySelector("#random") | ||
.addEventListener("click", () => trame.trigger("random")); | ||
}); |
Oops, something went wrong.