|
| 1 | +import { component$ } from '@builder.io/qwik'; |
| 2 | +import { ProductCard } from '../ProductCard'; |
| 3 | + |
| 4 | +type ProductSliderProps = { |
| 5 | + products: { |
| 6 | + id: string; |
| 7 | + slug: string; |
| 8 | + name: string; |
| 9 | + sku: string; |
| 10 | + rating: { average: number; count: number }; |
| 11 | + price: { |
| 12 | + isDiscounted: boolean; |
| 13 | + regularPrice: { |
| 14 | + currency: string; |
| 15 | + amount: number; |
| 16 | + precisionAmount: string; |
| 17 | + }; |
| 18 | + value: { currency: string; amount: number; precisionAmount: string }; |
| 19 | + }; |
| 20 | + primaryImage: { |
| 21 | + alt: string; |
| 22 | + url: string; |
| 23 | + }; |
| 24 | + description?: string; |
| 25 | + }[]; |
| 26 | + class?: string; |
| 27 | +}; |
| 28 | + |
| 29 | +export const ProductSlider = component$<ProductSliderProps>(({ products }) => { |
| 30 | + // <SfScrollable |
| 31 | + // buttonsPlacement="floating" |
| 32 | + // className="items-center pb-4" |
| 33 | + // {...attributes} |
| 34 | + // wrapperClassName={className} |
| 35 | + // > |
| 36 | + |
| 37 | + return ( |
| 38 | + <div class='items-center relative flex max-w-screen-3xl mx-auto px-4 md:px-10 mb-20'> |
| 39 | + <button |
| 40 | + type='button' |
| 41 | + class='inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-4 gap-3 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 ring-1 ring-primary-700 hover:shadow-md active:shadow shadow hover:ring-primary-800 active:ring-primary-900 disabled:ring-1 disabled:ring-disabled-300 disabled:bg-white/50 hidden md:block !ring-neutral-500 !text-neutral-500 disabled:!ring-disabled-300 disabled:!text-disabled-500 !rounded-full bg-white absolute left-4 z-10' |
| 42 | + data-testid='button' |
| 43 | + > |
| 44 | + <svg |
| 45 | + viewBox='0 0 24 24' |
| 46 | + data-testid='chevron-left' |
| 47 | + xmlns='http://www.w3.org/2000/svg' |
| 48 | + class='inline-block fill-current w-6 h-6 undefined' |
| 49 | + > |
| 50 | + <path d='M14.706 17.297a.998.998 0 0 0 0-1.41l-3.876-3.885 3.877-3.885a.998.998 0 0 0-1.412-1.41l-4.588 4.588a1 1 0 0 0 0 1.414l4.588 4.588a.997.997 0 0 0 1.41 0Z'></path> |
| 51 | + </svg> |
| 52 | + </button> |
| 53 | + <div class='items-center pb-4 motion-safe:scroll-smooth overflow-x-auto flex gap-4'> |
| 54 | + {products.map( |
| 55 | + ({ id, name, description, rating, price, primaryImage, slug }) => ( |
| 56 | + <ProductCard |
| 57 | + key={id} |
| 58 | + class='max-w-[192px]' |
| 59 | + name={name} |
| 60 | + description={description} |
| 61 | + ratingCount={rating.count} |
| 62 | + rating={rating.average} |
| 63 | + price={price.value.amount} |
| 64 | + imageUrl={primaryImage.url} |
| 65 | + imageAlt={primaryImage.alt} |
| 66 | + slug={slug} |
| 67 | + /> |
| 68 | + ) |
| 69 | + )} |
| 70 | + </div> |
| 71 | + <button |
| 72 | + type='button' |
| 73 | + class='inline-flex items-center justify-center font-medium text-base focus-visible:outline focus-visible:outline-offset rounded-md disabled:text-disabled-500 disabled:bg-disabled-300 disabled:shadow-none disabled:ring-0 disabled:cursor-not-allowed p-4 gap-3 text-primary-700 hover:bg-primary-100 hover:text-primary-800 active:bg-primary-200 active:text-primary-900 ring-1 ring-primary-700 hover:shadow-md active:shadow shadow hover:ring-primary-800 active:ring-primary-900 disabled:ring-1 disabled:ring-disabled-300 disabled:bg-white/50 hidden md:block !ring-neutral-500 !text-neutral-500 disabled:!ring-disabled-300 disabled:!text-disabled-500 !rounded-full bg-white absolute right-4 z-10' |
| 74 | + data-testid='button' |
| 75 | + > |
| 76 | + <svg |
| 77 | + viewBox='0 0 24 24' |
| 78 | + data-testid='chevron-right' |
| 79 | + xmlns='http://www.w3.org/2000/svg' |
| 80 | + class='inline-block fill-current w-6 h-6 undefined' |
| 81 | + > |
| 82 | + <path d='M8.705 17.297a.998.998 0 0 1-.001-1.41l3.876-3.885-3.876-3.885a.998.998 0 0 1 1.412-1.41l4.587 4.588a1 1 0 0 1 0 1.414l-4.587 4.588a.997.997 0 0 1-1.411 0Z'></path> |
| 83 | + </svg> |
| 84 | + </button> |
| 85 | + </div> |
| 86 | + ); |
| 87 | +}); |
0 commit comments