From 5107d3cd6802eafa77aa2a98a4939a474369c009 Mon Sep 17 00:00:00 2001 From: "Carlos A. Cabrera" <316104+fnhipster@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:40:14 -0600 Subject: [PATCH] PDP Containers (#135) * PDP containers * merge * fix * fixed height in overlay * bump * layout * promsie all * fixes * Promise.all * testin w/o promise all * Revert "testin w/o promise all" This reverts commit b3d8faa21a6c2d22f812704e8546eb32922fe827. * update * Update scripts.js * Update product-details.js * test: disable placeholders * Update scripts.js * Update product-details.js * placeholders * moved to variable * settings needs to be set once * Update head.html * extra berak line * promtoe jsonldp * fixed linting issues * initialDat * initialization * set jsonld on lcp * fixes * fix lint * fixed selections * moved initializer * reverting * removed spaces * clean up * optionsUIDs * getOptionsUIDsFromUrl * promise * prefetch placeholders * preload * render concurrently * wip initializer poc * initialize cart globally * initialize globally * fixed loop redirect * pdp initializer * await * mountImmediately * bump * fixed lint issues * clean up * fix lint errors * fixed cypress tests * preloads * preloads * Update product-details.js * valid * Update package.json * updated PDP drop-in version * bug fixes * removed custom pdp * bump * load css first * pre-initialize pdp * preload product image * Update pdp.js * Update pdp.js * Update pdp.js --------- Co-authored-by: Daniela Neagu --- .eslintrc.js | 1 + blocks/product-details-custom/Icon.js | 43 -- .../ProductDetailsCarousel.js | 149 ----- .../ProductDetailsShimmer.js | 17 - .../ProductDetailsSidebar.js | 132 ---- .../product-details-custom.css | 562 ------------------ .../product-details-custom.js | 224 ------- blocks/product-details/product-details.css | 113 +++- blocks/product-details/product-details.js | 390 +++++++----- .../e2eTests/events/initiate-checkout.spec.js | 4 +- .../src/tests/e2eTests/events/recs.spec.js | 2 +- head.html | 11 +- package-lock.json | 378 +----------- package.json | 2 +- .../__mocks__/product-mocks.d.ts | 1 + scripts/__dropins__/storefront-pdp/api.js | 4 +- .../fetchProductData/fetchProductData.d.ts | 24 + .../api/fetchProductData/index.d.ts | 17 + .../getFetchedProductData.d.ts | 4 + .../api/getFetchedProductData/index.d.ts | 17 + .../getProductConfigurationValues.d.ts | 4 + .../getProductConfigurationValues/index.d.ts | 17 + .../api/getProductData/getProductData.d.ts | 5 +- .../getRefinedProduct/getRefinedProduct.d.ts | 2 +- .../__dropins__/storefront-pdp/api/index.d.ts | 6 + .../api/initialize/initialize.d.ts | 10 +- .../isProductConfigurationValid/index.d.ts | 17 + .../isProductConfigurationValid.d.ts | 17 + .../setProductConfigurationValid/index.d.ts | 17 + .../setProductConfigurationValid.d.ts | 17 + .../setProductConfigurationValues/index.d.ts | 17 + .../setProductConfigurationValues.d.ts | 4 + .../storefront-pdp/chunks/PriceRange.js | 3 + .../storefront-pdp/chunks/Swatches.js | 3 + .../__dropins__/storefront-pdp/chunks/Zoom.js | 3 + .../__dropins__/storefront-pdp/chunks/date.js | 3 + .../chunks/getFetchedProductData.js | 3 + .../chunks/getProductConfigurationValues.js | 3 + .../chunks/getRefinedProduct.js | 185 ------ .../storefront-pdp/chunks/initialize.js | 1 - .../chunks/isProductConfigurationValid.js | 187 ++++++ .../components/Header/Header.d.ts | 10 + .../components/Header/index.d.ts | 18 + .../components/Price/Price.d.ts | 9 + .../components/Price/index.d.ts | 18 + .../components/Swatches/Swatches.d.ts | 1 + .../storefront-pdp/components/index.d.ts | 2 + .../containers/ProductAttributes.d.ts | 3 + .../containers/ProductAttributes.js | 3 + .../ProductAttributes/ProductAttributes.d.ts | 8 + .../containers/ProductAttributes/index.d.ts | 18 + .../containers/ProductDescription.d.ts | 3 + .../containers/ProductDescription.js | 3 + .../ProductDescription.d.ts | 8 + .../containers/ProductDescription/index.d.ts | 18 + .../containers/ProductDetails.js | 4 +- .../ProductDetails/ProductDetails.d.ts | 1 + .../containers/ProductGallery.d.ts | 3 + .../containers/ProductGallery.js | 3 + .../ProductGallery/ProductGallery.d.ts | 18 + .../containers/ProductGallery/index.d.ts | 3 + .../containers/ProductHeader.d.ts | 3 + .../containers/ProductHeader.js | 3 + .../ProductHeader/ProductHeader.d.ts | 9 + .../containers/ProductHeader/index.d.ts | 18 + .../containers/ProductOptions.d.ts | 3 + .../containers/ProductOptions.js | 3 + .../ProductOptions/ProductOptions.d.ts | 22 + .../containers/ProductOptions/index.d.ts | 18 + .../containers/ProductPrice.d.ts | 3 + .../storefront-pdp/containers/ProductPrice.js | 3 + .../containers/ProductPrice/ProductPrice.d.ts | 8 + .../containers/ProductPrice/index.d.ts | 18 + .../containers/ProductQuantity.d.ts | 3 + .../containers/ProductQuantity.js | 3 + .../ProductQuantity/ProductQuantity.d.ts | 9 + .../containers/ProductQuantity/index.d.ts | 18 + .../containers/ProductShortDescription.d.ts | 3 + .../containers/ProductShortDescription.js | 3 + .../ProductShortDescription.d.ts | 8 + .../ProductShortDescription/index.d.ts | 18 + .../storefront-pdp/containers/index.d.ts | 8 + .../data/models/acdl-models.d.ts | 10 +- .../storefront-pdp/data/models/index.d.ts | 1 + .../data/models/product-model.d.ts | 19 +- .../data/models/values-model.d.ts | 6 + .../data/transforms/product-transform.d.ts | 4 +- .../storefront-pdp/i18n/en_US.json.d.ts | 3 + scripts/__dropins__/storefront-pdp/render.js | 6 +- scripts/commerce.js | 150 +---- scripts/initializers/pdp.js | 44 +- scripts/scripts.js | 32 +- 92 files changed, 1211 insertions(+), 2021 deletions(-) delete mode 100644 blocks/product-details-custom/Icon.js delete mode 100644 blocks/product-details-custom/ProductDetailsCarousel.js delete mode 100644 blocks/product-details-custom/ProductDetailsShimmer.js delete mode 100644 blocks/product-details-custom/ProductDetailsSidebar.js delete mode 100644 blocks/product-details-custom/product-details-custom.css delete mode 100644 blocks/product-details-custom/product-details-custom.js create mode 100644 scripts/__dropins__/storefront-pdp/api/fetchProductData/fetchProductData.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/fetchProductData/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/getFetchedProductData/getFetchedProductData.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/getFetchedProductData/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/getProductConfigurationValues.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/isProductConfigurationValid.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/setProductConfigurationValid.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/setProductConfigurationValues.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/chunks/PriceRange.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/Swatches.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/Zoom.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/date.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/getFetchedProductData.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/getProductConfigurationValues.js delete mode 100644 scripts/__dropins__/storefront-pdp/chunks/getRefinedProduct.js delete mode 100644 scripts/__dropins__/storefront-pdp/chunks/initialize.js create mode 100644 scripts/__dropins__/storefront-pdp/chunks/isProductConfigurationValid.js create mode 100644 scripts/__dropins__/storefront-pdp/components/Header/Header.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/components/Header/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/components/Price/Price.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/components/Price/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductAttributes.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductAttributes.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductAttributes/ProductAttributes.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductAttributes/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductDescription.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductDescription.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductDescription/ProductDescription.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductDescription/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductGallery.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductGallery.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductGallery/ProductGallery.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductGallery/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductHeader.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductHeader.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductHeader/ProductHeader.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductHeader/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductOptions.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductOptions.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductOptions/ProductOptions.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductOptions/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductPrice.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductPrice.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductPrice/ProductPrice.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductPrice/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductQuantity.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductQuantity.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductQuantity/ProductQuantity.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductQuantity/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductShortDescription.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductShortDescription.js create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductShortDescription/ProductShortDescription.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/containers/ProductShortDescription/index.d.ts create mode 100644 scripts/__dropins__/storefront-pdp/data/models/values-model.d.ts diff --git a/.eslintrc.js b/.eslintrc.js index b1f96769da..d8d2e468ad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,5 +21,6 @@ module.exports = { allow: ['warn', 'error', 'info', 'debug'], }, ], + 'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], }, }; diff --git a/blocks/product-details-custom/Icon.js b/blocks/product-details-custom/Icon.js deleted file mode 100644 index 4506b6a18c..0000000000 --- a/blocks/product-details-custom/Icon.js +++ /dev/null @@ -1,43 +0,0 @@ -import { - h, Component, Fragment, - // eslint-disable-next-line import/no-unresolved,import/extensions -} from '../../scripts/preact.js'; -// eslint-disable-next-line import/no-unresolved,import/extensions -import htm from '../../scripts/htm.js'; - -const html = htm.bind(h); - -export default class Icon extends Component { - constructor(props) { - super(); - - this.iconName = props.name; - } - - async componentDidMount() { - const resp = await fetch(`${window.hlx.codeBasePath}/icons/${this.iconName}.svg`); - if (resp.ok) { - const iconHTML = await resp.text(); - this.setState({ iconHTML }); - } - } - - render() { - if (!this.state.iconHTML) { - return null; - } - - if (this.state.iconHTML.match(/