added loading placeholder when searching; added loading placeholder when changing tabs in search tab

This commit is contained in:
Roberto Tonino 2020-06-18 20:06:14 +02:00
parent e429b9e978
commit 04c127dd6c
12 changed files with 133 additions and 83 deletions

View File

@ -21,6 +21,7 @@ This is just the WebUI for deemix, it should be used with deemix-pyweb or someth
- Context menu for pywebview (Context menu is blocked in pywebview)
- Copy and paste functions
- Block selection where it's not needed (keep only titles artists albums labels and useful data)
- There's a SASS mixin for this. Need to use it in the proper classes
- ?
# License

File diff suppressed because one or more lines are too long

View File

@ -20,8 +20,8 @@
</head>
<body>
<div id="loading_overlay" class="active">
<span id="loading_text">Connecting to the server...</span>
<div id="start_app_placeholder" class="loading_placeholder">
<span class="loading_placeholder__text">Connecting to the server...</span>
<div class="lds-ring">
<div></div>
<div></div>
@ -69,6 +69,7 @@
</div>
</span>
</aside>
<main id="main_content">
<div id="middle_section">
<header id="search">
@ -223,8 +224,14 @@ <h1>No results</h1>
</div>
<!-- ### Track Search Tab ### -->
<div id="track_search" class="search_tabcontent">
<div v-if="!results.trackTab.loaded">
<h1>Loading</h1>
<div v-if="!results.trackTab.loaded" class="loading_placeholder">
<span class="loading_placeholder__text">Loading...</span>
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div v-else-if="results.trackTab.data.length == 0">
<h1>No Tracks found</h1>
@ -287,8 +294,14 @@ <h1>No Tracks found</h1>
</div>
<!-- ### Album Search Tab ### -->
<div id="album_search" class="search_tabcontent">
<div v-if="!results.albumTab.loaded">
<h1>Loading</h1>
<div v-if="!results.albumTab.loaded" class="loading_placeholder">
<span class="loading_placeholder__text">Loading...</span>
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div v-else-if="results.albumTab.data.length == 0">
<h1>No Albums found</h1>
@ -312,8 +325,14 @@ <h1>No Albums found</h1>
</div>
<!-- ### Artist Search Tab ### -->
<div id="artist_search" class="search_tabcontent">
<div v-if="!results.artistTab.loaded">
<h1>Loading</h1>
<div v-if="!results.artistTab.loaded" class="loading_placeholder">
<span class="loading_placeholder__text">Loading...</span>
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div v-else-if="results.artistTab.data.length == 0">
<h1>No Artists found</h1>
@ -334,8 +353,14 @@ <h1>No Artists found</h1>
</div>
<!-- ### Playlist Search Tab ### -->
<div id="playlist_search" class="search_tabcontent">
<div v-if="!results.playlistTab.loaded">
<h1>Loading</h1>
<div v-if="!results.playlistTab.loaded" class="loading_placeholder">
<span class="loading_placeholder__text">Loading...</span>
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div v-else-if="results.playlistTab.data.length == 0">
<h1>No Playlists found</h1>
@ -1442,6 +1467,15 @@ <h1>Errors for {{ title }}</h1>
</div>
</section>
<div id="search_placeholder" class="loading_placeholder loading_placeholder--hidden">
<span class="loading_placeholder__text">Searching...</span>
<div class="lds-ring">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
<div id="download_tab_container" class="tab_hidden">

File diff suppressed because one or more lines are too long

View File

@ -61,8 +61,6 @@ const FavoritesTab = new Vue({
this.artists = artists
this.playlists = playlists
console.log('update ok')
// Removing animation class only when the animation has completed an iteration
// Prevents animation ugly stutter
this.$refs.reloadButton.addEventListener(

View File

@ -131,6 +131,10 @@ const MainSearch = new Vue({
}
},
handleMainSearch(result) {
// Hiding loading placeholder
document.getElementById('content').style.display = ''
document.getElementById('search_placeholder').classList.toggle('loading_placeholder--hidden')
let resetObj = { data: [], next: 0, total: 0, loaded: false }
this.results.allTab = result

View File

@ -46,6 +46,10 @@ function handleSearchBarKeyup(e) {
if (term !== MainSearch.results.query || main_selected == 'search_tab') {
document.getElementById('search_tab_content').style.display = 'none'
socket.emit('mainSearch', { term })
// Showing loading placeholder
document.getElementById('content').style.display = 'none'
document.getElementById('search_placeholder').classList.toggle('loading_placeholder--hidden')
} else {
document.getElementById('search_tab_content').style.display = 'block'
document.getElementById('main_search_tablink').click()

View File

@ -1,5 +1,5 @@
export const socket = io.connect(window.location.href)
socket.on('connect', () => {
document.getElementById('loading_overlay').classList.remove('active')
document.getElementById('start_app_placeholder').classList.add('loading_placeholder--hidden')
})

View File

@ -1,41 +0,0 @@
/* Source: https://loading.io/css/ */
.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid #fff;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: #fff transparent transparent transparent;
&:nth-child(1) {
animation-delay: -0.45s;
}
&:nth-child(2) {
animation-delay: -0.3s;
}
&:nth-child(3) {
animation-delay: -0.15s;
}
}
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@ -1,3 +1,45 @@
/* Source: https://loading.io/css/ */
.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid #fff;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: #fff transparent transparent transparent;
&:nth-child(1) {
animation-delay: -0.45s;
}
&:nth-child(2) {
animation-delay: -0.3s;
}
&:nth-child(3) {
animation-delay: -0.15s;
}
}
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin {
from {
transform: rotate(0deg);

View File

@ -12,13 +12,13 @@ input[type='search'] {
margin-bottom: 8px;
}
input[type=search]::-webkit-search-cancel-button {
input[type='search']::-webkit-search-cancel-button {
-webkit-appearance: none;
width: 28px;
height: 28px;
background-color: var(--foreground);
-webkit-mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='28' viewBox='0 0 24 24' width='28'%3E%%3Cpath fill='%23ffffff' d='M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15.59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z'/%3E3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='28' viewBox='0 0 24 24' width='28'%3E%%3Cpath fill='%23ffffff' d='M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15.59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z'/%3E3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='28' viewBox='0 0 24 24' width='28'%3E%%3Cpath fill='%23ffffff' d='M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15.59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z'/%3E3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
}
input[type='checkbox'] {
@ -96,28 +96,6 @@ button:hover {
border: 1px solid var(--accent-color);
}
#loading_overlay {
justify-content: center;
align-items: center;
position: absolute;
flex-direction: column;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
display: none;
z-index: 1000;
}
#loading_overlay.active {
display: flex;
}
#loading_text {
margin-bottom: 20px;
}
#main_content {
margin-left: 48px;
width: calc(100% - 48px);
@ -304,3 +282,34 @@ button.with_icon i {
.hide {
display: none !important;
}
.loading_placeholder {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
flex: 1;
height: 100%;
&.loading_placeholder--hidden {
display: none;
}
&__text {
margin-bottom: 20px;
}
&#search_placeholder {
height: calc(100% - 93px);
}
&#start_app_placeholder {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: hsla(0, 0, 0, 50%);
z-index: 1000;
}
}

View File

@ -16,7 +16,6 @@
@import './tabs/settings-tab';
@import './tabs/tabs';
@import './animations';
@import './middle-section';
@import './progressbar';
@import './sidebar';