Skip to content

Commit

Permalink
Display brands in homepage products
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon committed Nov 20, 2023
1 parent e62bed9 commit 990106c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions src/lib/api/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export type Product = {
nutriments: Nutriments;
};

export type ProductReduced = Pick<Product, 'image_front_small_url' | 'code' | 'product_name'>;
export type ProductReduced = Pick<
Product,
'image_front_small_url' | 'code' | 'product_name' | 'brands'
>;
export async function getProduct(
barcode: string,
fetch: (url: string) => Promise<Response>
Expand All @@ -132,7 +135,7 @@ export async function getProductReducedForCard(
PRODUCT_URL(barcode) +
'?' +
new URLSearchParams({
fields: 'image_front_small_url,code,product_name',
fields: 'image_front_small_url,code,product_name,brands',
lc: get(preferences).lang
});
const res = await wrapFetch(fetch)(url);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</button>
</div>

<a class="btn btn-secondary ms-4 px-5" href="/qr" title="Scan a barcode">
<a class="btn btn-secondary ms-4 px-5 text-lg" href="/qr" title="Scan a barcode">
<span class="icon-[mdi--camera]"></span>
</a>
</div>
Expand Down
22 changes: 15 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
Explorer!
</h3>

<p>OpenFoodFacts Explorer is a tool to explore the OpenFoodFacts database.</p>
<p>
<strong>OpenFoodFacts Explorer</strong>
is a tool to explore the OpenFoodFacts database.
</p>
<p>
You can enter a product code in the search bar above to get started or click on one of the
products below.
Expand All @@ -28,15 +31,15 @@

<div class="mt-8 w-full">
{#await data.streamed.products}
<div class="flex justify-center">
<span class="loading loading-ring loading-lg mx-auto" />
<div class="mt-10 flex justify-center">
<span class="loading loading-dots loading-lg mx-auto" />
</div>
{:then products}
<div class="grid grid-cols-4 gap-4">
{#each products as state}
<a
href={`/products/${state.product.code}`}
class="btn btn-ghost pointer-events-none h-auto justify-normal p-2 text-start"
class="btn btn-ghost pointer-events-none h-auto justify-normal bg-white p-4 text-start text-primary shadow-md dark:bg-base-300"
class:pointer-events-none={$navigating}
>
<div class="flex flex-row items-center">
Expand All @@ -51,9 +54,14 @@
/>
{/if}
</div>
<p>
{state.product.product_name ?? state.product.code}
</p>
<div>
<p class="text-lg">
{state.product.product_name ?? state.product.code}
</p>
<p class="mt-2 text-sm font-light">
{state.product.brands}
</p>
</div>
</div>
</a>
{/each}
Expand Down

0 comments on commit 990106c

Please sign in to comment.