-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
209 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { PageServerLoad } from './$types'; | ||
import { getDrawMethods } from '$lib/api'; | ||
|
||
export const load: PageServerLoad = async () => { | ||
const res = await getDrawMethods(); | ||
return { drawMethods: res.data! }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import Title from '$lib/components/Title.svelte'; | ||
import DataTable from './DataTable.svelte'; | ||
import type { PageServerData } from './$types'; | ||
export let data: PageServerData; | ||
</script> | ||
|
||
<Title>Draw Methods</Title> | ||
|
||
<DataTable drawMethods={data.drawMethods} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script lang="ts"> | ||
import { createTable, Subscribe, Render } from 'svelte-headless-table'; | ||
import { readable } from 'svelte/store'; | ||
import * as Table from '$lib/components/ui/table'; | ||
import type { DrawMethod } from '$lib/api'; | ||
export let drawMethods: DrawMethod[]; | ||
const table = createTable(readable(drawMethods)); | ||
const columns = table.createColumns([ | ||
table.column({ | ||
accessor: 'name', | ||
header: 'Name', | ||
}), | ||
table.column({ | ||
accessor: 'method', | ||
header: 'Method', | ||
cell: ({ value }) => { | ||
if (!value) return ''; | ||
return value.split('_').map((v) => v.charAt(0).toUpperCase() + v.substring(1)).join(' '); | ||
}, | ||
}), | ||
table.column({ | ||
accessor: 'data', | ||
header: 'Data', | ||
}), | ||
]); | ||
const { headerRows, pageRows, tableAttrs, tableBodyAttrs } = table.createViewModel(columns); | ||
</script> | ||
|
||
<div class="rounded-md border"> | ||
<Table.Root {...$tableAttrs}> | ||
<Table.Header> | ||
{#each $headerRows as headerRow} | ||
<Subscribe rowAttrs={headerRow.attrs()}> | ||
<Table.Row> | ||
{#each headerRow.cells as cell (cell.id)} | ||
<Subscribe attrs={cell.attrs()} let:attrs props={cell.props()}> | ||
<Table.Head {...attrs}> | ||
<Render of={cell.render()} /> | ||
</Table.Head> | ||
</Subscribe> | ||
{/each} | ||
</Table.Row> | ||
</Subscribe> | ||
{/each} | ||
</Table.Header> | ||
<Table.Body {...$tableBodyAttrs}> | ||
{#each $pageRows as row (row.id)} | ||
<Subscribe rowAttrs={row.attrs()} let:rowAttrs> | ||
<Table.Row {...rowAttrs}> | ||
{#each row.cells as cell (cell.id)} | ||
<Subscribe attrs={cell.attrs()} let:attrs> | ||
<Table.Cell {...attrs}> | ||
<Render of={cell.render()} /> | ||
</Table.Cell> | ||
</Subscribe> | ||
{/each} | ||
</Table.Row> | ||
</Subscribe> | ||
{/each} | ||
</Table.Body> | ||
</Table.Root> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters