Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

2.5 KB
Raw Blame
<%# The result-list body, shared by the live search frame (search.html.erb) and
    the initial render inside _search_box (so an opened result keeps the list).
    Reads @searched / @results / @query. Result links target _top — they navigate
    the whole page (and carry q= for the body highlight), NOT the result frame, and
    the list is re-rendered filled on that navigation so it survives the click.

    The block is a clearly LABELLED group ("N Treffer") separated from the nav tree
    below (border-b) so it reads as search results, not more navigation. The open
    result gets a yellow left accent via an INSET shadow (not a left border) so the
    1px card frame stays even on all four sides — a transparent left border would
    make the card look open/broken. %>
<% if @searched %>
  <% if @results.empty? %>
    <p class="mt-2 px-1 text-xs text-muted"><%= t('views.organisations.help.search.empty') %></p>
  <% else %>
    <div class="mt-2 mb-3 border-b border-cream-300 pb-3">
      <p id="help-search-results-label" class="mb-1 flex items-center gap-1 px-1 text-xs font-semibold uppercase tracking-wide text-muted">
        <i class="bi bi-search"></i>
        <%= t('views.organisations.help.search.results_count', count: @results.size) %>
      </p>
      <%# role=listbox + role=option make this the keyboard combobox popup; the option
          id/aria-selected are managed by frame_search_controller. aria-current="page"
          marks the open card so a keyboard Enter can land the selection back on it. %>
      <ul role="listbox" id="help-search-listbox" aria-labelledby="help-search-results-label" class="flex flex-col gap-1">
        <% @results.each do |result| %>
          <% is_active = result.slug == @active_slug %>
          <li role="presentation">
            <%= link_to help_page_path(slug: result.slug, q: @query),
                  role: "option",
                  "aria-current": (is_active ? "page" : nil),
                  data: { turbo_frame: '_top', frame_search_target: 'result' },
                  class: "block rounded-md border border-cream-300 bg-surface-raised px-2 py-1.5 hover:bg-selected #{is_active ? 'shadow-[inset_3px_0_0_0_#fbbf24]' : ''}" do %>
              <span class="block truncate text-sm font-medium text-heading"><%= result.title %></span>
              <span class="block truncate text-xs text-muted">
                <%= t('views.organisations.help.search.in_section') %> <em><%= result.section %></em>
              </span>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  <% end %>
<% end %>