Skip to content

Commit

Permalink
types are nuts but the table works with the proper CSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
palmertab committed Jan 3, 2025
1 parent 0a3f101 commit 884bbef
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 163 deletions.
116 changes: 32 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "schemats",
"version": "0.0.1",
"version": "0.1.0",
"description": "Frontend Client for Tabroom.com",
"private": true,
"keywords": [
"speech",
"schemats",
"debate",
"congress",
"tabulation",
Expand All @@ -19,21 +20,23 @@
"url": "https://github.com/speechanddebate/tabroom/issues"
},
"scripts": {
"production": "vite build --mode production && node -r dotenv/config build/index.js",
"staging": "vite build --mode staging",
"build": "vite build --mode production",
"dev": "vite dev",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"production" : "vite build --mode production && node -r dotenv/config build/index.js",
"staging" : "vite build --mode staging",
"build" : "vite build --mode production",
"dev" : "vite dev",
"preview" : "vite preview",
"check" : "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test": "vitest",
"lint": "eslint .",
"prepare": "husky"
"test" : "vitest",
"lint" : "eslint .",
"prepare" : "husky"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@types/node": "^22.10.5",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@types/tabulator-tables": "^6.2.3",
"eslint": "^8.28.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-svelte": "^2.45.1",
Expand All @@ -50,12 +53,11 @@
"@sveltejs/adapter-node": "^5.2.10",
"@sveltejs/kit": "^2.5.27",
"dotenv": "^16.3.1",
"tabulator-tables": "^6.3.0",
"tsc-alias": "^1.8.10",
"typescript": "^5.5.0",
"vite": "^5.4.4",
"vitest": "^1.0.0",
"wx-svelte-core": "^2.0.0-beta-2",
"wx-svelte-grid": "^2.0.0-beta-3"
"vitest": "^1.0.0"
},
"eslintConfig": {
"extends": [
Expand Down
64 changes: 54 additions & 10 deletions src/lib/DataTable.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
<script lang='ts'>
import { Grid } from 'wx-svelte-grid';
import { Willow } from 'wx-svelte-grid';
import {TabulatorFull as Tabulator} from 'tabulator-tables';
import {onMount} from 'svelte';
import type { TabulatorFull } from 'tabulator-tables';
interface Props {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any[];
data?: any[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
columns?: any[];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options?: any;
}
let { data, columns = [] }: Props = $props();
let {
data = [],
columns = [],
options = {}
}: Props = $props();
/**@type {import('tabulator-tables').Tabulator}*/
let tableObject : TabulatorFull;
let tableRef : HTMLDivElement;
onMount(() => {
if (data) {
tableObject = new Tabulator(tableRef, {
data ,
columns ,
layout : 'fitColumns' , //fit columns to width of table
addRowPos : 'top' , //when adding a new row add it to the top of the table
paginationSize : 50 , //allow 7 rows per page of data
pagination : true , //paginate the data
paginationCounter : 'rows' , //display count of paginated rows in footer
responsiveLayout : 'hide' , //hide columns that don't fit on the table
movableColumns : true , //allow column order to be changed
resizableColumnFit : true,
});
} else {
tableObject = new Tabulator(tableRef, {
layout : 'fitColumns' , //fit columns to width of table
responsiveLayout : 'hide' , //hide columns that don't fit on the table
addRowPos : 'top' , //when adding a new row add it to the top of the table
paginationSize : 50 , //allow 7 rows per page of data
pagination : true , //paginate the data
paginationCounter : 'rows' , //display count of paginated rows in footer
movableColumns : true , //allow column order to be changed
});
}
return () => tableObject.destroy();
});
</script>

<Willow>
<Grid {data} {columns} />
</Willow>
<div style="text-align: right; padding-bottom: 4px;">
<button onclick={ () => { tableObject.download('csv', options.filename || 'tabroom-data.csv') } } >
CSV
</button>
</div>

<div bind:this={tableRef}></div>

<svelte:head>
<link href="/css/tabulator.min.css" rel="stylesheet">
</svelte:head>

4 changes: 2 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
margin : auto;
padding : 0;
}
#content {
position : relative;
color : black;
Expand All @@ -43,5 +43,5 @@
padding : 0;
min-width : 1180px;
}
</style>
7 changes: 1 addition & 6 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// import Sidebar from './Sidebar.svelte';
import type { PageData } from './$types';
import { tourns } from './stores';
interface Props {
data: PageData;
}
Expand All @@ -22,11 +20,8 @@
}
let tournList: Tourn[] = $state();
tournList = data.tourns;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
tourns.subscribe((value: any) => {
tournList = value;
});
</script>

<div id="main">
Expand Down
Loading

0 comments on commit 884bbef

Please sign in to comment.