Skip to content

Commit 1bdefa4

Browse files
committed
Add scroll, highlight to check nearby libraries
Clicking the check nearby libraries header in the read button will smoothly scroll the user to the check nearby libraries panel and highlight it with a border animation. See PR 7125 for similar implementation with star ratings.
1 parent ce6e10a commit 1bdefa4

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

openlibrary/macros/ReadButton.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</a>
5555
</li>
5656
<li>
57-
<a class="cta-btn cta-btn--available cta-btn--w-icon">
57+
<a class="cta-btn cta-btn--available cta-btn--w-icon" onclick="location.href='#bookLocateSection';">
5858
<span class="btn-icon map"></span>
5959
<span class="btn-label">Check Nearby Libraries</span>
6060
</a>

openlibrary/macros/databarWork.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h3 class="header">
6666
</div>
6767

6868
<div class="panel desktop-vendor">
69-
<div class="btn-notice">
69+
<div id="bookLocateSection" class="btn-notice book-locate-panel">
7070
$:worldcat_links
7171

7272
<div class="cta-section">

static/css/components/generic-dropper.less

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
background-position: center;
115115
}
116116

117-
118117
.cta-dropper {
119118
display: flex;
120119
margin-bottom: 10px;

static/css/components/read-panel.less

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,34 @@
182182
.cta-button-group.desktop {
183183
display: flex;
184184
}
185+
// scroll margin and animation when clicking "Check Nearby Libraries" in
186+
// read button dropper
187+
html {
188+
scroll-behavior: smooth;
189+
}
190+
.book-locate-panel {
191+
scroll-margin-top: 100px;
192+
-webkit-transition: all 1s linear;
193+
position: sticky;
194+
top: 0;
195+
}
196+
@keyframes highlight {
197+
0% {
198+
border: 1px solid transparent;
199+
box-shadow: 0 0 10px transparent;
200+
}
201+
50% {
202+
border: 1px solid @link-blue;
203+
box-shadow: 0 0 10px @link-blue;
204+
}
205+
100% {
206+
border: 1px solid transparent;
207+
box-shadow: 0 0 10px transparent;
208+
}
209+
}
210+
.book-locate-panel:target {
211+
animation: highlight 3s;
212+
}
185213
/* stylelint-enable selector-max-specificity */
186214
}
187215

0 commit comments

Comments
 (0)