Skip to content

Commit

Permalink
Update toolkit for Paper v7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJulik committed Jun 7, 2024
1 parent 13bc41d commit 7b153cd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/css/base/typography.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
@apply animation-500 underline-offset-1 underline;

&:hover {
@apply underline opacity-50;
@apply underline md:opacity-50;
}

&:focus-visible {
Expand Down
39 changes: 35 additions & 4 deletions src/ts/products/products.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const products = {

// Update page when variant selection changes
handleProductFormChange (
enableUrlParameters: boolean,
Expand Down Expand Up @@ -37,6 +37,40 @@ export const products = {

},

// If using combined listing this loads and sets title, description and images switching between products
async handleCombinedListing (
productURL: string,
sectionId: string
) {

// load product section with Section Render API
try {
const response = await fetch(
`${productURL}?section_id=${sectionId}`
);

// If response is not OK, throw an error
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
// Catpure data from fetch
const responseHtml = await response.text();
const html = new DOMParser().parseFromString(responseHtml, 'text/html');

// inject new html
const oldSection = document.querySelector('.js-product')
if(oldSection) {
const newSection = html.querySelector('.js-product');
oldSection.parentNode!.insertBefore(newSection!, oldSection);
oldSection.remove();
}
}

catch (error) {
console.error(error);
}
},

// Find options that are not available based on selected options
setUnavailableOptions() {

Expand Down Expand Up @@ -291,9 +325,6 @@ export const products = {
(optionsSize === 1 && this.option1) ||
(optionsSize === 2 && this.option1 && this.option2) ||
(optionsSize === 3 && this.option1 && this.option2 && this.option3);
if(optionsSize === 1) {
this.all_options_selected = true;
}
},

// Update order of product gallery images
Expand Down

0 comments on commit 7b153cd

Please sign in to comment.