rosary: progressive enhancement for no-JS browsers
All checks were successful
CI / update (push) Successful in 1m33s
All checks were successful
CI / update (push) Successful in 1m33s
SVG beads are now anchor links to prayer sections, with CSS :has(:target) highlighting the active bead. Inline mystery images render in each decade by default and hide when JS takes over. StreakCounter uses a form action fallback for logged-in users and hides entirely for anonymous no-JS users. Show images toggle now works via ?images= URL param like the other toggles.
This commit is contained in:
@@ -10,9 +10,10 @@ let streak = $state<ReturnType<typeof getRosaryStreak> | null>(null);
|
||||
interface Props {
|
||||
streakData?: { length: number; lastPrayed: string | null } | null;
|
||||
lang?: 'de' | 'en';
|
||||
isLoggedIn?: boolean;
|
||||
}
|
||||
|
||||
let { streakData = null, lang = 'de' }: Props = $props();
|
||||
let { streakData = null, lang = 'de', isLoggedIn = false }: Props = $props();
|
||||
|
||||
const isEnglish = $derived(lang === 'en');
|
||||
|
||||
@@ -42,23 +43,25 @@ async function pray() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="streak-container">
|
||||
<div class="streak-container" class:no-js-hidden={!isLoggedIn}>
|
||||
<div class="streak-display">
|
||||
<StreakAura value={displayLength} {burst} />
|
||||
<span class="streak-label">{labels.days}</span>
|
||||
</div>
|
||||
<button
|
||||
class="streak-button"
|
||||
onclick={pray}
|
||||
disabled={prayedToday}
|
||||
aria-label={labels.ariaLabel}
|
||||
>
|
||||
{#if prayedToday}
|
||||
{labels.prayedToday}
|
||||
{:else}
|
||||
{labels.prayed}
|
||||
{/if}
|
||||
</button>
|
||||
<form method="POST" action="?/pray" onsubmit={(e) => { e.preventDefault(); pray(); }}>
|
||||
<button
|
||||
class="streak-button"
|
||||
type="submit"
|
||||
disabled={prayedToday}
|
||||
aria-label={labels.ariaLabel}
|
||||
>
|
||||
{#if prayedToday}
|
||||
{labels.prayedToday}
|
||||
{:else}
|
||||
{labels.prayed}
|
||||
{/if}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -119,6 +122,15 @@ async function pray() {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* Hide for non-logged-in users without JS (no form action available) */
|
||||
.no-js-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:global(html.js-enabled) .no-js-hidden {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
.streak-button:disabled {
|
||||
background: var(--nord4);
|
||||
|
||||
Reference in New Issue
Block a user