adding cool search
This commit is contained in:
@@ -3054,6 +3054,7 @@ input#s_avatar {
|
|||||||
50% {
|
50% {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Modern Tags Layout */
|
/* Modern Tags Layout */
|
||||||
.tags-grid {
|
.tags-grid {
|
||||||
@@ -3121,3 +3122,59 @@ input#s_avatar {
|
|||||||
color: #888;
|
color: #888;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
}
|
}
|
||||||
|
/* Search Overlay */
|
||||||
|
#search-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.9);
|
||||||
|
backdrop-filter: blur(5px);
|
||||||
|
z-index: 10000;
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 20px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-overlay.visible {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-input {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 2px solid var(--accent);
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 3rem;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 800px;
|
||||||
|
text-align: center;
|
||||||
|
outline: none;
|
||||||
|
font-family: var(--font);
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-input::placeholder {
|
||||||
|
color: #555;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-close {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 30px;
|
||||||
|
color: var(--white);
|
||||||
|
font-size: 2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: sans-serif;
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search-close:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -745,6 +745,73 @@ window.requestAnimFrame = (function () {
|
|||||||
|
|
||||||
// <scroller>
|
// <scroller>
|
||||||
|
|
||||||
|
// <search-overlay>
|
||||||
|
const initSearch = () => {
|
||||||
|
if (!document.getElementById('search-overlay')) {
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.id = 'search-overlay';
|
||||||
|
overlay.innerHTML = `
|
||||||
|
<div id="search-close">×</div>
|
||||||
|
<input type="text" id="search-input" placeholder="Search Tags..." autocomplete="off">
|
||||||
|
`;
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
const input = document.getElementById('search-input');
|
||||||
|
const close = document.getElementById('search-close');
|
||||||
|
const btns = document.querySelectorAll('#nav-search-btn, #nav-search-btn-guest');
|
||||||
|
|
||||||
|
const toggleSearch = (show) => {
|
||||||
|
if (show) {
|
||||||
|
overlay.style.display = 'flex';
|
||||||
|
// Force reflow
|
||||||
|
overlay.offsetHeight;
|
||||||
|
overlay.classList.add('visible');
|
||||||
|
input.focus();
|
||||||
|
} else {
|
||||||
|
overlay.classList.remove('visible');
|
||||||
|
setTimeout(() => {
|
||||||
|
overlay.style.display = 'none';
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
btns.forEach(btn => btn.addEventListener('click', (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
toggleSearch(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
close.addEventListener('click', () => toggleSearch(false));
|
||||||
|
|
||||||
|
// Close on click outside (background)
|
||||||
|
overlay.addEventListener('click', (e) => {
|
||||||
|
if (e.target === overlay) toggleSearch(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ESC to close
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Escape' && overlay.classList.contains('visible')) {
|
||||||
|
toggleSearch(false);
|
||||||
|
}
|
||||||
|
// "k" to open
|
||||||
|
if (e.key === 'k' && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && !overlay.classList.contains('visible')) {
|
||||||
|
e.preventDefault();
|
||||||
|
toggleSearch(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
input.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
const val = input.value.trim();
|
||||||
|
if (val) {
|
||||||
|
window.location.href = `/tag/${encodeURIComponent(val)}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
initSearch();
|
||||||
|
// </search-overlay>
|
||||||
|
|
||||||
// </scroller>
|
// </scroller>
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
@if(!/^\/\d$/.test(url.pathname))
|
@if(!/^\/\d$/.test(url.pathname))
|
||||||
<a href="/random" id="nav-random">rand</a>
|
<a href="/random" id="nav-random">rand</a>
|
||||||
@endif
|
@endif
|
||||||
|
<a href="#" id="nav-search-btn" title="Search"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
|
||||||
|
fill="currentColor" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
|
||||||
|
</svg></a>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<!-- show pagination only for tags and main page -->
|
<!-- show pagination only for tags and main page -->
|
||||||
@@ -33,6 +38,11 @@
|
|||||||
@if(!/^\/\d$/.test(url.pathname))
|
@if(!/^\/\d$/.test(url.pathname))
|
||||||
<a href="/random" id="nav-random">rand</a>
|
<a href="/random" id="nav-random">rand</a>
|
||||||
@endif
|
@endif
|
||||||
|
<a href="#" id="nav-search-btn-guest" title="Search"><svg xmlns="http://www.w3.org/2000/svg" width="16"
|
||||||
|
height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
|
||||||
|
</svg></a>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<!-- show pagination only for tags and main page -->
|
<!-- show pagination only for tags and main page -->
|
||||||
|
|||||||
Reference in New Issue
Block a user