🌐 pmme-ui: Shadow-cljs configured for hot reloading, moved static files to ui side

This commit is contained in:
Joseph Ferano 2025-06-16 19:17:51 +07:00
parent 6892060d16
commit 2c741adac7
10 changed files with 45 additions and 70 deletions

View File

@ -23,3 +23,4 @@ dist-ssr
*.sln
*.sw?
*.jks
src/

View File

@ -4,7 +4,7 @@
"version": "0.1.0",
"identifier": "com.pmme.app",
"build": {
"frontendDist": "../src"
"devUrl": "http://localhost:3000"
},
"app": {
"withGlobalTauri": true,

View File

@ -1,39 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri App</title>
<script type="module" src="./js/main.js" defer></script>
</head>
<body>
<main class="container">
<h1>Welcome to Tauri</h1>
<div class="row">
<a href="https://tauri.app" target="_blank">
<img src="/assets/tauri.svg" class="logo tauri" alt="Tauri logo" />
</a>
<a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript"
target="_blank"
>
<img
src="/assets/javascript.svg"
class="logo vanilla"
alt="JavaScript logo"
/>
</a>
</div>
<p>Click on the Tauri logo to learn more about the framework</p>
<form class="row" id="greet-form">
<input id="greet-input" placeholder="Enter a name..." />
<button type="submit">Greet</button>
</form>
<p id="greet-msg"></p>
</main>
</body>
</html>

View File

@ -1,18 +0,0 @@
const { invoke } = window.__TAURI__.core;
let greetInputEl;
let greetMsgEl;
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
}
window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document.querySelector("#greet-form").addEventListener("submit", (e) => {
e.preventDefault();
greet();
});
});

View File

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 995 B

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,12 +1,32 @@
<!DOCTYPE html>
<html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PMME UI</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri App</title>
</head>
<body>
<div id="app"></div>
<script src="/js/main.js"></script>
<main class="container">
<h1>Welcome to Tauri</h1>
<div class="row">
<a href="https://tauri.app" target="_blank">
<img src="/assets/tauri.svg" class="logo tauri" alt="Tauri logo" />
</a>
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript" target="_blank">
<img src="/assets/javascript.svg" class="logo vanilla" alt="JavaScript logo" />
</a>
</div>
<p>Click on the Tauri logo to learn more about the framework.</p>
<form class="row" id="greet-form">
<input id="greet-input" placeholder="Enter a name..." />
<button type="submit">Greet</button>
</form>
<p id="greet-msg"></p>
</main>
<script src="./js/main.js"></script>
</body>
</html>
</html>

View File

@ -6,14 +6,21 @@
:dependencies
[]
:dev-http {3000 "public"}
:builds
{:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:main {:init-fn pmme-ui.core/init}}}
:modules {:main {:init-fn pmme-ui.core/init}}
:devtools {:devtools-url "http://192.168.110.133:9630"}}
:release {:target :browser
:output-dir "../pmme-mobile/src/js"
:asset-path "/js"
:modules {:main {:init-fn pmme-ui.core/init}}
:compiler-options {:optimizations :advanced}}}}
:compiler-options {:optimizations :advanced}
:build-hooks [(shadow.resource/copy-resources
{:from "public"
:to "../pmme-mobile/src"
:exclude ["**/*.js"]})]}}}

View File

@ -10,13 +10,17 @@
(set! (.-innerHTML msg-element) "Please enter a name!")
(do
;; You could call a Tauri command here instead
(js/console.log "Testing the chrome thingie")
(set! (.-innerHTML msg-element)
(str "Hello, " name "! 👋 (from ClojureScript)"))
(str "Hello, " name "! 👋 (from ClojureScript)!"))
(set! (.-value input) "")))))
(defn greet-handler [event]
(handle-greet event))
(defn setup-greet-form []
(when-let [form (.getElementById js/document "greet-form")]
(.addEventListener form "submit" handle-greet)))
(.addEventListener form "submit" greet-handler)))
(defn add-dynamic-styling []
(let [style (.createElement js/document "style")]