From 297a6994b204116c930a97db404b60cb80c0df3e Mon Sep 17 00:00:00 2001 From: Nick Miller Date: Tue, 14 Apr 2020 12:19:10 -0400 Subject: [PATCH] Render search results as a list --- app/assets/stylesheets/notes.scss | 2 +- app/assets/stylesheets/search.scss | 18 +++++++++++------- app/views/search/_result.html.erb | 4 ++-- app/views/search/search.html.erb | 20 +++++++++++--------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/notes.scss b/app/assets/stylesheets/notes.scss index 6cbca18..d28a5d5 100644 --- a/app/assets/stylesheets/notes.scss +++ b/app/assets/stylesheets/notes.scss @@ -2,7 +2,7 @@ textarea#note_text, blockquote.note > p { width: 100%; font-family: serif; - font-size: 125%; + font-size: 150%; } textarea#note_text { diff --git a/app/assets/stylesheets/search.scss b/app/assets/stylesheets/search.scss index 236f2f6..a3e9721 100644 --- a/app/assets/stylesheets/search.scss +++ b/app/assets/stylesheets/search.scss @@ -1,12 +1,16 @@ -.search-result { - padding-top: 0.50em; - padding-bottom: 0.50em; +.search-results { + list-style: none; + padding: 0; } -.search-result:first-of-type { - padding-top: 0em; +.search-result { + padding: 0.5em; + + > p { + margin: 0; + } } -.search-result + .search-result { - margin-top: 0.50em; +.search-result:nth-child(2n) { + background: #eee; } diff --git a/app/views/search/_result.html.erb b/app/views/search/_result.html.erb index 984e9b5..b1595cb 100644 --- a/app/views/search/_result.html.erb +++ b/app/views/search/_result.html.erb @@ -1,8 +1,8 @@ -
+
  • <%= link_to note.summarize(200), note %>

      #{heart} +<%=number_to_human note.likes.size%>

    -
  • + diff --git a/app/views/search/search.html.erb b/app/views/search/search.html.erb index 46e8449..13d7137 100644 --- a/app/views/search/search.html.erb +++ b/app/views/search/search.html.erb @@ -1,11 +1,13 @@ -<%- title @query %> +<%- title "Results for \"#{@query}\"" %>
    -
    -

    Results for “<%=@query%>”

    - <% if @results.any? %> - <%= render partial: 'search/result', collection: @results, as: :note %> - <% else %> -

    No results

    - <% end %> -
    +
    +

    Results for “<%=@query%>”

    + <% if @results.any? %> +
      + <%= render partial: 'search/result', collection: @results, as: :note %> +
    + <% else %> +

    No results

    + <% end %> +