From 7b1d634b6617ef2e0b1ab788dc1aa53bb60ce8b2 Mon Sep 17 00:00:00 2001 From: Oscar Arzola Date: Tue, 8 Nov 2022 11:30:43 -0500 Subject: [PATCH] feat: new frontend catalog (#369) --- assets/scripts/featured-books.js | 23 + assets/styles/aldine.scss | 1 + assets/styles/components/_featured_book.scss | 31 + assets/styles/layouts/_page-catalog.scss | 2 +- assets/styles/layouts/_page-home.scss | 2 +- dist/mix-manifest.json | 34 +- dist/scripts/aldine.js | 400 ++- dist/scripts/call-to-action.js | 33 +- dist/scripts/catalog-admin.js | 68 +- dist/scripts/customizer-toggle.js | 33 +- dist/scripts/customizer.js | 33 +- dist/scripts/page-section.js | 33 +- dist/styles/aldine.css | 2740 +++++++++++++++++- dist/styles/editor.css | 387 ++- functions.php | 1 + inc/customizer/namespace.php | 38 +- inc/helpers/namespace.php | 123 +- page-catalog.php | 4 +- partials/book.php | 28 +- partials/content-front-page.php | 51 +- partials/content-page-catalog.php | 2 +- partials/featured-book.php | 15 + 22 files changed, 4002 insertions(+), 80 deletions(-) create mode 100644 assets/scripts/featured-books.js create mode 100644 assets/styles/components/_featured_book.scss create mode 100644 partials/featured-book.php diff --git a/assets/scripts/featured-books.js b/assets/scripts/featured-books.js new file mode 100644 index 0000000..a463cf9 --- /dev/null +++ b/assets/scripts/featured-books.js @@ -0,0 +1,23 @@ +/** + * Disallow duplicate books in the featured books list. + */ +window.addEventListener( 'load', function () { + const selects = document.querySelectorAll( '#sub-accordion-section-pb_front_page_catalog select' ); + /** + * + * @param current + * @param value + */ + let checkOtherValues = function ( current, value ) { + selects.forEach( function ( select ) { + if ( current.id !== select.id && select.value === value ) { + select.selectedIndex = -1; + } + } ); + }; + selects.forEach( function ( select ) { + select.addEventListener( 'change', function ( event ) { + checkOtherValues( event.target, event.target.value ); + } ); + } ); +} ); diff --git a/assets/styles/aldine.scss b/assets/styles/aldine.scss index 0cbde1e..4ba9ec4 100644 --- a/assets/styles/aldine.scss +++ b/assets/styles/aldine.scss @@ -11,6 +11,7 @@ /** Import theme styles */ @import "common/global"; @import "components/book"; +@import "components/featured_book"; @import "components/forms"; @import "layouts/footer"; @import "layouts/header"; diff --git a/assets/styles/components/_featured_book.scss b/assets/styles/components/_featured_book.scss new file mode 100644 index 0000000..4b82fbf --- /dev/null +++ b/assets/styles/components/_featured_book.scss @@ -0,0 +1,31 @@ +.featured_book { + display: flex; + flex-direction: column; + justify-content: flex-start; + width: 100%; + max-width: 18rem; + height: 25rem; + border: solid 1px var(--accent); + margin: 0 0 2rem; + + &__cover { + width: 100%; + height: 80%; + background-repeat: no-repeat; + background-size: cover; + } + + a { + margin: 0; + text-decoration: none; + text-align: center; + hyphens: auto; + } + + &__title { + display: flex; + justify-content: center; + align-items: center; + font-weight: 500; + } +} diff --git a/assets/styles/layouts/_page-catalog.scss b/assets/styles/layouts/_page-catalog.scss index d908d73..54e44b2 100644 --- a/assets/styles/layouts/_page-catalog.scss +++ b/assets/styles/layouts/_page-catalog.scss @@ -128,7 +128,7 @@ margin: 2rem 0 1rem 1rem; } - .book { + .book, .featured_book { height: 14.375rem; width: calc(50% - 1rem); margin: 0 1rem 1rem 0; diff --git a/assets/styles/layouts/_page-home.scss b/assets/styles/layouts/_page-home.scss index 8bd4201..c745873 100644 --- a/assets/styles/layouts/_page-home.scss +++ b/assets/styles/layouts/_page-home.scss @@ -79,7 +79,7 @@ flex-direction: row; justify-content: center; - .book { + .book, .featured_book { margin-right: 1rem; margin-left: 1rem; } diff --git a/dist/mix-manifest.json b/dist/mix-manifest.json index 82437c9..851b8c2 100644 --- a/dist/mix-manifest.json +++ b/dist/mix-manifest.json @@ -1,19 +1,19 @@ { - "/scripts/aldine.js": "/scripts/aldine.js?id=3d34a35fb0f0f504be08e54784ab85be", - "/scripts/call-to-action.js": "/scripts/call-to-action.js?id=33370b66c7af12320fc0e1250f6be399", - "/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=2bc3bfa90831ab142ee9ebeb14ddab3c", - "/scripts/customizer.js": "/scripts/customizer.js?id=14dca3944228dd789c27c772d55bf471", - "/scripts/customizer-toggle.js": "/scripts/customizer-toggle.js?id=c31594589675d7c5662aaddcf7a9669a", - "/scripts/page-section.js": "/scripts/page-section.js?id=19d5c30146ea1a763bcf2bd733a75e77", - "/styles/editor.css": "/styles/editor.css?id=3fd7086e0f2bcacabc5152bf57ca90ca", - "/styles/aldine.css": "/styles/aldine.css?id=9c16e4ea9817fe0bd35a6b7222cd5736", - "/fonts/pressbooks-theme.woff": "/fonts/pressbooks-theme.woff?id=2a7aae81673f4707bbe78c8f12b72b64", - "/images/banner.jpg": "/images/banner.jpg?id=04a813e0b4f94ddfef1951557166e417", - "/images/catalog-header.jpg": "/images/catalog-header.jpg?id=223b9f7a23985f2a72df72e4e4a2ffdc", - "/images/header.jpg": "/images/header.jpg?id=c6712212b6aa749cf1cf1f077c679f9f", - "/images/left-arrow.svg": "/images/left-arrow.svg?id=91d479e2d001857a3ee46691c0187854", - "/images/logo.svg": "/images/logo.svg?id=d71cb98d33ef823ffd27b15ae07e723a", - "/images/pb.svg": "/images/pb.svg?id=c08fb158c15a470648a74591e1fc94a4", - "/images/right-arrow.svg": "/images/right-arrow.svg?id=ee2d7230318ea54ae20bd9d5fd96efd6", - "/images/yt_icon_mono_dark.png": "/images/yt_icon_mono_dark.png?id=ee68b73409979a92944025ae95a18011" + "/scripts/aldine.js": "/scripts/aldine.js", + "/scripts/call-to-action.js": "/scripts/call-to-action.js", + "/scripts/catalog-admin.js": "/scripts/catalog-admin.js", + "/scripts/customizer.js": "/scripts/customizer.js", + "/scripts/customizer-toggle.js": "/scripts/customizer-toggle.js", + "/scripts/page-section.js": "/scripts/page-section.js", + "/styles/editor.css": "/styles/editor.css", + "/styles/aldine.css": "/styles/aldine.css", + "/fonts/pressbooks-theme.woff": "/fonts/pressbooks-theme.woff", + "/images/banner.jpg": "/images/banner.jpg", + "/images/catalog-header.jpg": "/images/catalog-header.jpg", + "/images/header.jpg": "/images/header.jpg", + "/images/left-arrow.svg": "/images/left-arrow.svg", + "/images/logo.svg": "/images/logo.svg", + "/images/pb.svg": "/images/pb.svg", + "/images/right-arrow.svg": "/images/right-arrow.svg", + "/images/yt_icon_mono_dark.png": "/images/yt_icon_mono_dark.png" } diff --git a/dist/scripts/aldine.js b/dist/scripts/aldine.js index 55edf9d..659e95d 100644 --- a/dist/scripts/aldine.js +++ b/dist/scripts/aldine.js @@ -1,2 +1,398 @@ -/*! For license information please see aldine.js.LICENSE.txt */ -!function(){var t,e={256:function(t,e,n){"use strict";var i=n(755),r=n(391),o=n(831),s={init:function(){var t;t=document.querySelectorAll("fieldset h2"),Array.prototype.forEach.call(t,(function(t){t.innerHTML='\n\t\t\t\t\n\t\t\t ');var e=function(t){for(var e=[];t.nextElementSibling&&"H2"!==t.nextElementSibling.tagName;)e.push(t.nextElementSibling),t=t.nextElementSibling;return e.forEach((function(t){t.parentNode.removeChild(t)})),e}(t),n=document.createElement("div");n.hidden=!0,e.forEach((function(t){n.appendChild(t)})),t.parentNode.insertBefore(n,t.nextElementSibling);var i=t.querySelector("button");i.onclick=function(){var t="true"===i.getAttribute("aria-expanded")||!1;i.setAttribute("aria-expanded",!t),n.hidden=t}})),function(){var t=document.querySelectorAll("fieldset h3");Array.prototype.forEach.call(t,(function(t){t.innerHTML='\n\t\t\t\t\n\t\t\t ');var e=function(t){for(var e=[];t.nextElementSibling&&"H3"!==t.nextElementSibling.tagName;)e.push(t.nextElementSibling),t=t.nextElementSibling;return e.forEach((function(t){t.parentNode.removeChild(t)})),e}(t),n=document.createElement("div");n.hidden=!0,e.forEach((function(t){n.appendChild(t)})),t.parentNode.insertBefore(n,t.nextElementSibling);var i=t.querySelector("button");i.onclick=function(){var t="true"===i.getAttribute("aria-expanded")||!1;i.setAttribute("aria-expanded",!t),n.hidden=t}}))}(),i((function(t){o("isotope",r,t);var e=t(".books");e.isotope({itemSelector:".book",getSortData:{title:".book__title a",subject:"[data-subject]",latest:"[data-date-published]"},sortAscending:{title:!0,subject:!1,latest:!1}});var n=document.querySelector(".license-filters"),i=document.querySelector(".subject-filters"),s=document.querySelector(".institution-filters"),a=document.querySelector(".sorts"),u=document.querySelector(".clear-filters");u.hidden=!1,n.addEventListener("click",(function(t){if("radio"===t.target.type){var n=i.querySelector('input[type="radio"]:checked').value?'[data-subject="'.concat(i.querySelector('input[type="radio"]:checked').value,'"]'):"",r=s.querySelector('input[type="radio"]:checked').value?'[data-institution*="'.concat(s.querySelector('input[type="radio"]:checked').value,'"]'):"",o=t.target.value?'[data-license="'.concat(t.target.value,'"]'):"",a=n||o||r?"".concat(n).concat(o).concat(r):"*";e.isotope({filter:a})}})),s.addEventListener("click",(function(t){if("radio"===t.target.type){var r=i.querySelector('input[type="radio"]:checked').value?'[data-subject="'.concat(i.querySelector('input[type="radio"]:checked').value,'"]'):"",o=n.querySelector('input[type="radio"]:checked').value?'[data-license="'.concat(n.querySelector('input[type="radio"]:checked').value,'"]'):"",s=t.target.value?'[data-institution*="'.concat(t.target.value,'"]'):"",a=r||o||s?"".concat(r).concat(o).concat(s):"*";e.isotope({filter:a})}})),i.addEventListener("click",(function(t){if("radio"===t.target.type){var i=n.querySelector('input[type="radio"]:checked').value?'[data-license="'.concat(n.querySelector('input[type="radio"]:checked').value,'"]'):"",r=s.querySelector('input[type="radio"]:checked').value?'[data-institution*="'.concat(s.querySelector('input[type="radio"]:checked').value,'"]'):"",o=t.target.value?'[data-subject="'.concat(t.target.value,'"]'):"",a=o||i||r?"".concat(o).concat(i).concat(r):"*";e.isotope({filter:a})}})),u.addEventListener("click",(function(){var t=document.getElementById("all-licenses"),n=document.getElementById("all-subjects"),i=document.getElementById("all-institutions");t.checked=!0,n.checked=!0,i.checked=!0,e.isotope({filter:"*"})})),a.addEventListener("click",(function(t){"radio"===t.target.type&&e.isotope({sortBy:t.target.value})}))}))},finalize:function(){}},a=n(755),u={init:function(){document.body.classList.remove("no-js"),document.body.classList.add("js"),a((function(t){t(document).ready((function(){for(var e=document.getElementsByTagName("section"),n=0,i=e.length;n1&&void 0!==arguments[1]?arguments[1]:"init",n=arguments.length>2?arguments[2]:void 0,i=""!==t&&this.routes[t]&&"function"==typeof this.routes[t][e];i&&this.routes[t][e](n)}},{key:"loadEvents",value:function(){var t=this;this.fire("common"),document.body.className.toLowerCase().replace(/-/g,"_").split(/\s+/).map(l).forEach((function(e){t.fire(e),t.fire(e,"finalize")})),this.fire("common","finalize")}}],n&&c(e.prototype,n),i&&c(e,i),Object.defineProperty(e,"prototype",{writable:!1}),t}(),d=f,h=n(755),p=new d({common:u,home:{init:function(){},finalize:function(){}},pageTemplatePageCatalog:s});h(document).ready((function(){return p.loadEvents()}))},741:function(t,e,n){var i,r;!function(o,s){"use strict";void 0===(r="function"==typeof(i=s)?i.call(e,n,e,t):i)||(t.exports=r)}(window,(function(){"use strict";var t=function(){var t=window.Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],n=0;n