-
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
shahrul
committed
Oct 11, 2024
1 parent
55b6e49
commit e8193f5
Showing
6 changed files
with
95 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
local module = {} | ||
local toggleMain = "toggleMain" | ||
local todoList = "todoList" | ||
local todoFooter = "todoFooter" | ||
|
||
function module.Page(todos) | ||
return <html lang="en" data-framework="htmx"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<title>HTMX • TodoMVC</title> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/base.css" type="text/css" /> | ||
<link rel="stylesheet" href="https://unpkg.com/todomvc-app-css/index.css" type="text/css" /> | ||
<script type="text/hyperscript" src="/hs/start-me-up._hs"></script> | ||
<script type="text/hyperscript" src="/hs/main._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/toggle-main._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/toggle-footer._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/toggle-show._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/add-todo._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/footer._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/toggle-all._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/clear-completed._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/destroy._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/todo-count._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/todo-dblclick._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/todo-check._hs"></script> | ||
<script type="text/hyperscript" src="/hs/behaviors/todo-edit._hs"></script> | ||
</head> | ||
<body> | ||
<section class="todoapp" | ||
_="install ToggleMain end install ToggleFooter end install ToggleShow end" | ||
> | ||
<header class="header"> | ||
<h1>todos</h1> | ||
<input | ||
id="add-todo" | ||
name="title" | ||
class="new-todo" | ||
placeholder="What needs to be done?" | ||
_="install AddTodo" | ||
/> | ||
</header> | ||
{toggleMain} | ||
{todoList} | ||
{todoFooter} | ||
</section> | ||
<footer class="info" | ||
_="on load debounced at 10ms call startMeUp() hashCache()" | ||
> | ||
<p>Double-click to edit a todo</p> | ||
<p>Created by <a href="http://github.com/syarul/">syarul</a></p> | ||
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p> | ||
<img src="https://htmx.org/img/createdwith.jpeg" width="250" height="auto" /> | ||
</footer> | ||
</body> | ||
<script src="https://unpkg.com/[email protected]/base.js"></script> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
<script src="https://unpkg.com/hyperscript.org/dist/_hyperscript.js"></script> | ||
</html> | ||
end | ||
|
||
return module |
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,7 @@ | ||
return <html lang="en" data-framework="htmx"> | ||
<head> | ||
<title>HTMX • TodoMVC</title> | ||
</head> | ||
<body> | ||
</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 @@ | ||
return <p>Created by <a href="http://github.com/syarul/">syarul</a></p> |
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 |
---|---|---|
|
@@ -99,13 +99,18 @@ describe("LuaX", function() | |
it("should return a HTML string with deep node tree", function() | ||
local el = require("test.12_test") | ||
assert.is.equal( | ||
'<li _="on destroy my.querySelector(\'button\').click()" class="test" id="1"><div class="view">todo A<label _="install TodoDblclick" hx-patch="/edit-todo?id=1&foo=test" hx-swap="outerHTML" hx-target="next input" hx-trigger="dblclick">todo A Label</label><button _="install Destroy" class="destroy" hx-delete="/remove-todo?id=1" hx-swap="outerHTML" hx-target="closest <li/>" hx-trigger="click"></button></div>todo A Value</li>', | ||
[[<li _="on destroy my.querySelector('button').click()" class="test" id="1"><div class="view">todo A<label _="install TodoDblclick" hx-patch="/edit-todo?id=1&foo=test" hx-swap="outerHTML" hx-target="next input" hx-trigger="dblclick">todo A Label </label><button _="install Destroy" class="destroy" hx-delete="/remove-todo?id=1" hx-swap="outerHTML" hx-target="closest <li/>" hx-trigger="click"></button></div>todo A Value</li>]], | ||
h(el)) | ||
end) | ||
|
||
it("should return a HTML string when given JSX like syntax with nested node", function() | ||
local el = require("test.13_varin") | ||
assert.is.equal('<div class="container" id="div_1"><p class="title" id="p_2" style="border: 1px solid red;">Hello, world!</p></div>', h(el)) | ||
end) | ||
|
||
it("should return a HTML string when given JSX like syntax with nested node", function() | ||
local el = require("test.14_page") | ||
assert.is.equal([[<html data-framework="htmx" lang="en"><head><meta charSet="utf-8"><title>HTMX • TodoMVC</title><link href="https://unpkg.com/[email protected]/base.css" rel="stylesheet" type="text/css"><link href="https://unpkg.com/todomvc-app-css/index.css" rel="stylesheet" type="text/css"><script src="/hs/start-me-up._hs" type="text/hyperscript"></script><script src="/hs/main._hs" type="text/hyperscript"></script><script src="/hs/behaviors/toggle-main._hs" type="text/hyperscript"></script><script src="/hs/behaviors/toggle-footer._hs" type="text/hyperscript"></script><script src="/hs/behaviors/toggle-show._hs" type="text/hyperscript"></script><script src="/hs/behaviors/add-todo._hs" type="text/hyperscript"></script><script src="/hs/behaviors/footer._hs" type="text/hyperscript"></script><script src="/hs/behaviors/toggle-all._hs" type="text/hyperscript"></script><script src="/hs/behaviors/clear-completed._hs" type="text/hyperscript"></script><script src="/hs/behaviors/destroy._hs" type="text/hyperscript"></script><script src="/hs/behaviors/todo-count._hs" type="text/hyperscript"></script><script src="/hs/behaviors/todo-dblclick._hs" type="text/hyperscript"></script><script src="/hs/behaviors/todo-check._hs" type="text/hyperscript"></script><script src="/hs/behaviors/todo-edit._hs" type="text/hyperscript"></script> </head><body><section _="install ToggleMain end install ToggleFooter end install ToggleShow end" class="todoapp"><header class="header"><h1>todos</h1><input _="install AddTodo" class="new-todo" id="add-todo" name="title" placeholder="What needs to be done?"></header>toggleMaintodoListtodoFooter</section><footer _="on load debounced at 10ms call startMeUp() hashCache()" class="info"><p>Double-click to edit a todo</p><p>Created by <a href="http://github.com/syarul/">syarul</a></p><p>Part of <a href="http://todomvc.com">TodoMVC</a></p><img height="auto" src="https://htmx.org/img/createdwith.jpeg" width="250"></footer></body><script src="https://unpkg.com/[email protected]/base.js"></script><script src="https://unpkg.com/[email protected]"></script><script src="https://unpkg.com/hyperscript.org/dist/_hyperscript.js"></script> </html>]], h(el.Page("todos"))) | ||
end) | ||
|
||
end) |