Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement custom digital contents icon, tooltip, and alert #613

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/palette.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ $stanford-stone-light: #D4D1D1;
$cyan-blue-light: #f8f9fa;
$gray-light: #fafafa;
$grey-lighter: #ededed;
$green-white: #EBF5F1;
41 changes: 39 additions & 2 deletions app/assets/stylesheets/sulCollection.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}

.al-show-actions-box {
background-color: #EBF5F1;
background-color: $green-white;
}

.al-collection-context-actions .btn-sm {
Expand Down Expand Up @@ -104,7 +104,7 @@
}

.al-hierarchy-highlight > .documentHeader {
background-color: #EBF5F1;
background-color: $green-white;
}

#sidebar {
Expand Down Expand Up @@ -190,3 +190,40 @@ a.btn-outline-secondary:focus {
.page-item.disabled .page-link {
color: black;
}

.al-online-content-icon {
align-content: center;
}

// Digital contents icons, alerts
// AL Core overrides
article.document .al-online-content-icon .blacklight-icons svg,
.online-contents .al-online-content-icon .blacklight-icons svg {
fill: $stanford-palo-alto-light;
}

.tooltip-inner {
background-color: $stanford-palo-alto-light;
color: white;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
border-top-color: $stanford-palo-alto-light;
}

.title-container .online-contents h2 {
text-transform: none;
margin-bottom: 0;
align-content: center;
margin-left: 1rem;
}

.online-contents.card {
border: 0;
background-color: $green-white;
padding: 0;
.card-body {
padding: 0.25rem 0.25rem 0.25rem 1rem;
border-left: 8px solid $stanford-palo-alto-dark;
}
}
16 changes: 16 additions & 0 deletions app/components/arclight/online_content_filter_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%# Overrides AL Core to use custom icon/tooltip and layout %>
<div class="card online-contents">
<div class="card-body d-flex align-items-center">
<div class="d-flex">
<%= render Arclight::OnlineStatusIndicatorComponent.new(document: @document) %>
<h2 class="d-none d-lg-inline">
<span class="visually-hidden">Filter</span>
Digital content -
</h2>
</div>
<div class="ms-1">
<%= t('arclight.views.show.online_content.description') %>
<%= link_to t('arclight.views.show.online_content.link_text'), helpers.search_action_path(f: { collection: [collection_name], access: ['online'] }) %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= icon_with_tooltip %>
25 changes: 25 additions & 0 deletions app/components/arclight/online_status_indicator_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# Overrides Arclight's OnlineStatusIndicatorComponent to replace with a custom template that includes our tooltip
module Arclight
# Render an online status indicator for a document
class OnlineStatusIndicatorComponent < Blacklight::Component
def initialize(document:, **)
@document = document
super
end

def render?
@document.online_content?
end

def icon_with_tooltip
icon = <<~HTML
<span class="al-online-content-icon" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="Includes digital content">
#{helpers.blacklight_icon(:online)}
</span>
HTML
icon.html_safe # rubocop:disable Rails/OutputSafety
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%# This file overrides AL Core for more control over the extents display %>
<%# This file overrides AL Core for more control over the extents display
and to add the digital content icon %>
<header class="documentHeader row" data-document-id="<%= @document.id %>">
<h3 class="index_title document-title-heading col">
<%= helpers.link_to_document @document, counter: @counter %>
Expand All @@ -10,10 +11,14 @@
<div class="d-flex">
<% @document.extent.each do |extent| %>
<%= tag.span extent, class: 'al-document-extent badge mx-1' unless compact? %>
<% end %>
<% end %>
<%= render Arclight::OnlineStatusIndicatorComponent.new(document: @document) %>

</div>

</h3>

<%# these are set in the catalog_controller by add_results_document_tool %>
<% actions.each do |action| %>
<%= action %>
<% end %>
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class CatalogController < ApplicationController

config.header_component = Arclight::HeaderComponent
config.logo_link = 'https://library.stanford.edu'
config.add_results_document_tool(:online, component: Arclight::OnlineStatusIndicatorComponent)
# add_results_document_tool effectively creates an Blacklight action
# Then actions are interated over in search_results_document_component.html.erb
# See https://github.com/projectblacklight/blacklight/blob/6c6a72066a6330a815603e839b316958f6321dd7/lib/blacklight/configuration.rb#L560
config.add_results_document_tool(:arclight_bookmark_control, component: Arclight::BookmarkComponent)

config.add_results_collection_tool(:group_toggle)
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ import bootstrap from "bootstrap"
import githubAutoCompleteElement from "@github/auto-complete-element"
import Blacklight from "blacklight"

import "arclight"
import "arclight"

Blacklight.onLoad(() => {
// Initialize Bootstrap tooltips
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
})