Add full-text search

Add a search box with a quick results popover, as well full results in
the sidebar on pressing enter.
This commit is contained in:
2026-02-20 12:39:04 +04:00
parent 2734f08608
commit bf12305600
15 changed files with 878 additions and 68 deletions

View File

@@ -74,6 +74,11 @@ body {
pointer-events: auto; /* Re-enable clicks for buttons */
}
.header-left {
display: flex;
align-items: center;
}
.btn-press {
transition: transform 0.1s;
}
@@ -750,3 +755,158 @@ button.create-place {
padding-bottom: env(safe-area-inset-bottom, 20px);
}
}
/* Search Box Component */
.search-box {
position: relative;
width: 100%;
max-width: 320px;
margin-left: 1rem;
z-index: 3002; /* Higher than menu button to be safe */
}
@media (max-width: 768px) {
.search-box {
max-width: 200px; /* Smaller on mobile */
margin-left: 0.5rem;
}
}
.search-form {
display: flex;
align-items: center;
background: white;
border-radius: 24px; /* Pill shape */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
padding: 0 0.75rem;
height: 40px;
transition: box-shadow 0.2s;
}
.search-form:focus-within {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.search-icon {
display: flex;
align-items: center;
color: #666;
margin-right: 0.5rem;
}
.search-input {
border: none;
background: transparent;
flex: 1;
height: 100%;
font-size: 1rem;
color: #333;
outline: none;
width: 100%;
padding: 0;
/* Remove native search cancel button in WebKit */
-webkit-appearance: none;
}
/* Remove 'x' from search input in Chrome/Safari */
.search-input::-webkit-search-cancel-button {
-webkit-appearance: none;
}
.search-clear-btn {
background: none;
border: none;
padding: 4px;
cursor: pointer;
display: flex;
align-items: center;
color: #999;
border-radius: 50%;
}
.search-clear-btn:hover {
background: #f0f0f0;
color: #666;
}
/* Search Results Popover */
.search-results-popover {
position: absolute;
top: 100%;
left: 0;
right: 0;
margin-top: 8px;
background: white;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
overflow: hidden;
max-height: 400px;
overflow-y: auto;
z-index: 3002;
}
.search-results-list {
list-style: none;
padding: 0;
margin: 0;
}
.search-result-item {
width: 100%;
display: flex;
align-items: center; /* Vertical center alignment */
gap: 0.75rem;
padding: 0.75rem 1rem;
border: none;
background: white;
text-align: left;
cursor: pointer;
transition: background 0.1s;
border-bottom: 1px solid #f0f0f0;
}
.search-result-item:last-child {
border-bottom: none;
}
.search-result-item:hover,
.search-result-item:focus {
background: #f5f5f5;
outline: none;
}
.result-icon {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
background: #f0f0f0;
border-radius: 50%;
flex-shrink: 0;
color: #666;
}
.result-info {
display: flex;
flex-direction: column;
overflow: hidden; /* For text truncation if needed */
}
.result-title {
font-weight: 500;
color: #333;
font-size: 0.95rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.result-desc {
font-size: 0.8rem;
color: #777;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 2px;
}