From 4bf69e64c5fbe9d3e5ea22abab600b9798695233 Mon Sep 17 00:00:00 2001 From: ludwiczakpawel Date: Wed, 16 Sep 2020 22:03:34 +0200 Subject: [PATCH] Update search menu to use Crayons styling, v2 (#10347) * Replace old query style with crayons link block * Add Crayons layout * Rename nav file and refactor how it's referenced in parent file * Rename sidebar file * style updates * more changes * podcasts * . * code format Co-authored-by: Lisa Sy --- .../javascripts/utilities/buildArticleHTML.js | 48 ++++++---------- app/assets/stylesheets/widgets.scss | 56 ------------------- app/views/articles/_search.html.erb | 8 +-- app/views/articles/search.html.erb | 30 ++++++---- app/views/articles/search/_nav_menu.html.erb | 17 ++++++ app/views/articles/search/_sidebar.html.erb | 18 ------ .../search/_sidebar_additional.html.erb | 5 -- 7 files changed, 56 insertions(+), 126 deletions(-) create mode 100644 app/views/articles/search/_nav_menu.html.erb delete mode 100644 app/views/articles/search/_sidebar.html.erb delete mode 100644 app/views/articles/search/_sidebar_additional.html.erb diff --git a/app/assets/javascripts/utilities/buildArticleHTML.js b/app/assets/javascripts/utilities/buildArticleHTML.js index 863876f90..edb51b83e 100644 --- a/app/assets/javascripts/utilities/buildArticleHTML.js +++ b/app/assets/javascripts/utilities/buildArticleHTML.js @@ -4,37 +4,23 @@ function buildArticleHTML(article) { if (article && article.class_name === 'PodcastEpisode') { - return ( - '
\ -
\ - \ - ' +
-      article.podcast.title +
-      ' image\ - \ -
\ - \ -
\ -

podcast' + - article.title + - '

\ -
\ -
\ -

' + - article.podcast.title + - '

\ -
' - ); + return ``; } if (article) { diff --git a/app/assets/stylesheets/widgets.scss b/app/assets/stylesheets/widgets.scss index 6972bbd3a..2cfcf603b 100644 --- a/app/assets/stylesheets/widgets.scss +++ b/app/assets/stylesheets/widgets.scss @@ -63,10 +63,6 @@ &:hover { opacity: 1; } - h4 { - margin: 0; - } - &.showing { display: block; } @@ -267,51 +263,6 @@ } } - // Filtering / todo: replace with tabs? - .query-filter-button { - font-size: 15px; - font-weight: bold; - background: transparent; - border: 0px; - display: block; - padding: 6px 8px; - width: calc(100% - 16px); - text-align: left; - border-radius: 0px; - color: var(--body-color); - cursor: pointer; - &:hover { - @include themeable( - background, - theme-container-background-hover, - lighten($bold-blue, 38%) - ); - } - &.selected { - @include themeable( - background, - theme-container-accent-background, - lighten($bold-blue, 10%) - ); - color: var(--card-color); - } - &.query-type-filter-button { - &:hover { - @include themeable( - background, - theme-container-background-hover, - $light-green - ); - } - &.selected { - @include themeable( - background, - theme-container-accent-background, - darken($light-green, 10%) - ); - } - } - } p { margin: 8px 0; } @@ -393,13 +344,6 @@ } } -.query-filter-button { - box-sizing: border-box; - display: inline-block; - padding: var(--su-2) 0; - width: 100%; -} - // Sidebar sponsors .sidebar-sponsor { color: var(--card-color-tertiary); diff --git a/app/views/articles/_search.html.erb b/app/views/articles/_search.html.erb index 1333b5b9d..25802e08f 100644 --- a/app/views/articles/_search.html.erb +++ b/app/views/articles/_search.html.erb @@ -70,7 +70,7 @@ var filterButts = document.getElementsByClassName("query-filter-button"); for (var i = 0; i < filterButts.length; i++) { if (filters == filterButts[i].dataset.filter) { - filterButts[i].classList.add("selected"); + filterButts[i].classList.add("crayons-link--current"); } filterButts[i].onclick = function (e) { var currentParams = getQueryParams(document.location.search); @@ -86,10 +86,10 @@ window.history.pushState(null, null, "/search?q=" + query + "&filters=" + filters + sortString); var className = e.target.className; for (var i = 0; i < filterButts.length; i++) { - filterButts[i].classList.remove("selected"); + filterButts[i].classList.remove("crayons-link--current"); } - if (className.indexOf("selected") == -1) { - e.target.classList.add("selected"); + if (className.indexOf("crayons-link--current") == -1) { + e.target.classList.add("crayons-link--current"); window.history.replaceState(null, null, "/search?q=" + query + "&filters=" + filters + sortString); search(query, filters, sortBy, sortDirection); } else { diff --git a/app/views/articles/search.html.erb b/app/views/articles/search.html.erb index c9f15b679..b1242dbe9 100644 --- a/app/views/articles/search.html.erb +++ b/app/views/articles/search.html.erb @@ -2,22 +2,29 @@ <%= render "articles/search/meta" %> <% end %>
-
+

Search results

+ + + + +
" data-articles-since="<%= Timeframer.new(params[:timeframe]).datetime&.iso8601 %>"> - <%= render "articles/search/sidebar" %> -
+ + + +
-
@@ -28,7 +35,6 @@ loading...
- <%= render "articles/search/sidebar_additional" %>
<%= render "articles/search" %> diff --git a/app/views/articles/search/_nav_menu.html.erb b/app/views/articles/search/_nav_menu.html.erb new file mode 100644 index 000000000..195eb2e1d --- /dev/null +++ b/app/views/articles/search/_nav_menu.html.erb @@ -0,0 +1,17 @@ + diff --git a/app/views/articles/search/_sidebar.html.erb b/app/views/articles/search/_sidebar.html.erb deleted file mode 100644 index 88ff55081..000000000 --- a/app/views/articles/search/_sidebar.html.erb +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/app/views/articles/search/_sidebar_additional.html.erb b/app/views/articles/search/_sidebar_additional.html.erb deleted file mode 100644 index 3013f5acd..000000000 --- a/app/views/articles/search/_sidebar_additional.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -