From 64b568cfaf152b948f7b2fd0339aeff6da07b7dd Mon Sep 17 00:00:00 2001 From: Daniel O'Kane Date: Mon, 4 Nov 2024 17:35:08 -0500 Subject: [PATCH] WIP on bugfix/PM-637-ca-pet-tags --- blocks/pet-tags/pet-tags.css | 22 +++++++++ blocks/pet-tags/pet-tags.js | 92 ++++++++++++++++++++++-------------- 2 files changed, 78 insertions(+), 36 deletions(-) diff --git a/blocks/pet-tags/pet-tags.css b/blocks/pet-tags/pet-tags.css index 9cc57bac..07e670ac 100644 --- a/blocks/pet-tags/pet-tags.css +++ b/blocks/pet-tags/pet-tags.css @@ -101,6 +101,28 @@ form[id^="pet-tags-"] .radio-wrapper>input[type="radio"]:checked+label img { border: 0.25rem solid var(--button-secondary-color); } +form[id^="pet-tags-"] .col1 a:any-link { + font-family: var(--body-font-family); + display: block; + box-sizing: border-box; + text-decoration: none; + border: 2px solid transparent; + padding: 0.875rem 1.625rem; + text-align: center; + font-size: 1rem; + font-style: normal; + font-weight: 600; + cursor: pointer; + color: var(--background-color); + background-color: var(--button-primary-color); + margin: 6px auto; + width: 80%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + border-radius: 0.625rem; +} + @media screen and (width >=768px) { form[id^="pet-tags-"] .grid-wrapper-x4 { grid-template-columns: repeat(4, 1fr); diff --git a/blocks/pet-tags/pet-tags.js b/blocks/pet-tags/pet-tags.js index 92c9597b..bc958ab8 100644 --- a/blocks/pet-tags/pet-tags.js +++ b/blocks/pet-tags/pet-tags.js @@ -1,13 +1,7 @@ import { jsx } from '../../scripts/scripts.js'; -// link to the 24PetWatch website to buy pet tags -const buyNowLink = 'https://www.24petwatch.com/ca/lost-pet-protection/pet-tags/tag-quote'; // path to the images for pet tags const imagePath = '/images/tags/'; -// prices for pet tags -const pricePerTagMetal = 19.95; -const pricePerTagLifetimeSmall = 19.95; -const pricePerTagLifetimeLarge = 19.95; function updateTagImage() { // lifetime tags @@ -31,31 +25,67 @@ function updateTagImage() { } export default async function decorate(block) { + const blockMetadata = {}; + + // eslint-disable-next-line no-restricted-syntax + for (const row of block.children) { + let key = row.children[0].textContent; + + key = key.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, (match, index) => { + if (+match === 0) return ''; + return index === 0 ? match.toLowerCase() : match.toUpperCase(); + }); + + const value = row.children[1].innerHTML; + if (key) { + blockMetadata[key] = value; + } + } + + const { + primaryTagHeaderTitle, + primaryTagHeaderContent1Top, + primaryTagHeaderContent1Bottom, + primaryTagHeaderContent2Top, + primaryTagHeaderContent2Bottom, + primaryTagCTA, + primaryTagColumn2Title, + primaryTagColumn3Title, + primaryTagColumn4Title, + primaryTagColumn4Description, + secondaryTagHeaderTitle, + secondaryTagHeaderContent1Top, + secondaryTagHeaderContent1Bottom, + secondaryTagCTA, + secondaryTagColumn2Title, + secondaryTagColumn3Title, + secondaryTagColumn4Title, + secondaryTagColumn4Description, + } = blockMetadata; + block.innerHTML = jsx`
-

Lifetime Warranty ID Tags

+

${primaryTagHeaderTitle}

-

Small: $${pricePerTagLifetimeSmall}

-

(plus shipping)

+

${primaryTagHeaderContent1Top}

+

${primaryTagHeaderContent1Bottom}

-

Large: $${pricePerTagLifetimeLarge}

-

(plus shipping)

+

${primaryTagHeaderContent2Top}

+

${primaryTagHeaderContent2Bottom}

traditional bone lifetime tag - - - + ${primaryTagCTA}
-
Choose from 2 prints:
+
${primaryTagColumn2Title}
@@ -74,7 +104,7 @@ export default async function decorate(block) {
-
Choose from 2 shapes:
+
${primaryTagColumn3Title}
@@ -93,13 +123,8 @@ export default async function decorate(block) {
-
Key features:
-
    -
  • Made of steel with a special coating for a porcelain look and feel
  • -
  • Lifetime warranty if the tag is damaged or unreadable (not if it's lost)
  • -
  • Long lasting and durable
  • -
  • Includes your pet's name and unique microchip number
  • -
+
${primaryTagColumn4Title}
+ ${primaryTagColumn4Description}
@@ -107,22 +132,20 @@ export default async function decorate(block) {
-

Standard Metal ID Tags

+

${secondaryTagHeaderTitle}

-

$${pricePerTagMetal}

-

(plus shipping)

+

${secondaryTagHeaderContent1Top}

+

${secondaryTagHeaderContent1Bottom}

teal heart metal tag - - - + ${secondaryTagCTA}
-
Choose from 3 colors:
+
${secondaryTagColumn2Title}
@@ -148,7 +171,7 @@ export default async function decorate(block) {
-
Choose from 2 shapes:
+
${secondaryTagColumn3Title}
@@ -167,11 +190,8 @@ export default async function decorate(block) {
-
Key features:
-
    -
  • Long lasting and durable
  • -
  • Includes your pet's name and unique microchip number
  • -
+
${secondaryTagColumn4Title}
+ ${secondaryTagColumn4Description}