Last active
December 3, 2024 21:55
-
-
Save chr15m/b724c4e47390eea0689f87f9ed423c8e to your computer and use it in GitHub Desktop.
Scittle ClojureScript with Preact instead of 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
<!DOCTYPE html> | |
<html lang="en-us"> | |
<head> | |
<title>Scittle Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="mobile-web-app-capable" content="yes"> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/concrete.min.css"> | |
<script src="https://cdn.jsdelivr.net/npm/scittle@latest/dist/scittle.min.js" type="application/javascript"></script> | |
<script src="https://cdn.jsdelivr.net/npm/scittle@latest/dist/scittle.promesa.min.js" type="application/javascript"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.min.js"></script> | |
<script> | |
window.React = preact; | |
window.ReactDOM = preact; | |
</script> | |
<script src="https://cdn.jsdelivr.net/npm/scittle@latest/dist/scittle.reagent.min.js" type="application/javascript"></script> | |
<style> | |
body { | |
margin: 0; | |
min-height: 100vh; | |
display: flex; | |
flex-direction: column; | |
align-items: center; | |
justify-content: center; | |
} | |
main { | |
text-align: center; | |
} | |
</style> | |
<script type="application/x-scittle"> | |
(ns main | |
(:require | |
[reagent.core :as r] | |
[reagent.dom :as rdom])) | |
(defonce state (r/atom nil)) | |
(defn app [] | |
[:main | |
[:h1 "Hello"] | |
[:pre "State: " (pr-str @state)] | |
[:button | |
{:on-click #(swap! state update :counter inc)} | |
"Increment"]]) | |
(rdom/render [app] (.getElementById js/document "app")) | |
</script> | |
</head> | |
<body> | |
<div id="app"><div class="loader"></div></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment