Skip to content

Commit 37f4b00

Browse files
committed
feat: table added on page
1 parent 0d4d59d commit 37f4b00

File tree

4 files changed

+289
-18
lines changed

4 files changed

+289
-18
lines changed

infrastructure/control-panel/src/lib/ui/Table/Table.svelte

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
selectedRow?: number;
5858
withSelection?: boolean;
5959
headerHeight?: number;
60-
onMutate: () => Promise<void> | void;
60+
onMutate?: () => Promise<void> | void;
6161
currentPage?: number;
6262
totalPages?: number;
6363
totalItems?: number;
@@ -205,10 +205,10 @@
205205

206206
<Table
207207
class={cn(
208-
['relative w-full table-fixed text-left text-sm text-gray-500', restProps.class].join(' ')
208+
['relative w-full table-fixed text-left text-sm text-black-700', restProps.class].join(' ')
209209
)}
210210
>
211-
<TableHead class="sticky top-0 h-[var(--table-header-height)] bg-black">
211+
<TableHead class="sticky top-0 h-[var(--table-header-height)] bg-white">
212212
{#if withSelection}
213213
<TableHeadCell class="wide:px-5 w-[48px] max-w-[48px] min-w-[48px] rounded-l-2xl p-4">
214214
<Checkbox checked={checkAll} onchange={(e) => toggleCheckAll(e as boolean)} />
@@ -231,7 +231,7 @@
231231
<Table
232232
class={cn(
233233
[
234-
'relative w-full table-fixed border-separate border-spacing-y-2 text-left text-sm text-gray-500',
234+
'relative w-full table-fixed border-separate border-spacing-y-2 text-left text-sm text-black-700',
235235
restProps.class
236236
].join(' ')
237237
)}
@@ -243,8 +243,8 @@
243243
selectedRow = i;
244244
handleSelectedRow && handleSelectedRow(i);
245245
}}
246-
class="w-full bg-black/50 select-none hover:bg-white/3
247-
{selectedRow === i && 'bg-white/6!'}"
246+
class="w-full bg-white select-none hover:bg-black-300
247+
{selectedRow === i && 'bg-black-300!'}"
248248
>
249249
{#if withSelection}
250250
<th class="wide:px-5 w-[48px] max-w-[48px] min-w-[48px] rounded-l-2xl p-4">
@@ -267,7 +267,7 @@
267267
{@const cellData = tableData[0]?.[heading]}
268268
{@const isSortable = cellData && 'sortable' in cellData && cellData.sortable}
269269
<TableHeadCell
270-
class="wide:text-sm font-roboto p-0 text-xs font-semibold text-gray-200 normal-case
270+
class="wide:text-base font-roboto p-0 text-xs font-bold text-black-700 normal-case
271271
{i === 0 && !withSelection && 'rounded-l-2xl'}
272272
{i === tableHeadings.length - 1 && !isScrollable && 'rounded-r-2xl'}
273273
"
@@ -309,7 +309,7 @@
309309

310310
{#snippet BodyCell(data: Record<string, TableCell>, field: string, i: number)}
311311
<TableBodyCell
312-
class="wide:text-base font-roboto overflow-hidden p-2 text-xs font-normal text-ellipsis text-gray-200
312+
class="wide:text-base font-roboto overflow-hidden p-2 text-xs font-normal text-ellipsis text-black-700
313313
{i === 0 && !withSelection && 'rounded-s-2xl pl-6'}
314314
{i === Object.keys(data).length - 1 && 'rounded-e-2xl'}
315315
"
@@ -343,20 +343,20 @@
343343
<!-- PAGINATION -->
344344
{#if withPagination}
345345
<div
346-
class="sticky bottom-0 z-10 flex h-[var(--pagination-height)] items-center justify-between rounded-2xl bg-black p-3"
346+
class="sticky bottom-0 z-10 flex h-[var(--pagination-height)] items-center justify-between rounded-2xl bg-white p-3"
347347
>
348-
<p class="small text-gray-200">
348+
<p class="small text-black-700">
349349
Showing {(currentPage - 1) * pageSize + 1} - {Math.min(
350350
currentPage * pageSize,
351351
totalItems
352352
)} of {totalItems}
353353
</p>
354354
<div class="flex items-center gap-2">
355355
<!-- Custom Pagination -->
356-
<div class="border-primary-900 flex items-center rounded-lg border bg-white/10">
356+
<div class="border-primary-900 flex items-center rounded-lg border bg-white">
357357
<!-- Previous Button -->
358358
<button
359-
class=" flex h-8 w-10 items-center justify-center text-gray-300 transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
359+
class=" flex h-8 w-10 items-center justify-center text-black-700 transition-colors hover:bg-black-300 disabled:cursor-not-allowed disabled:opacity-50"
360360
onclick={handlePreviousPage}
361361
disabled={currentPage <= 1 || isLoading}
362362
>
@@ -366,15 +366,15 @@
366366
<!-- Page Numbers -->
367367
{#each generatePageNumbers(currentPage, totalPages) as pageNum}
368368
{#if pageNum === '...'}
369-
<span class="flex h-8 w-10 items-center justify-center text-gray-400"
369+
<span class="flex h-8 w-10 items-center justify-center text-black-700"
370370
>...</span
371371
>
372372
{:else}
373373
<button
374374
class="outline-primary-900 flex h-8 w-10 items-center justify-center transition-colors
375375
{currentPage === pageNum
376-
? ' bg-black text-white'
377-
: ' text-gray-300 hover:bg-white/10'}"
376+
? ' bg-white text-black-700'
377+
: ' text-black-700 hover:bg-white'}"
378378
onclick={() =>
379379
typeof pageNum === 'number' ? goToPage?.(pageNum) : undefined}
380380
disabled={isLoading}
@@ -386,7 +386,7 @@
386386

387387
<!-- Next Button -->
388388
<button
389-
class="flex h-8 w-10 items-center justify-center text-gray-300 transition-colors hover:bg-white/10 disabled:cursor-not-allowed disabled:opacity-50"
389+
class="flex h-8 w-10 items-center justify-center text-black-700 transition-colors hover:bg-black-300 disabled:cursor-not-allowed disabled:opacity-50"
390390
onclick={handleNextPage}
391391
disabled={currentPage >= totalPages || isLoading}
392392
>
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
<script lang="ts">
2+
import { ButtonAction } from '$lib/ui';
23
import '../app.css';
34
45
let { children } = $props();
56
</script>
67

7-
{@render children()}
8+
<main>
9+
<header class="flex justify-between items-center px-10 py-5 border-b-[1px] border-black-100 mb-6">
10+
<h4 class="text-primary font-semibold text-xl">Control Panel</h4>
11+
<div class="flex items-center gap-4">
12+
<ButtonAction size="sm" variant="soft">Refresh</ButtonAction>
13+
<ButtonAction size="sm" class="whitespace-nowrap" variant="soft">Start Monitering</ButtonAction>
14+
</div>
15+
</header>
16+
<section class="px-10">
17+
{@render children()}
18+
</section>
19+
</main>
Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,90 @@
1-
<h1 class="text-primary">New Project Control-Panel</h1>
1+
<script lang="ts">
2+
import { Table } from "$lib/ui";
3+
4+
const handlePreviousPage = async () => {
5+
alert('Previous btn clicked. Make a call to your server to fetch data.');
6+
};
7+
const handleNextPage = async () => {
8+
alert('Next btn clicked. Make a call to your server to fetch data.');
9+
};
10+
const tableHeadings = [
11+
'Image',
12+
'Material Name',
13+
'Description',
14+
'Product ID',
15+
'Smart Contract'
16+
// "Ledger Link",
17+
];
18+
const pages = [
19+
{ name: '1', href: '#' },
20+
{ name: '2', href: '#' },
21+
{ name: '3', href: '#' }
22+
];
23+
const tableData = [
24+
{
25+
image: 'https://example.com/image1.jpg',
26+
name: 'Material 1',
27+
description: 'Description of Material 1',
28+
productId: '12345',
29+
smartContract: '0x1234567890abcdef',
30+
ledgerLink: 'https://example.com/ledger1'
31+
},
32+
{
33+
image: 'https://example.com/image2.jpg',
34+
name: 'Material 2',
35+
description: 'Description of Material 2',
36+
productId: '67890',
37+
smartContract: '0xabcdef1234567890',
38+
ledgerLink: 'https://example.com/ledger2'
39+
}
40+
];
41+
42+
const mappedData = tableData.map((row) => {
43+
return {
44+
rowOne: {
45+
type: 'image',
46+
value: row.image
47+
},
48+
rowTwo: {
49+
type: 'text',
50+
value: row.name
51+
},
52+
rowThree: {
53+
type: 'text',
54+
value: row.description
55+
},
56+
rowFour: {
57+
type: 'text',
58+
value: row.productId
59+
},
60+
rowFive: {
61+
type: 'text',
62+
value: row.smartContract
63+
}
64+
// rowSix: {
65+
// type: "snippet",
66+
// snippet: BadgeCell,
67+
// value:
68+
// row.ledgerLink,
69+
// },
70+
};
71+
});
72+
</script>
73+
74+
75+
<section>
76+
<Table
77+
class="mb-7"
78+
tableData= {mappedData}
79+
withSelection= {true}
80+
{handlePreviousPage}
81+
{handleNextPage}
82+
/>
83+
84+
<Table
85+
tableData= {mappedData}
86+
withSelection= {true}
87+
{handlePreviousPage}
88+
{handleNextPage}
89+
/>
90+
</section>

0 commit comments

Comments
 (0)