63 lines
5.3 KiB
HTML
63 lines
5.3 KiB
HTML
<div x-data>
|
|
<template x-if="$store.lyrics.visible">
|
|
<div class="lyrics-overlay" :class="{'lyrics-fullscreen':$store.lyrics.follow}" @click.self="$store.lyrics.close()">
|
|
<section class="lyrics-dialog" role="dialog" aria-modal="true" aria-labelledby="lyrics-title" tabindex="-1"
|
|
x-init="$nextTick(()=>$el.focus())" @keydown.escape.window.stop.prevent="$store.lyrics.close()" @keydown="$store.lyrics.trap($event,$el)"
|
|
x-effect="$store.lyrics.tick($store.player.currentTrack,$store.player.currentTime)">
|
|
<header class="lyrics-header">
|
|
<div class="lyrics-heading"><small x-text="$store.lyrics.follow?$store.lyrics.text('following'):$store.lyrics.text('preview')"></small>
|
|
<h2 id="lyrics-title" x-text="$store.lyrics.track?.title || $store.lyrics.text('lyrics')"></h2>
|
|
<p x-text="($store.lyrics.track?.artists || []).map(a=>a.name || a.label).join(', ')"></p>
|
|
<div class="lyrics-status" role="status" aria-live="polite" x-show="$store.lyrics.status()">
|
|
<span x-text="$store.lyrics.text($store.lyrics.status())"></span>
|
|
<button type="button" x-show="$store.lyrics.error" @click="$store.lyrics.load($store.lyrics.track)" x-text="$store.lyrics.text('retry')"></button>
|
|
</div>
|
|
</div>
|
|
<div class="lyrics-header-actions" @keydown.space.stop>
|
|
<button type="button" class="lyrics-copy" x-show="!$store.lyrics.follow && $store.lyrics.canCopy()"
|
|
@click="$store.lyrics.copy($el)" :data-result="$store.lyrics.copyResult"
|
|
:title="$store.lyrics.text($store.lyrics.copyResult || 'copy')" :aria-label="$store.lyrics.text('copy')">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
<g x-show="!$store.lyrics.copyResult"><rect x="8" y="8" width="12" height="13" rx="2"/><path d="M15 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3"/></g>
|
|
<path x-show="$store.lyrics.copyResult==='copied'" d="m4 12 5 5L20 6"/>
|
|
<path x-show="$store.lyrics.copyResult==='copyFailed'" d="M12 4v10m0 4v1"/>
|
|
</svg>
|
|
</button>
|
|
<span class="lyrics-copy-result" role="status" aria-live="polite" x-text="$store.lyrics.copyResult && $store.lyrics.text($store.lyrics.copyResult)"></span>
|
|
<button class="lyrics-close" type="button" @click="$store.lyrics.close()" :aria-label="$store.lyrics.text('close')">✕</button>
|
|
</div>
|
|
</header>
|
|
<div class="lyrics-scroll" x-show="$store.lyrics.follow || $store.lyrics.canCopy()"
|
|
@wheel.passive="$store.lyrics.holdUntil=Date.now()+5000" @touchstart.passive="$store.lyrics.holdUntil=Date.now()+5000">
|
|
<div class="lyrics-lines" x-show="$store.lyrics.lines.length>0">
|
|
<template x-for="(line,index) in $store.lyrics.lines" :key="index">
|
|
<button class="lyrics-line" :data-lyrics-line="index" :class="{active:index===$store.lyrics.active,past:index<$store.lyrics.active}"
|
|
:disabled="!$store.lyrics.sameTrack($store.player.currentTrack)" @click="$store.lyrics.seek(line)" x-text="line.text || '♪'"></button>
|
|
</template>
|
|
</div>
|
|
<pre class="lyrics-plain" x-show="!$store.lyrics.lines.length && !$store.lyrics.currentVersion()?.instrumental" x-text="$store.lyrics.plain()"></pre>
|
|
</div>
|
|
<footer class="lyrics-footer" x-show="$store.lyrics.follow || $store.lyrics.versions.length">
|
|
<div class="lyrics-versions" role="group" :aria-label="$store.lyrics.text('version')"
|
|
x-show="$store.lyrics.versions.length" @keydown.space.stop @keydown.left.stop @keydown.right.stop>
|
|
<template x-for="(version,index) in $store.lyrics.versions" :key="index">
|
|
<span class="lyrics-version-option">
|
|
<span x-show="index>0" aria-hidden="true">·</span>
|
|
<button type="button" class="lyrics-version-choice" :aria-pressed="index===$store.lyrics.selected"
|
|
:title="$store.lyrics.versionLabel(version)" x-text="$store.lyrics.versionName(version,index)"
|
|
@click="if (index!==$store.lyrics.selected) $store.lyrics.choose(index)"></button>
|
|
</span>
|
|
</template>
|
|
</div>
|
|
<div class="lyrics-transport" x-show="$store.lyrics.follow">
|
|
<button @click="$store.player.prev()" :aria-label="$store.lyrics.text('previous')">⏮</button>
|
|
<button @click="$store.player.toggle()" :aria-label="$store.lyrics.text('play')" x-text="$store.player.isPlaying?'Ⅱ':'▶'"></button>
|
|
<button @click="$store.player.next()" :aria-label="$store.lyrics.text('next')">⏭</button>
|
|
</div>
|
|
<button x-show="$store.lyrics.lines.length && $store.lyrics.active>=0" @click="$store.lyrics.scroll(true)" x-text="$store.lyrics.text('resume')"></button>
|
|
</footer>
|
|
</section>
|
|
</div>
|
|
</template>
|
|
</div>
|