Skip to content

Commit db23e62

Browse files
committed
feat: enable morph on player to retain player state
1 parent fd8e6de commit db23e62

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

pages/base.gohtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<link rel="stylesheet" href="/public/reset.css">
1010
<link rel="stylesheet" href="/public/styles.css">
1111
<script src="/public/htmx/htmx2.0.7.min.js" defer></script>
12+
<script src="/public/htmx/idiomorph-ext0.7.4.min.js" defer></script>
1213
{{block "head".}}{{end}}
1314
</head>
14-
<body>
15+
<body hx-ext="morph">
1516
{{block "nav".}}{{end}}
1617
<main>
1718
{{template "content".}}

pages/index/index.gohtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122

123123
<article>
124124
<h2>Player</h2>
125-
<div hx-get="/player" hx-swap="innerHTML" hx-trigger="load, playerReloadEvent" id="player"></div>
125+
<div hx-get="/player" hx-swap="morph:innerHTML" hx-trigger="load, playerReloadEvent" id="player"></div>
126126
</article>
127127
</div>
128128
{{end}}

pages/player/playerPartial.gohtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
{{range .Items}}
1313
<tr>
1414
<td class="min-width">
15-
{{.CreatedAt.Format "15:04:05"}} -
15+
{{.CreatedAt.Format "15:04:05"}}
1616
</td>
1717
<td class="align-start">
1818
{{.Path}}
1919
</td>
2020
<td class="align-end short">
2121
<button class="icon-button" hx-delete="/removeSong/{{.ID}}" hx-target="#player-partial"
22-
hx-swap="outerHTML">
22+
hx-swap="morph:outerHTML">
2323
<img src="/public/icons/delete.svg" width="20" height="20" alt="Delete"/>
2424
</button>
2525
</td>

public/htmx/idiomorph-ext0.7.4.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)