diff --git a/completed-components/exercise-3-html/ProductBuyBoxVariantSelector.tsx b/completed-components/exercise-3-html/ProductBuyBoxVariantSelector.tsx index 4d42dd0..590243a 100644 --- a/completed-components/exercise-3-html/ProductBuyBoxVariantSelector.tsx +++ b/completed-components/exercise-3-html/ProductBuyBoxVariantSelector.tsx @@ -4,10 +4,10 @@ const ProductBuyBoxVariantSelector = ({ Product }) => { const [selectedSize, selectSize] = useState(null); return (
-

- Color: +
+

Color:

{selectedColor} -

+
{Product.colors.map((color, index) => (
-

-

Size:

-

+
+

Size:

+
{Product && Product.sizes.length === 1 && ( diff --git a/completed-components/exercise-3-html/ProductDetails.tsx b/completed-components/exercise-3-html/ProductDetails.tsx index f7131c7..64a95ab 100644 --- a/completed-components/exercise-3-html/ProductDetails.tsx +++ b/completed-components/exercise-3-html/ProductDetails.tsx @@ -44,10 +44,11 @@ const ProductDetails = ({ product, onAddToCart }: ProductDetailsProps) => {
+

Reviews

{hasReviews && ( <> - {product.overallRating} + {product.overallRating}
@@ -69,22 +70,22 @@ const ProductDetails = ({ product, onAddToCart }: ProductDetailsProps) => {
-

Price:

+

Price

{product.price}
- +
-

Quantity:

+

Quantity

setProductCount(parseInt(event.target.value))} role="spinbutton" @@ -128,14 +129,14 @@ const ProductDetails = ({ product, onAddToCart }: ProductDetailsProps) => {
- -
+
Add to Wishlist - +
); diff --git a/completed-components/exercise-3-html/ProductHeader.tsx b/completed-components/exercise-3-html/ProductHeader.tsx index 85df79b..84c4eca 100644 --- a/completed-components/exercise-3-html/ProductHeader.tsx +++ b/completed-components/exercise-3-html/ProductHeader.tsx @@ -18,12 +18,13 @@ const Banner = ({ shouldAnimate = false }: BannerProps) => { } }; const incrementSlide = () => { - if (currentSlideNum <= slideCount) { + if (currentSlideNum < slideCount) { changeSlideNum(currentSlideNum + 1); } else { changeSlideNum(1); } }; + const setInert = (node, slideNumber) => { // workaround for React not recognizing inert // https://github.com/facebook/react/pull/24730 @@ -31,28 +32,43 @@ const Banner = ({ shouldAnimate = false }: BannerProps) => { node && (currentSlideNum === slideNumber ? node.removeAttribute('inert', '') : node.setAttribute('inert', '')) ); }; + useEffect(() => { updateSlidePercentage(((currentSlideNum - 1) / 3) * 100); }, [currentSlideNum]); + + async function animate() { + incrementSlide(); + } + + useEffect(() => { + if (shouldAnimate) animate(); + }, []); + + if (shouldAnimate) { + setTimeout(() => { + animate(); + }, 3000); + } + return (