Skip to content

Commit bb30778

Browse files
committed
Improving Private button design
1 parent e5b03c5 commit bb30778

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

openlibrary/i18n/messages.pot

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ msgstr ""
296296
msgid "UnfollowFollow"
297297
msgstr ""
298298

299-
#: Follow.html
299+
#: Follow.html lists/list_follow.html
300300
msgid "Follow"
301301
msgstr ""
302302

@@ -6301,7 +6301,11 @@ msgid "You"
63016301
msgstr ""
63026302

63036303
#: lists/list_follow.html
6304-
msgid "Private"
6304+
msgid "This patron has not enabled following"
6305+
msgstr ""
6306+
6307+
#: lists/list_follow.html
6308+
msgid "🔒︎"
63056309
msgstr ""
63066310

63076311
#: lists/list_follow.html

openlibrary/plugins/openlibrary/js/book-page-lists.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export function initListsSection(elem) {
2020
fetchPartials(ids.work, ids.edition)
2121
.then((resp) => {
2222
// Check response code, continue if not 4XX or 5XX
23-
2423
return resp.json()
2524
})
2625
.then((data) => {
@@ -43,6 +42,8 @@ export function initListsSection(elem) {
4342
showAllLink.classList.remove('hidden')
4443
}
4544
}
45+
// Initialize private buttons after content is loaded
46+
initPrivateButtonsAfterLoad(listSection)
4647
})
4748
}
4849
})
@@ -55,6 +56,20 @@ export function initListsSection(elem) {
5556
intersectionObserver.observe(elem)
5657
}
5758

59+
/**
60+
* Initialize private buttons after the lists section has been loaded
61+
* @param {HTMLElement} container - The container that now has the loaded content
62+
*/
63+
function initPrivateButtonsAfterLoad(container) {
64+
const privateButtons = container.querySelectorAll('.list-follow-card__private-button')
65+
if (privateButtons.length > 0) {
66+
import(/* webpackChunkName: "private-buttons" */ './private-button')
67+
.then(module => {
68+
module.initPrivateButtons(privateButtons)
69+
})
70+
}
71+
}
72+
5873
async function fetchPartials(workId, editionId) {
5974
const params = {}
6075
if (workId) {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { FadingToast } from './Toast'
2+
3+
export function initPrivateButtons(buttons) {
4+
buttons.forEach(button => {
5+
button.addEventListener('click', (event) => {
6+
event.preventDefault();
7+
const toast = new FadingToast('This patron has not enabled following', null, 3000);
8+
toast.show();
9+
10+
});
11+
});
12+
}

openlibrary/templates/lists/list_follow.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@
5353
$if is_public:
5454
$:render_follow_button(owner_username, is_subscribed)
5555
$else:
56-
<button class="list-follow-card__private-button" disabled>
57-
<span class="pvt-text">$_('Private')</span>
58-
</button>
56+
<div title="$_('This patron has not enabled following')">
57+
<button class="list-follow-card__private-button" >
58+
<span class="pvt-icon">$_('🔒︎')</span>
59+
<span class="pvt-text">$_('Follow')</span>
60+
</button>
61+
</div>
5962
</div>
6063
</div>
6164
$else:

static/css/components/list-follow.less

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
background-color: @grey;
132132
border: none;
133133
cursor: not-allowed;
134-
pointer-events: none;
134+
pointer-events: auto;
135135
display: flex;
136136
justify-content: center;
137137
align-items: center;
@@ -144,6 +144,11 @@
144144
box-shadow: none; // Remove default shadow if present
145145
margin: 0;
146146
letter-spacing: 0.2px;
147+
margin-top: 1px;
148+
}
149+
.pvt-icon {
150+
color: @white;
151+
font-size: 14px;
147152
}
148153
}
149154
&__title {

0 commit comments

Comments
 (0)