mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 13:49:39 +05:00
refactor: 💄 tweak search suggestion appearance and make them submit on click
This commit is contained in:
@@ -1,19 +1,37 @@
|
||||
#search-suggestions {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
background-color: var(--secondary);
|
||||
flex-direction: column;
|
||||
margin: 0;
|
||||
padding: 1rem;
|
||||
padding-bottom: 0;
|
||||
/* god damn this shit i hate webdev */
|
||||
background-color: var(--secondary);
|
||||
padding: .5rem;
|
||||
width: -moz-available;
|
||||
width: -webkit-fill-available;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#search-suggestions > ul {
|
||||
display: flex;
|
||||
position: absolute;
|
||||
gap: 1rem;
|
||||
margin: 0;
|
||||
background-color: var(--secondary);
|
||||
padding: 1rem;
|
||||
width: -moz-available;
|
||||
width: -webkit-fill-available;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#search-suggestions > li {
|
||||
padding-bottom: 1rem;
|
||||
cursor: pointer;
|
||||
padding: .5rem;
|
||||
|
||||
&:hover {
|
||||
background-color: var(--0);
|
||||
}
|
||||
|
||||
#search-suggestions > li:hover {
|
||||
cursor: pointer;
|
||||
&::before {
|
||||
margin-right: .5rem;
|
||||
content: "🔎 ";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
var searchSuggestions = document.getElementById('search-suggestions');
|
||||
var input = document.getElementById('q');
|
||||
var form = document.querySelector('form[action="/search"]');
|
||||
var timeout;
|
||||
|
||||
function getSuggestions() {
|
||||
@@ -26,13 +27,14 @@ function getSuggestions() {
|
||||
e.onclick = function () {
|
||||
input.value = this.textContent;
|
||||
searchSuggestions.style.display = 'none';
|
||||
form.submit();
|
||||
}
|
||||
cloned.appendChild(e);
|
||||
}
|
||||
|
||||
searchSuggestions.parentNode.replaceChild(cloned, searchSuggestions);
|
||||
searchSuggestions = cloned;
|
||||
searchSuggestions.style.display = 'block';
|
||||
searchSuggestions.style.display = 'flex';
|
||||
} catch {
|
||||
searchSuggestions.style.display = 'none';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user