Skip to content

Commit

Permalink
refactor: fixing margins across the different pages that implement it…
Browse files Browse the repository at this point in the history
…em-grid so they are more consistent
  • Loading branch information
Zazawowow committed Jan 24, 2025
1 parent 2ff4f16 commit 71804ed
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 44 deletions.
18 changes: 11 additions & 7 deletions packages/app/src/lib/components/common/item-grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</script>

{#if forItemType === 'product'}
<div class="m-8">
<div class="my-8 mx-4">
{#if title}
<div class="flex flex-col md:flex-row justify-between items-center">
<h2>{title}</h2>
Expand All @@ -45,12 +45,16 @@
</div>
</div>
{:else if forItemType === 'stall'}
<div class="my-16 mx-4">
{#if title}
<h2>{title}</h2>
{/if}
<div class="grid grid-cols-1 gap-8 md:gap-16 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
<slot />
<div class="my-8">
<div class="mx-4">
{#if title}
<div class="my-8">
<h2>{title}</h2>
</div>
{/if}
<div class="grid grid-cols-1 gap-8 md:gap-16 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
<slot />
</div>
</div>
</div>
{/if}
2 changes: 2 additions & 0 deletions packages/app/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div>
<CatMenu />
</div>
<div class="my-8 mx-4">
{#if $featuredProductsQuery.data?.products?.length}
<ItemGrid title="Featured">
{#each $featuredProductsQuery.data?.products as item (item.id)}
Expand All @@ -56,6 +57,7 @@
</div>
</div>
{/if}
</div>
</div>
</main>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/routes/category/[category]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</Hero>
<CatMenu />
<div class="flex min-h-screen w-full flex-col">
<div class="flex flex-col gap-2 relative">
<div class="flex flex-col gap-2 relative mx-4">
{#if $productsQuery.data?.products}
<ItemGrid title="Products">
{#each $productsQuery?.data.products as product}
Expand Down
18 changes: 10 additions & 8 deletions packages/app/src/routes/community/[...stallId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</div>

{#if isMyStall}
<div class="flex flex-row gap-2">
<div class="flex flex-row gap-2 mx-8">
<Button variant="primary" class="mt-4 w-fit" on:click={() => openDrawerForStall(stall.id)}>Edit stall</Button>
<Button variant="primary" class="mt-4 w-fit" on:click={() => openDrawerForNewProductForStall(stall.id)}>Add product</Button>
</div>
Expand All @@ -192,13 +192,15 @@

{#if $productsQuery.data?.products.length}
{@const { products } = $productsQuery.data}
<ItemGrid title="Products" withSort={false} on:sortSelectedChange={(e) => onSortSelectedChange(e.detail.value)}>
{#if products.length}
{#each products as item (item.id)}
<ProductItem product={item} />
{/each}
{/if}
</ItemGrid>
<div class="mx-4">
<ItemGrid title="Products" withSort={false} on:sortSelectedChange={(e) => onSortSelectedChange(e.detail.value)}>
{#if products.length}
{#each products as item (item.id)}
<ProductItem product={item} />
{/each}
{/if}
</ItemGrid>
</div>
{:else if $productsQuery.isSuccess && !$productsQuery.data}
<div class="my-16 mx-8">
<h3>No products found</h3>
Expand Down
38 changes: 20 additions & 18 deletions packages/app/src/routes/p/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,27 @@
</div>
</div>
{/if}
{#if stallsMixture.length}
<ItemGrid title="Shops">
{#key stallsMixture}
{#each stallsMixture as item (item.id)}
<StallItem stallData={item} />
{/each}
{/key}
</ItemGrid>
{/if}
<div class="mx-4">
{#if stallsMixture.length}
<ItemGrid title="Shops">
{#key stallsMixture}
{#each stallsMixture as item (item.id)}
<StallItem stallData={item} />
{/each}
{/key}
</ItemGrid>
{/if}

{#if productsMixture.length}
<ItemGrid title="Products">
{#key stallsMixture}
{#each productsMixture as item (item.id)}
<ProductItem product={item} />
{/each}
{/key}
</ItemGrid>
{/if}
{#if productsMixture.length}
<ItemGrid title="Products">
{#key stallsMixture}
{#each productsMixture as item (item.id)}
<ProductItem product={item} />
{/each}
{/key}
</ItemGrid>
{/if}
</div>
</div>
</div>
</div>
Expand Down
21 changes: 11 additions & 10 deletions packages/app/src/routes/products/[...productId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,15 @@
</div>
{/if}
{/if}

{#if $otherProducts?.data?.products.length}
<ItemGrid title="More from {$userProfileQuery?.data?.name}">
{#key $otherProducts.data.products}
{#each $otherProducts?.data?.products as item}
<ProductItem product={item} />
{/each}
{/key}
</ItemGrid>
{/if}
<div class="mx-4">
{#if $otherProducts?.data?.products.length}
<ItemGrid title="More from {$userProfileQuery?.data?.name}">
{#key $otherProducts.data.products}
{#each $otherProducts?.data?.products as item}
<ProductItem product={item} />
{/each}
{/key}
</ItemGrid>
{/if}
</div>
{/if}

0 comments on commit 71804ed

Please sign in to comment.