Skip to content

Commit a71d8e6

Browse files
committed
return more popular products on homepage, and limit to 2 lines
1 parent 50a44be commit a71d8e6

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/routes/(info)/lttstore/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const load = (async ({platform}) => {
1515
const oneWeekAgo = Date.now() - (7 * 24 * 60 * 60e3);
1616

1717
const popularProducts = retryD1(() =>
18-
db.prepare("select * from products where stockChecked > ? and purchasesPerHour > 0 and stock is not null and json_extract(stock, '$.total') is not null order by purchasesPerHour DESC limit 11")
18+
db.prepare("select * from products where stockChecked > ? and purchasesPerHour > 0 and stock is not null and json_extract(stock, '$.total') is not null order by purchasesPerHour DESC limit 14")
1919
.bind(Math.max(oneWeekAgo, 1745474690241))
2020
.all<ProductsTableRow>()
2121
.then(r => r.results)

src/routes/(info)/lttstore/+page.svelte

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
import { run } from 'svelte/legacy';
32
43
import LTTProductCard from "$lib/lttstore/LTTProductCard.svelte";
54
import { page } from "$app/state";
@@ -8,17 +7,10 @@
87
import {slide, fade} from "svelte/transition";
98
import { Progress } from "@skeletonlabs/skeleton-svelte";
109
import { invalidateAll } from "$app/navigation";
11-
import { SearchClient } from "typesense";
12-
import type { SearchResponse } from "typesense/lib/Typesense/Documents";
13-
import type { ProductSearchIndex } from "$lib/lttstore/lttstore_types.ts";
14-
import sanitizeHtml from "sanitize-html";
15-
import DateStamp from "$lib/DateStamp.svelte";
1610
import RelativeDate from "$lib/RelativeDate.svelte";
1711
1812
let { data } = $props();
1913
20-
let waiting = $state(false);
21-
2214
let loading = $state(false);
2315
async function reload() {
2416
loading = true;
@@ -107,24 +99,27 @@
10799
<div class="opacity-80 pl-2">
108100
From the past few hours
109101
</div>
110-
{#each data.popularProducts as product (product.id)}
111-
<div class="inline-block" animate:flip={{ duration: 200 }}>
112-
<LTTProductCard
113-
product={JSON.parse(product.product)}
114-
shortTitle={product.shortTitle}
115-
>
116-
{#snippet detail()}
117-
<div class="opacity-80 text-xs">
118-
{#if product.purchasesPerHour && product.purchasesPerHour > 0}
119-
{product.purchasesPerHour.toFixed(2)} sph
120-
{/if}
121-
</div>
122-
{/snippet}
123-
</LTTProductCard>
124-
</div>
125-
{:else}
126-
No products are being tracked yet!
127-
{/each}
102+
<!-- text-clear is to hide the ellipsis from line-clamp -->
103+
<div class="overflow-hidden max-md:line-clamp-5 max-lg:line-clamp-3 lg:line-clamp-2 text-clear">
104+
{#each data.popularProducts as product (product.id)}
105+
<div class="inline-block text-white text-base" animate:flip={{ duration: 200 }}>
106+
<LTTProductCard
107+
product={JSON.parse(product.product)}
108+
shortTitle={product.shortTitle}
109+
>
110+
{#snippet detail()}
111+
<div class="opacity-80 text-xs">
112+
{#if product.purchasesPerHour && product.purchasesPerHour > 0}
113+
{product.purchasesPerHour.toFixed(2)} sph
114+
{/if}
115+
</div>
116+
{/snippet}
117+
</LTTProductCard>
118+
</div>
119+
{:else}
120+
No products are being tracked yet!
121+
{/each}
122+
</div>
128123
<br>
129124
<br>
130125
{/if}
@@ -217,4 +212,9 @@
217212
margin-left: 0.5rem;
218213
margin-right: 0.5rem;
219214
}
220-
</style>
215+
216+
.text-clear {
217+
color: rgba(0, 0, 0, 0);
218+
font-size: 0;
219+
}
220+
</style>

0 commit comments

Comments
 (0)