% @page_title = "Search" %>
<% @body_class = "sidebar searches" %>
<% content_for :nav do %>
<% if @query %>
<%= tag.div class: "btn btn--reversed btn--faux align-center gap txt-nowrap" do %>
“<%= @query %>”
<%= @messages.count %>
<% end %>
<% end %>
<% @recent_searches.each do |search| %>
<%= link_to searches_path(q: search.query), class: "align-center gap room btn txt-nowrap" do %>
“<%= search.query %>”
<% end %>
<% end %>
<% if @recent_searches.any? %>
<%= button_to clear_searches_url, method: :delete, class: "btn searches__btn",
data: { turbo_confirm: "Are you sure you want to clear your recent searches?" } do %>
<%= image_tag "broom.svg", aria: { hidden: "true" } %>
Clear recent searches
<% end %>
<% end %>
<% end %>
<% content_for :sidebar do %>
<% @recent_searches.each do |search| %>
<%= link_to searches_path(q: search.query), class: "align-center gap room btn txt-nowrap" do %>
“<%= search.query %>”
<% end %>
<% end %>
<% if @recent_searches.any? %>
<%= button_to clear_searches_url, method: :delete, class: "btn searches__btn",
data: { turbo_confirm: "Are you sure you want to clear your recent searches?" } do %>
<%= image_tag "broom.svg", aria: { hidden: "true" } %>
Clear recent searches
<% end %>
<% end %>
<% end %>
<%= image_tag "search.svg", aria: { hidden: "true" }, class: "colorize--black translucent" %>
<%= search_results_tag do %>
<%= render @messages %>
<% end %>
<% content_for :footer do %>
<%= link_to room_path(@return_to_room),
class: "btn flex-item-no-shrink margin-block-end", style: "view-transition-name: input-switcher; --btn-border-radius: 0.5em" do %>
<%= image_tag "arrow-left.svg", aria: { hidden: "true" } %>
Exit search
<% end %>
<%= form_with url: searches_path, class: "margin-block flex-item-grow contain flex align-center gap",
data: { controller: "form", action: "keydown.esc->form#cancel" } do |form| %>
<%= image_tag "search.svg", size: 20, aria: { hidden: "true" }, class: "composer__input-hint colorize--black", style: "view-transition-name: input-btn;" %>
<%= form.text_field :q, value: params[:q], class: "searches__input input flex-item-grow", role: "searchbox", aria: { label: "search" }, autofocus: true, required: true %>
<%= link_to searches_path, data: { form_target: "cancel" }, role: "button", class: "searches__reset" do %>
<%= image_tag "remove.svg", aria: { hidden: "true" }, size: 14, class: "colorize--black" %>
Clear search field
<% end %>
<%= form.button type: "submit", class: "btn btn--reversed flex-item-no-shrink txt-small", style: "--btn-border-radius: 0.5em" do %>
<%= image_tag "arrow-up.svg", aria: { hidden: "true" } %>
Search
<% end %>
<% end %>
<% end %>