mini-player, header: make it persistent, add music page button and check current route
This commit is contained in:
parent
4b4044d689
commit
2ed650c3f4
11 changed files with 78 additions and 52 deletions
|
|
@ -12,20 +12,19 @@
|
|||
<script src="/static/vendor/htmx.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body hx-boost="true" hx-target="#content">
|
||||
<crt>
|
||||
|
||||
<body hx-boost="true" hx-target="#content" {% block bodyattrs %}{% endblock %}>
|
||||
<persistent-ui>
|
||||
{% include "partials/header.html" %}
|
||||
<miniplayer-container id="miniplayer-container" hx-get="/miniplayer" hx-trigger="load" hx-swap="innerHTML"
|
||||
hx-target="#miniplayer-container">
|
||||
<miniplayer>
|
||||
<p>Chargement...</p>
|
||||
</miniplayer>
|
||||
<miniplayer-container id="miniplayer-container">
|
||||
{% block miniplayer %}{% endblock %}
|
||||
</miniplayer-container>
|
||||
</persistent-ui>
|
||||
|
||||
<main id="content">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
<main id="content">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</crt>
|
||||
|
||||
<script src="/static/miniplayer.js"></script>
|
||||
<script>
|
||||
|
|
@ -37,11 +36,28 @@
|
|||
}
|
||||
}
|
||||
|
||||
updateMiniplayerVisibility();
|
||||
function updateNavState() {
|
||||
const path = window.location.pathname;
|
||||
document.querySelectorAll('navbar input[type="radio"]').forEach(radio => {
|
||||
radio.checked = false;
|
||||
});
|
||||
if (path === '/') {
|
||||
const homeRadio = document.getElementById('nav-home');
|
||||
if (homeRadio) homeRadio.checked = true;
|
||||
} else if (path === '/music') {
|
||||
const musicRadio = document.getElementById('nav-music');
|
||||
if (musicRadio) musicRadio.checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', updateMiniplayerVisibility);
|
||||
updateMiniplayerVisibility();
|
||||
updateNavState();
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', () => {
|
||||
updateMiniplayerVisibility();
|
||||
updateNavState();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</crt>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
{% include "partials/home.html" %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block miniplayer %}
|
||||
{% include "partials/miniplayer.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -3,3 +3,7 @@
|
|||
{% block content %}
|
||||
{% include "partials/music.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block miniplayer %}
|
||||
{% include "partials/miniplayer.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,9 @@
|
|||
<input type="radio" name="nav" id="nav-home" checked>
|
||||
<a href="/">Accueil</a>
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="nav" id="nav-music">
|
||||
<a href="/music">Music</a>
|
||||
</label>
|
||||
</navbar-content>
|
||||
</navbar>
|
||||
Loading…
Add table
Add a link
Reference in a new issue