forked from Furumi/furumi-web
fix: stabilize mobile player and track action layout
This commit is contained in:
1 parent
a296af3b37
commit
ea3a95da42
4 files changed
+110
-14
No files matched your search
@@ -1188,7 +1188,8 @@
|
||||
</div>
|
||||
<div class="history-date" x-text="$store.history.date(item.played_at)"></div>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="item.track.has_lyrics" @click.stop="$store.lyrics.open(item.track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="item.track.has_lyrics" @click.stop="$store.lyrics.open(item.track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(item.track), 'no-popularity': !$store.library.hasPopularity(item.track) }"
|
||||
:style="$store.library.popularityStyle(item.track)"
|
||||
@@ -1198,6 +1199,7 @@
|
||||
<span x-show="$store.library.hasPopularity(item.track)" x-text="$store.library.popularityLabel(item.track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(item.track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button class="like-btn" :class="{ liked: $store.likes.has(item.track_id) }" @click.stop="$store.likes.toggle(item.track_id)" title="{{ t.player_like }}">
|
||||
<svg viewBox="0 0 24 24" :fill="$store.likes.has(item.track_id) ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
|
||||
</button>
|
||||
|
||||
@@ -521,7 +521,8 @@
|
||||
</div>
|
||||
<span></span>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(track), 'no-popularity': !$store.library.hasPopularity(track) }"
|
||||
:style="$store.library.popularityStyle(track)"
|
||||
@@ -531,6 +532,7 @@
|
||||
<span x-show="$store.library.hasPopularity(track)" x-text="$store.library.popularityLabel(track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button data-member-only class="like-btn" :class="{ liked: $store.likes.has(track.id) }" @click.stop="$store.likes.toggle(track.id)" title="{{ t.player_like }}">
|
||||
<svg viewBox="0 0 24 24" :fill="$store.likes.has(track.id) ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
|
||||
</button>
|
||||
@@ -895,7 +897,8 @@
|
||||
</div>
|
||||
<span></span>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(track), 'no-popularity': !$store.library.hasPopularity(track) }"
|
||||
:style="$store.library.popularityStyle(track)"
|
||||
@@ -905,6 +908,7 @@
|
||||
<span x-show="$store.library.hasPopularity(track)" x-text="$store.library.popularityLabel(track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button data-member-only class="like-btn" :class="{ liked: $store.likes.has(track.id) }" @click.stop="$store.likes.toggle(track.id)" title="{{ t.player_like }}">
|
||||
<svg viewBox="0 0 24 24" :fill="$store.likes.has(track.id) ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
|
||||
</button>
|
||||
@@ -1125,7 +1129,8 @@
|
||||
</div>
|
||||
<span></span>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(track), 'no-popularity': !$store.library.hasPopularity(track) }"
|
||||
:style="$store.library.popularityStyle(track)"
|
||||
@@ -1135,6 +1140,7 @@
|
||||
<span x-show="$store.library.hasPopularity(track)" x-text="$store.library.popularityLabel(track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button data-member-only class="like-btn" :class="{ liked: $store.likes.has(track.id) }" @click.stop="$store.likes.toggle(track.id)" title="{{ t.player_like }}">
|
||||
<svg viewBox="0 0 24 24" :fill="$store.likes.has(track.id) ? 'currentColor' : 'none'" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
|
||||
</button>
|
||||
@@ -1306,7 +1312,8 @@
|
||||
</div>
|
||||
<span></span>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(track), 'no-popularity': !$store.library.hasPopularity(track) }"
|
||||
:style="$store.library.popularityStyle(track)"
|
||||
@@ -1316,6 +1323,7 @@
|
||||
<span x-show="$store.library.hasPopularity(track)" x-text="$store.library.popularityLabel(track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button data-member-only class="like-btn"
|
||||
:class="{ liked: track.federation_pending ? $store.library.federationIsLiked(track._federationTrack) : $store.likes.has(track.id) }"
|
||||
@click.stop="track.federation_pending ? $store.library.toggleFederationLike(track._federationTrack) : $store.likes.toggle(track.id)"
|
||||
@@ -1474,7 +1482,8 @@
|
||||
</div>
|
||||
<span></span>
|
||||
<div class="track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="track.has_lyrics" @click.stop="$store.lyrics.open(track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="track-action-btn info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(track), 'no-popularity': !$store.library.hasPopularity(track) }"
|
||||
:style="$store.library.popularityStyle(track)"
|
||||
@@ -1484,6 +1493,7 @@
|
||||
<span x-show="$store.library.hasPopularity(track)" x-text="$store.library.popularityLabel(track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button data-member-only class="like-btn"
|
||||
:class="{ liked: track.federation_pending ? $store.library.federationIsLiked(track._federationTrack) : $store.likes.has(track.id) }"
|
||||
@click.stop="track.federation_pending ? $store.library.toggleFederationLike(track._federationTrack) : $store.likes.toggle(track.id)"
|
||||
@@ -1604,7 +1614,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="queue-track-actions">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="item.track.has_lyrics" @click.stop="$store.lyrics.open(item.track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<span class="track-popularity-slot">
|
||||
<button class="track-action-btn lyrics-presence" type="button" x-show="item.track.has_lyrics" @click.stop="$store.lyrics.open(item.track,false)" :title="$store.lyrics.text('lyrics')" :aria-label="$store.lyrics.text('lyrics')"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><rect x="4" y="3" width="16" height="18" rx="3"/><path d="M8 8h8M8 12h6M8 16h4"/></svg></button>
|
||||
<button class="queue-track-remove info-btn popularity-info-btn"
|
||||
:class="{ 'has-popularity': $store.library.hasPopularity(item.track), 'no-popularity': !$store.library.hasPopularity(item.track) }"
|
||||
:style="$store.library.popularityStyle(item.track)"
|
||||
@@ -1614,6 +1625,7 @@
|
||||
<span x-show="$store.library.hasPopularity(item.track)" x-text="$store.library.popularityLabel(item.track)"></span>
|
||||
<span x-show="!$store.library.hasPopularity(item.track)" class="info-letter">i</span>
|
||||
</button>
|
||||
</span>
|
||||
<button class="queue-track-remove" x-show="!item.synthetic" @click.stop="$store.queue.remove(item.index)" title="{{ t.player_remove }}">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
|
||||
</button>
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
.lyrics-toggle-mobile {display:none!important}
|
||||
.lyrics-presence {color:var(--accent,#80bda6)!important;width:24px!important;min-width:24px!important;padding:3px!important}
|
||||
.lyrics-presence svg {width:15px;height:15px}
|
||||
.track-popularity-slot {position:relative;display:inline-flex;align-items:center;flex:none}
|
||||
.track-popularity-slot > .lyrics-presence {position:absolute;right:calc(100% + 2px);top:50%;transform:translateY(-50%);height:24px}
|
||||
.queue-track-info {padding-right:24px}
|
||||
.track-row > .track-album {padding-right:24px}
|
||||
@media(max-width:768px) {
|
||||
.lyrics-overlay {padding:12px}
|
||||
.lyrics-fullscreen {padding:0}
|
||||
@@ -40,7 +44,11 @@
|
||||
.lyrics-scroll {padding:12px 24px}
|
||||
.lyrics-line {font-size:30px;padding:10px 0}
|
||||
.lyrics-footer {padding-left:20px;padding-right:20px;gap:8px;flex-wrap:wrap}
|
||||
}
|
||||
@media (max-width:900px), (pointer:coarse) and (max-width:1024px) {
|
||||
.lyrics-toggle-mobile {display:inline-flex!important}
|
||||
.player-right > .lyrics-toggle {display:none}
|
||||
.track-row .track-info {padding-right:24px}
|
||||
}
|
||||
@media(prefers-reduced-motion:reduce) {.lyrics-line {transition:none}}
|
||||
:root {
|
||||
@@ -801,7 +809,7 @@ button.user-stat:hover {
|
||||
|
||||
.track-list-header {
|
||||
display: grid;
|
||||
grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 154px 60px;
|
||||
grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 178px 60px;
|
||||
padding: 8px 16px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
color: var(--text-subdued);
|
||||
@@ -813,7 +821,7 @@ button.user-stat:hover {
|
||||
|
||||
.track-row {
|
||||
display: grid;
|
||||
grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 154px 60px;
|
||||
grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 178px 60px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
cursor: default;
|
||||
@@ -826,7 +834,7 @@ button.user-stat:hover {
|
||||
.track-row.playing .track-num { color: var(--accent); }
|
||||
.playlist-track-list-header.editing,
|
||||
.playlist-track-row.editing {
|
||||
grid-template-columns: 32px 40px minmax(0, 1fr) minmax(0, 1fr) 154px 60px;
|
||||
grid-template-columns: 32px 40px minmax(0, 1fr) minmax(0, 1fr) 178px 60px;
|
||||
}
|
||||
|
||||
.playlist-track-row.editing {
|
||||
@@ -5551,6 +5559,14 @@ button.user-stat:hover {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Hidden edit controls still count for nth-child. Pin the normal playlist
|
||||
cells so its spacer cannot push actions onto a second grid row. */
|
||||
.playlist-track-row > span:nth-child(4) {display:none}
|
||||
.playlist-track-row:not(.editing) .track-num {grid-column:1;grid-row:1}
|
||||
.playlist-track-row:not(.editing) .playlist-track-info {grid-column:2;grid-row:1}
|
||||
.playlist-track-row:not(.editing) .track-actions {grid-column:3;grid-row:1}
|
||||
.playlist-track-row:not(.editing) .track-duration {grid-column:4;grid-row:1}
|
||||
|
||||
.history-table-head,
|
||||
.history-row.track-row {
|
||||
grid-template-columns: 44px minmax(0, 1fr) auto;
|
||||
@@ -5885,7 +5901,7 @@ button.user-stat:hover {
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
justify-self: center;
|
||||
width: min(80vw, 360px);
|
||||
width: min(100%, 360px);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -6165,13 +6181,16 @@ button.user-stat:hover {
|
||||
justify-self: center;
|
||||
width: min(100%, 560px);
|
||||
flex: 0 0 auto;
|
||||
grid-template-columns: minmax(0, 1fr) 48px 48px;
|
||||
grid-template-columns: 44px minmax(0, 1fr) 48px 48px;
|
||||
gap: 8px;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.player-bar.mobile-expanded .player-buttons > .lyrics-toggle-mobile {display:none!important}
|
||||
.player-bar.mobile-expanded .player-right > .lyrics-toggle {display:flex}
|
||||
|
||||
.player-bar.mobile-expanded .mobile-full-player .volume-control {
|
||||
grid-template-columns: 44px minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
@@ -6951,7 +6970,7 @@ button.user-stat:hover {
|
||||
|
||||
.volume-control {
|
||||
grid-template-columns: 22px minmax(0, 1fr);
|
||||
width: min(80vw, 320px);
|
||||
width: min(100%, 320px);
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
@@ -7024,7 +7043,7 @@ button.user-stat:hover {
|
||||
}
|
||||
|
||||
.player-bar.mobile-expanded .mobile-full-player .player-buttons {
|
||||
gap: 12px;
|
||||
gap: clamp(2px, calc((100vw - 300px) / 8), 12px);
|
||||
}
|
||||
|
||||
.player-bar.mobile-expanded .mobile-full-player .player-btn {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
// Render via FURU_PODCAST_RENDER_FIXTURE=1 cargo test renders_podcast_navigation_and_views.
|
||||
const {chromium}=require(process.env.PLAYWRIGHT_MODULE||'playwright');
|
||||
const fs=require('node:fs'),assert=require('node:assert/strict');
|
||||
const html=fs.readFileSync('target/podcast-player-fixture.html','utf8'),alpine=fs.readFileSync('target/podcast-alpine.min.js','utf8');
|
||||
const tracks=[1,2,3].map(id=>({id,playlist_track_id:id,title:id===1?'Вся правда о Юрии Куклачёве — очень длинное название трека':'Time Only Knows',artists:[{id:1,name:'Длинное имя исполнителя'}],featured_artists:[],release_id:1,release_title:'Example album',duration_seconds:303,lastfm_rating:87,has_lyrics:id===1,stream_url:'/audio.mp3'}));
|
||||
const near=(a,b,message)=>assert.ok(Math.abs(a-b)<1,`${message}: ${a} vs ${b}`);
|
||||
(async()=>{
|
||||
const browser=await chromium.launch({headless:true,...(process.env.CHROME_PATH?{executablePath:process.env.CHROME_PATH}:{})});
|
||||
try {
|
||||
for(const viewport of [{width:1440,height:1000},{width:900,height:1000},{width:820,height:1000},{width:575,height:900},{width:390,height:844},{width:320,height:740}]){
|
||||
const page=await browser.newPage({viewport,reducedMotion:'reduce'}),errors=[];page.on('pageerror',e=>errors.push(e.message));
|
||||
await page.route('**/*',route=>{
|
||||
const url=new URL(route.request().url());
|
||||
if(url.hostname==='layout.test'&&url.pathname==='/')return route.fulfill({contentType:'text/html',body:html});
|
||||
if(url.hostname==='cdn.jsdelivr.net'&&url.pathname.includes('alpine'))return route.fulfill({contentType:'application/javascript',body:alpine});
|
||||
if(url.pathname==='/api/player/artists')return route.fulfill({json:{items:[],total:0,has_more:false}});
|
||||
return route.fulfill({json:[]});
|
||||
});
|
||||
await page.goto('http://layout.test/');await page.waitForFunction(()=>window.Alpine?.store('library')&&Alpine.store('player'));
|
||||
await page.evaluate(data=>{
|
||||
const library=Alpine.store('library');library.view='playlist_detail';library.currentPlaylist={id:-1,title:'Likes',kind:'likes',is_own:false,tracks:data};
|
||||
const player=Alpine.store('player');player.currentTrack=data[0];player.duration=303;player.currentTime=31;player.progress=10;
|
||||
},tracks);
|
||||
await page.waitForSelector('.playlist-track-row');
|
||||
const row=page.locator('.playlist-track-row').first(),pop=row.locator('.popularity-info-btn'),heart=row.locator('.like-btn');
|
||||
const initial=await pop.boundingBox(),heartBefore=await heart.boundingBox();
|
||||
const icon=await row.locator('.lyrics-presence').boundingBox();assert.ok(icon.x+icon.width<=initial.x,'lyrics appear to the left of popularity');
|
||||
await page.evaluate(()=>Alpine.store('library').currentPlaylist.tracks[0].has_lyrics=false);
|
||||
await row.locator('.lyrics-presence').waitFor({state:'hidden'});
|
||||
near((await pop.boundingBox()).x,initial.x,'popularity must not move');near((await heart.boundingBox()).x,heartBefore.x,'other actions must not move');
|
||||
await page.evaluate(()=>Alpine.store('library').currentPlaylist.tracks[0].has_lyrics=true);await row.locator('.lyrics-presence').waitFor({state:'visible'});
|
||||
assert.equal(await page.locator('.lyrics-toggle:visible').count(),1,'only one player lyrics button');
|
||||
const actions=await row.locator('.track-actions').boundingBox(),info=await row.locator('.playlist-track-info').boundingBox(),rowBox=await row.boundingBox();
|
||||
assert.ok(actions.y>=rowBox.y&&actions.y+actions.height<=rowBox.y+rowBox.height+1,'actions stay inside row');
|
||||
near(actions.y+actions.height/2,info.y+info.height/2,'playlist actions share title row');
|
||||
assert.ok(actions.x>=0&&actions.x+actions.width<=viewport.width,'actions fit viewport');
|
||||
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false,'no horizontal page overflow');
|
||||
if(viewport.width<=900){
|
||||
assert.equal(await page.locator('.player-right > .lyrics-toggle:visible').count(),0);
|
||||
const volume=await page.locator('.volume-control').boundingBox(),right=await page.locator('.player-right').boundingBox();
|
||||
assert.ok(volume.x+volume.width<=right.x+right.width,'volume stays inside controls');
|
||||
const device=await page.locator('.player-right > .device-picker').boundingBox();
|
||||
near(device.y+device.height/2,volume.y+volume.height/2,'device control stays on volume row');
|
||||
assert.ok(device.x+device.width<=viewport.width,'device picker stays inside viewport');
|
||||
}else{
|
||||
const duration=await row.locator('.track-duration').boundingBox();assert.ok(actions.x+actions.width<=duration.x+1,'actions do not overlap duration');
|
||||
}
|
||||
await page.screenshot({path:`target/player-layout-likes-${viewport.width}.png`});
|
||||
await page.evaluate(()=>{const playlist=Alpine.store('library').currentPlaylist;playlist.id=12;playlist.kind='user';playlist.is_own=true;playlist.title='Playlist';Alpine.store('playlists').editingPlaylistId=12;});
|
||||
await page.waitForSelector('.playlist-track-row.editing');
|
||||
const editingActions=await row.locator('.track-actions').boundingBox(),editingInfo=await row.locator('.playlist-track-info').boundingBox();
|
||||
near(editingActions.y+editingActions.height/2,editingInfo.y+editingInfo.height/2,'editing actions stay in title row');
|
||||
if(viewport.width<=900){
|
||||
await page.evaluate(()=>Alpine.store('mobile').playerExpanded=true);await page.waitForSelector('.player-bar.mobile-expanded');
|
||||
assert.equal(await page.locator('.lyrics-toggle:visible').count(),1,'expanded player has one lyrics button');
|
||||
const expandedButtons=await page.locator('.player-buttons').boundingBox();assert.ok(expandedButtons.x>=-1&&expandedButtons.x+expandedButtons.width<=viewport.width+1,`expanded transport buttons fit viewport: ${JSON.stringify({viewport,expandedButtons})}`);
|
||||
await page.screenshot({path:`target/player-layout-expanded-${viewport.width}.png`});
|
||||
}
|
||||
assert.deepEqual(errors,[]);await page.close();
|
||||
}
|
||||
console.log('Player layout checks passed at 1440, 900, 820, 575, 390 and 320 px.');
|
||||
}finally{await browser.close();}
|
||||
})().catch(e=>{console.error(e);process.exitCode=1;});
|
||||
Reference in new issue
Block a user