Skip to content

Commit

Permalink
feat(ExportButtons): add book icon to Buy Print Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeaturner committed Feb 14, 2025
1 parent a18ac95 commit 5f3e215
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions public/ExportButtons/libreExportButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (!(navigator.webdriver || window.matchMedia('print').matches) && !LibreTexts?
const CLASS_BUTTON_ICON_TEXT = 'libre-icon-btn-text';
const CLASS_DROPDOWN_OPEN_STATE = 'dropdown-open';
const CLASS_DONORBOX_LINK = 'libretexts-dbox-popup';
const CLASS_BUY_PRINT_COPY_BTN = 'libre-buy-print-copy-btn';

let currentCoverpage = null;
let currentSubdomain = null;
Expand Down Expand Up @@ -660,7 +661,7 @@ if (!(navigator.webdriver || window.matchMedia('print').matches) && !LibreTexts?
{
key: 'bookstore',
text: 'Buy Print Copy',
title: 'Buy Paper Copy (opens in new tab)',
title: 'Buy Print Copy (opens in new tab)',
href: bookstoreURL,
icon: 'mt-icon-book2',
}
Expand Down Expand Up @@ -705,8 +706,21 @@ if (!(navigator.webdriver || window.matchMedia('print').matches) && !LibreTexts?
type: 'button',
tabIndex: 0,
});
buyPrintCopyButton.classList.add(CLASS_DROPDOWN_BTN);
buyPrintCopyButton.appendChild(document.createTextNode('Buy Print Copy'));

buyPrintCopyButton.classList.add(CLASS_BUY_PRINT_COPY_BTN);

// Create the span element for the icon
const iconSpan = document.createElement('span');
iconSpan.classList.add('mt-icon-book2'); // Add the icon class
iconSpan.setAttribute('aria-hidden', 'true');

// Create the text node
const buttonText = document.createTextNode(' Buy Print Copy'); // Space for separation

// Append icon and text to the button
buyPrintCopyButton.appendChild(iconSpan);
buyPrintCopyButton.appendChild(buttonText);

buyPrintCopyButton.addEventListener('click', (e) => {
e.preventDefault();
window.open(bookstoreURL, '_blank', 'noreferrer');
Expand Down Expand Up @@ -1022,6 +1036,10 @@ if (!(navigator.webdriver || window.matchMedia('print').matches) && !LibreTexts?
#${ID_CONDUCTOR_PROJECT_BTN}:focus {
border: 3px solid #30B3F6 !important;
}
.${CLASS_BUY_PRINT_COPY_BTN} {
background-color: #57116A !important;
${commonButtonStyles}
}
</style>
`);

Expand Down
Loading

0 comments on commit 5f3e215

Please sign in to comment.