Skip to content

Commit 4e4a972

Browse files
Adds tab description partial and styles
Moves the tab description closer to the tab itself to allow for clearly indication that the description is related to the tab. Refreshes page for non-active tab rather than just updating the results. Alternate options would be moving to Turbo Streams or Stimulus Controllers but this was easy and we don't get a ton of value in the tabs being partial loads. https: //mitlibraries.atlassian.net/browse/USE-575 https: //mitlibraries.atlassian.net/browse/USE-594 Co-Authored-By: djanelle-mit <181018533+djanelle-mit@users.noreply.github.com>
1 parent 2574c1f commit 4e4a972

8 files changed

Lines changed: 58 additions & 13 deletions

File tree

app/assets/stylesheets/partials/_results.scss

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,7 @@
408408
.results-context {
409409
padding-left: 0;
410410
margin-top: 0;
411-
margin-bottom: 4px;
412-
}
413-
414-
.results-context-description {
415-
color: $color-text-secondary;
416-
margin-bottom: 12px;
411+
margin-bottom: 24px;
417412
}
418413

419414
#results-section {
@@ -596,4 +591,33 @@ aside.nls-alert {
596591
}
597592
}
598593
}
599-
}
594+
}
595+
596+
// RESULTS LIST NLS ALERT
597+
aside.nls-alert {
598+
margin-bottom: 40px;
599+
display: flex;
600+
gap: 6px;
601+
602+
i {
603+
color: $color-magenta-500;
604+
margin-top: 2px;
605+
}
606+
607+
p {
608+
font-weight: $fw-medium;
609+
line-height: 1.35;
610+
611+
a {
612+
padding-left: 8px;
613+
font-weight: $fw-normal;
614+
font-size: 1.4rem;
615+
color: $color-text-secondary;
616+
text-decoration-color: $color-gray-300;
617+
618+
&:hover {
619+
text-decoration-color: $color-text-secondary;
620+
}
621+
}
622+
}
623+
}

app/assets/stylesheets/partials/_source_tabs.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
}
4747

4848
&.active {
49-
background-color: $color-white;
49+
background-color: $color-gray-25;
5050
color: $color-text-primary;
5151
text-decoration: none;
5252

@@ -104,4 +104,18 @@
104104
display: block;
105105
}
106106

107+
}
108+
109+
/* ============================== */
110+
/* Tab description bar below tabs */
111+
/* ============================== */
112+
div.tab-description {
113+
background-color: $color-gray-25;
114+
border-bottom: 1px solid $color-gray-200;
115+
color: $color-text-secondary;
116+
117+
.wrap-content {
118+
padding-top: 16px;
119+
padding-bottom: 16px;
120+
}
107121
}

app/assets/stylesheets/partials/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
// GRAY
8+
$color-gray-25: #FAFAFA;
89
$color-gray-100: #F2F2F2;
910
$color-gray-200: #e6e6e6;
1011
$color-gray-300: #ccc;

app/helpers/search_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def link_to_tab(target, label = nil)
4242
link_to tab_label, results_path(params.permit(:q, :per_page, :booleanType, :tab, :queryMode).merge(tab: clean_target)),
4343
class: 'tab-link',
4444
role: 'button',
45-
data: { turbo_frame: 'search-results', turbo_action: 'advance' }
45+
data: { turbo_frame: '_top', turbo_action: 'advance' }
4646
end
4747
end
4848

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="tab-description">
2+
<div class="wrap-content">
3+
<%= tab_description %>
4+
</div>
5+
</div>

app/views/layouts/application.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<%= render partial: "layouts/site_header" %>
1414

1515
<div class="wrap-outer-content layout-band">
16+
17+
<%= render partial: "layouts/tab_description" %>
18+
1619
<div class="wrap-content">
1720
<%= render partial: "layouts/flash" %>
1821

app/views/search/results.html.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<% content_for :additional_meta_tag do %>
44
<meta name="robots" content="noindex, nofollow">
55
<% end %>
6-
76
<div id="content-wrapper" class="space-wrap">
87
<%= render(partial: 'shared/error', collection: @errors) %>
98

@@ -19,7 +18,6 @@
1918
<% elsif @results.present? && @errors.blank? %>
2019

2120
<h2 class="results-context" data-matomo-seen="Search, Results Found, Tab: {{getActiveTabName}}"><%= results_summary(@pagination[:hits]) %></h2>
22-
<p class="results-context-description"><%= tab_description %></p>
2321
<%= render partial: 'search/nls_alert' %>
2422
<div id="results-layout-wrapper">
2523
<main id="results">

test/controllers/search_controller_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,8 @@ def source_filter_count(controller)
871871
get '/results?q=test&tab=primo'
872872
assert_response :success
873873
assert_select '.results-context', text: /10 results/
874-
assert_select '.results-context-description', count: 1
875-
assert_select '.results-context-description',
874+
assert_select '.tab-description', count: 1
875+
assert_select '.tab-description .wrap-content',
876876
text: /Articles, books, chapters, streaming and physical media, and more/
877877
end
878878

0 commit comments

Comments
 (0)