Skip to content

Commit

Permalink
Merge pull request #3306 from projectblacklight/toggle-bookmark
Browse files Browse the repository at this point in the history
Disambiguate .toggle-bookmark
  • Loading branch information
jcoyne authored Oct 24, 2024
2 parents 87fe889 + add62d0 commit 1cebc26
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 46 deletions.
85 changes: 43 additions & 42 deletions app/assets/stylesheets/blacklight/_bookmark.scss
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
label.toggle-bookmark {
font-weight: inherit;
min-width: 8.5em;
}

div.toggle-bookmark {
cursor: pointer;
}

/* override for line 3.
Creates weird spacing in toolbar when min-width is set to 8rem */
.header-tools label.toggle-bookmark {
min-width: 2rem;
}

.bookmark-toggle {
.no-js & {
input[type="submit"] {
display: inline
}

div.toggle-bookmark {
display: none
}
}

input[type="submit"] {
display: none;
}
}
.toggle-bookmark .blacklight-icons svg {
height: 1.25rem;
width: 1.25rem;
overflow: visible;
fill: var(--bs-primary);
.no-js & {
input[type="submit"] {
display: inline;
}

.toggle-bookmark {
display: none;
}
}

&.bookmark-checked {
input[type="submit"] {
display: none;
}
}

.toggle-bookmark[type="checkbox"]:checked+span svg {
&.bookmark-checked {
display: inherit;
.toggle-bookmark {
cursor: pointer;

.toggle-bookmark-label {
font-weight: inherit;
min-width: 8.5em;

.blacklight-icons svg {
height: 1.25rem;
width: 1.25rem;
overflow: visible;
fill: var(--bs-primary);

&.bookmark-checked {
display: none;
}
}
}

.toggle-bookmark-input:checked + span svg {
&.bookmark-checked {
display: inherit;
}

&.bookmark-unchecked {
display: none;
}
}
}

&.bookmark-unchecked {
display: none;
/* override for line 21.
Creates weird spacing in toolbar when min-width is set to 8rem */
.header-tools .toggle-bookmark-label {
min-width: 2rem;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
absent: t('blacklight.search.bookmarks.absent'),
inprogress: t('blacklight.search.bookmarks.inprogress')
}) do %>
<div class="checkbox toggle-bookmark">
<label class="toggle-bookmark" data-checkboxsubmit-target="label">
<input type="checkbox" class="toggle-bookmark <%= bookmark_icon ? 'd-none' : '' %>" data-checkboxsubmit-target="checkbox" <%= 'checked="checked"' if bookmarked? %>>
<div class="toggle-bookmark">
<label class="toggle-bookmark-label" data-checkboxsubmit-target="label">
<input type="checkbox" class="toggle-bookmark-input <%= bookmark_icon ? 'd-none' : '' %>" data-checkboxsubmit-target="checkbox" <%= 'checked="checked"' if bookmarked? %>>
<%= bookmark_icon %>
<span data-checkboxsubmit-target="span"><%= bookmarked? ? t('blacklight.search.bookmarks.present') : t('blacklight.search.bookmarks.absent') %></span>
</label>
Expand Down
2 changes: 1 addition & 1 deletion spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
expect(page).to have_css('.blacklight-icons-bookmark')
find('.blacklight-icons-bookmark').click

expect(find('.toggle-bookmark[type="checkbox"]', visible: false)).to be_checked
expect(find('.toggle-bookmark-input', visible: false)).to be_checked
find('.blacklight-icons-bookmark').click
end
end
Expand Down

0 comments on commit 1cebc26

Please sign in to comment.