@pradip1995/segment-animation-shop-grid 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-animation-shop-grid",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,9 +24,9 @@
24
24
  "next": ">=15"
25
25
  },
26
26
  "dependencies": {
27
- "@pradip1995/segment-primitives": "^0.4.0",
28
- "@pradip1995/segment-product-card": "^0.3.10",
29
- "@pradip1995/segment-tokens": "^0.3.7",
27
+ "@pradip1995/segment-primitives": "^0.4.11",
28
+ "@pradip1995/segment-product-card": "^0.3.26",
29
+ "@pradip1995/segment-tokens": "^0.3.14",
30
30
  "framer-motion": "^12.0.0"
31
31
  },
32
32
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  .animation-shop-grid {
2
2
  width: 100%;
3
- padding: 0 1.5rem 4rem 1.5rem;
3
+ padding: 0 0 3rem 0;
4
4
  background-color: var(--page-bg, #ffffff);
5
5
  color: var(--text-color, #111111);
6
6
  font-family: inherit;
@@ -9,7 +9,7 @@
9
9
 
10
10
  @media (min-width: 1024px) {
11
11
  .animation-shop-grid {
12
- padding: 0 3rem 6rem 3rem;
12
+ padding: 0 0 6rem 0;
13
13
  }
14
14
  }
15
15
 
@@ -9,6 +9,7 @@ import { loadMoreStoreProducts, type StoreLoadMoreFilters } from "./load-more-pr
9
9
  import "./animation-shop-grid.css"
10
10
 
11
11
  const PAGE_SIZE = 12
12
+ const EMPTY_PRODUCTS: HttpTypes.StoreProduct[] = []
12
13
 
13
14
  const SORT_OPTIONS = [
14
15
  { value: "created_at_desc", label: "Newest" },
@@ -240,7 +241,7 @@ export default function AnimationShopGrid(props: {
240
241
  props.maxPrice,
241
242
  ]
242
243
  )
243
- const initialProducts = props.products ?? []
244
+ const initialProducts = props.products ?? EMPTY_PRODUCTS
244
245
  const totalCount = props.productCount ?? initialProducts.length
245
246
 
246
247
  const [items, setItems] = useState(initialProducts)
@@ -255,12 +256,12 @@ export default function AnimationShopGrid(props: {
255
256
  const loadingRef = useRef(false)
256
257
 
257
258
  useEffect(() => {
258
- setItems(props.products ?? [])
259
+ setItems(props.products ?? EMPTY_PRODUCTS)
259
260
  setCurrentPage(initialPage)
260
261
  setHasMore(sortBy !== "bestsellers" && totalCount > initialPage * PAGE_SIZE)
261
262
  setLoadError(null)
262
263
  loadingRef.current = false
263
- }, [filterSignature, initialPage, sortBy, totalCount])
264
+ }, [filterSignature, initialPage, sortBy, totalCount, props.products])
264
265
 
265
266
  const loadNextPage = useCallback(() => {
266
267
  if (loadingRef.current || pending || !hasMore || sortBy === "bestsellers") return
@@ -381,6 +382,15 @@ export default function AnimationShopGrid(props: {
381
382
  useEffect(() => {
382
383
  const sidebar = document.querySelector(".store-page__sidebar") as HTMLElement | null
383
384
  const mainCol = document.querySelector(".store-page__main") as HTMLElement | null
385
+ const isDesktop = typeof window !== "undefined" && window.matchMedia("(min-width: 1024px)").matches
386
+
387
+ if (!isDesktop) {
388
+ // Mobile uses segment-mobile-filters — never force sidebar display
389
+ if (sidebar) sidebar.style.display = ""
390
+ if (mainCol) mainCol.classList.remove("w-full", "col-span-full")
391
+ return
392
+ }
393
+
384
394
  if (sidebar) {
385
395
  sidebar.style.display = showFilters ? "" : "none"
386
396
  }
@@ -393,6 +403,10 @@ export default function AnimationShopGrid(props: {
393
403
  }
394
404
  }, [showFilters])
395
405
 
406
+ function handleFilterToggle() {
407
+ setShowFilters((v) => !v)
408
+ }
409
+
396
410
  return (
397
411
  <section className="animation-shop-grid flex-1 min-w-0 pt-0" aria-label="Product results">
398
412
  {/* Simplified, Clean Hero Header */}
@@ -419,13 +433,13 @@ export default function AnimationShopGrid(props: {
419
433
  </p>
420
434
  </motion.header>
421
435
 
422
- {/* Filter Toolbar with Hide Filters Option */}
423
- <div className="w-full flex flex-wrap items-center justify-between gap-3 mb-5 py-2.5 px-4 bg-white border border-gray-200/80 rounded-md shadow-2xs">
424
- <div className="flex items-center gap-3">
436
+ {/* Filter Toolbar */}
437
+ <div className="animation-shop-grid__toolbar w-full flex flex-wrap items-center justify-between gap-2 sm:gap-3 mb-4 sm:mb-5 py-2 sm:py-2.5 px-2.5 sm:px-4 bg-white border border-gray-200/80 rounded-md shadow-2xs">
438
+ <div className="flex items-center gap-2 sm:gap-3 min-w-0">
425
439
  <button
426
440
  type="button"
427
- onClick={() => setShowFilters(!showFilters)}
428
- className="inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-gray-800 hover:text-black transition-colors py-1 px-2.5 bg-gray-50 hover:bg-gray-100 border border-gray-200 rounded cursor-pointer"
441
+ onClick={handleFilterToggle}
442
+ className="hidden lg:inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-gray-800 hover:text-black transition-colors py-1.5 px-2.5 bg-gray-50 hover:bg-gray-100 border border-gray-200 rounded cursor-pointer"
429
443
  >
430
444
  <svg className="w-3.5 h-3.5 fill-none stroke-current stroke-[1.8]" viewBox="0 0 24 24">
431
445
  <path strokeLinecap="round" strokeLinejoin="round" d="M10.5 6h9m-9 12h9m-15-6h15M3 6h3m-3 12h3m3-6h3" />
@@ -434,7 +448,7 @@ export default function AnimationShopGrid(props: {
434
448
  </button>
435
449
 
436
450
  {appliedFilters.length > 0 ? (
437
- <div className="hidden sm:flex items-center gap-2">
451
+ <div className="hidden sm:flex items-center gap-2 flex-wrap">
438
452
  <span className="text-[11px] font-bold text-gray-400 uppercase tracking-wider">Active:</span>
439
453
  {appliedFilters.map((filter) => (
440
454
  <LocalizedLink
@@ -451,17 +465,17 @@ export default function AnimationShopGrid(props: {
451
465
  ) : null}
452
466
  </div>
453
467
 
454
- <div className="flex items-center gap-3 ml-auto">
455
- <span className="text-xs text-gray-500 font-medium tracking-wide">
456
- {showingCount} of {totalCount} {totalCount === 1 ? "Product" : "Products"}
468
+ <div className="flex items-center gap-2 sm:gap-3 ml-auto shrink-0">
469
+ <span className="text-[11px] sm:text-xs text-gray-500 font-medium tracking-wide">
470
+ {showingCount} of {totalCount}
457
471
  </span>
458
472
  {appliedFilters.length > 0 ? (
459
473
  <LocalizedLink
460
474
  href={buildClearAllFiltersHref(storeSearchParams)}
461
- className="text-xs font-bold text-red-600 hover:text-red-700 uppercase tracking-wider underline ml-2"
475
+ className="text-[11px] sm:text-xs font-bold text-red-600 hover:text-red-700 uppercase tracking-wider underline"
462
476
  countryCode={countryCode}
463
477
  >
464
- Clear All
478
+ Clear
465
479
  </LocalizedLink>
466
480
  ) : null}
467
481
  </div>