Skip to content

Commit

Permalink
Merge pull request #146 from deco-sites/feat/loading-fallback
Browse files Browse the repository at this point in the history
feat: loading skeletons
  • Loading branch information
tlgimenes authored Feb 19, 2024
2 parents 2abd9ca + 2244dab commit 0a3b63b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 6 deletions.
17 changes: 11 additions & 6 deletions components/product/ProductShelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useOffer } from "$store/sdk/useOffer.ts";
import { usePlatform } from "$store/sdk/usePlatform.tsx";
import type { Product } from "apps/commerce/types.ts";
import { mapProductToAnalyticsItem } from "apps/commerce/utils/productToAnalyticsItem.ts";
import { clx } from "$store/sdk/clx.ts";

export interface Props {
products: Product[] | null;
Expand Down Expand Up @@ -67,17 +68,21 @@ function ProductShelf({

<div
id={id}
class={`grid ${
layout?.showArrows ? "grid-cols-[48px_1fr_48px]" : ""
} px-0 md:px-5 container`}
class={clx(
"grid",
layout?.showArrows && "grid-cols-[48px_1fr_48px]",
"px-0 md:px-5 container",
)}
>
<Slider class="carousel carousel-center sm:carousel-end sm:gap-1 row-start-2 row-end-5">
{products?.map((product, index) => (
<Slider.Item
index={index}
class={`carousel-item ${
slideDesktop[layout?.numberOfSliders?.desktop ?? 3]
} ${slideMobile[layout?.numberOfSliders?.mobile ?? 1]}`}
class={clx(
"carousel-item",
slideDesktop[layout?.numberOfSliders?.desktop ?? 3],
slideMobile[layout?.numberOfSliders?.mobile ?? 1],
)}
>
<ProductCard
product={product}
Expand Down
11 changes: 11 additions & 0 deletions sections/Product/ImageGallerySlider.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export { default } from "../../components/product/Gallery/ImageSlider.tsx";

export function LoadingFallback() {
return (
<div
style={{ height: "710px" }}
class="w-full flex justify-center items-center"
>
<span class="loading loading-spinner" />
</div>
);
}
11 changes: 11 additions & 0 deletions sections/Product/ProductInfo.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
export { default } from "../../components/product/ProductInfo.tsx";

export function LoadingFallback() {
return (
<div
style={{ height: "710px" }}
class="w-full flex justify-center items-center"
>
<span class="loading loading-spinner" />
</div>
);
}
8 changes: 8 additions & 0 deletions sections/Product/ProductShelf.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export { default } from "$store/components/product/ProductShelf.tsx";

export function LoadingFallback() {
return (
<div style={{ height: "716px" }} class="flex justify-center items-center">
<span class="loading loading-spinner" />
</div>
);
}
8 changes: 8 additions & 0 deletions sections/Product/ProductShelfTabbed.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export { default } from "$store/components/product/ProductShelfTabbed.tsx";

export function LoadingFallback() {
return (
<div style={{ height: "716px" }} class="flex justify-center items-center">
<span class="loading loading-spinner" />
</div>
);
}
8 changes: 8 additions & 0 deletions sections/Product/SearchResult.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export { default } from "$store/components/search/SearchResult.tsx";

export function LoadingFallback() {
return (
<div style={{ height: "100vh" }} class="flex justify-center items-center">
<span class="loading loading-spinner" />
</div>
);
}

0 comments on commit 0a3b63b

Please sign in to comment.