search: real autocomplete previews + clearer placeholder

PLACEHOLDER: "Search broadcast news…" → "Search articles, gear,
vendors". Drops the weird ellipsis and the "we're a broadcast site
so 'broadcast news' is redundant" feel.

API (/api/search/suggest):
- Match expanded from {title, author_name} to
  {title, excerpt, content, author_name} — surfaces hits when the
  phrase lives deep in the article body.
- Returns a snippet object {text, matchStart, matchEnd} sliced
  from the first hit (HTML-stripped), with ~80 chars of context on
  either side and "…" markers when truncated.
- Returns matched_in: 'title' | 'excerpt' | 'content' | 'author' so
  the UI can show "match in article body" / "match in byline".
- Returns date + author_name on each result.

UI dropdown (Header.tsx):
- Each suggestion now renders three rows:
  1) Title (bold) + category chip
  2) Snippet with the matched substring wrapped in <mark>
  3) Author byline + date + (if match wasn't in title) a tag
     showing where the match occurred
- Vertical stacking with a colored left-border on hover so the
  active suggestion is visible.

CSS:
- Stack item layout, snippet with -webkit-line-clamp:2 so long
  matches don't overflow.
- <mark> background uses the accent blue at 28% so the highlight
  reads against the dark card.
This commit is contained in:
Ryan Salazar
2026-05-20 16:22:04 +00:00
parent c1705e1a4b
commit 418027b469
3 changed files with 201 additions and 27 deletions

View File

@@ -867,22 +867,31 @@ h1, h2, h3 {
.bb-browse-search-suggest-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 8px 14px;
flex-direction: column;
gap: 4px;
padding: 10px 14px;
font-family: var(--font-body);
font-size: 13px;
color: #d1d8e4;
text-decoration: none;
transition: background var(--transition-fast), color var(--transition-fast);
border-left: 2px solid transparent;
}
.bb-browse-search-suggest-item:hover,
.bb-browse-search-suggest-item:focus-visible {
background: rgba(59, 130, 246, 0.12);
background: rgba(59, 130, 246, 0.10);
color: #ffffff;
outline: none;
border-left-color: var(--color-accent);
}
.bb-browse-search-suggest-row1 {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
min-width: 0;
}
.bb-browse-search-suggest-title {
@@ -891,6 +900,8 @@ h1, h2, h3 {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: 600;
color: #e6ecf3;
}
.bb-browse-search-suggest-cat {
@@ -904,6 +915,52 @@ h1, h2, h3 {
opacity: 0.75;
}
.bb-browse-search-suggest-snippet {
font-size: 12px;
color: #98a3b3;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.bb-browse-search-suggest-mark {
background: rgba(59, 130, 246, 0.28);
color: #ffffff;
padding: 0 2px;
border-radius: 2px;
font-weight: 600;
}
.bb-browse-search-suggest-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
font-size: 11px;
color: #6b7585;
font-family: var(--font-mono);
letter-spacing: 0.02em;
}
.bb-browse-search-suggest-meta .bb-dot {
opacity: 0.5;
}
.bb-browse-search-suggest-mark-tag {
display: inline-block;
margin-left: 4px;
padding: 1px 6px;
background: rgba(59, 130, 246, 0.10);
color: var(--color-accent);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
border-radius: 2px;
}
.bb-browse-search-suggest-all {
border-top: 1px solid #1f2937;
margin-top: 2px;