-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add templates for Data table and columns #148
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial PR pass, it should work e2e, but happy to update further based on feedback.
@@ -9,7 +9,7 @@ | |||
}, | |||
"scripts": { | |||
"test": "echo \"Error: no test specified\" && exit 1", | |||
"build": "npx tsc", | |||
"build": "npx tsc && rm -rf dist/templates && cp -r src/templates dist/templates", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if there is a better way to do this, but I figured this is at least a quick and dirty way to pull templates into the dist
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally used a npm package called typescript-cp
for it and then just using the watch flag in dev and without it when building it.
Edit: I'm also using npm-run-all to run the dev scripts in parallel. I dont like concurrently so I used npm-run-all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
@@ -540,7 +540,7 @@ export const addScriptsToPackageJson = ( | |||
"db:migrate": `tsx ${libPath}/db/migrate.ts`, | |||
"db:drop": "drizzle-kit drop", | |||
"db:pull": `drizzle-kit introspect:${driver}`, | |||
...(driver !== "pg" ? { "db:push": `drizzle-kit push:${driver}` } : {}), | |||
"db:push": `drizzle-kit push:${driver}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the guardrails around db:push for pg, now that it's supported.
@@ -20,6 +20,7 @@ addCommonOptions(program.command("init")) | |||
|
|||
program | |||
.command("generate") | |||
.alias("g") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alias 😎
import { Button } from "@/components/ui/button" | ||
|
||
export const columns: ColumnDef<TData, TValue>[] = [ | ||
<% it.fields.map(function (field) { %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
templating in action
@@ -469,19 +481,6 @@ export default function ${tableNameSingularCapitalised}List({ | |||
+ | |||
</Button> | |||
</div> | |||
{optimistic${tableNamePluralCapitalised}.length === 0 ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this list since it's taken care of by the table
PaginationLink, | ||
PaginationNext, | ||
PaginationPrevious, | ||
} from "@/components/ui/pagination"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format the imports also so it works with a different alias.
I got that part working if u want some code. I'll push it later onto my fork in a new branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, thanks!
This PR is the first of a few to incorporate a data table for the index page when generating a new resource using kirimase.
It incorporates the Eta templating package in order to generate views and components.
Additionally, it incorporates the tanstack react-table library, as per Shadcn's recommendations. I purposefully kept the table relatively barebones in this first attempt. It includes pagination and column hiding, alone.
I have a few outstanding questions re: incremental improvements, but I figure that smaller PRs that are easier to review are better than mammoth new PRs.
To test, generate a new next project:
bun run reinstall && bun run createTesterApp
cd
into thetester
dir.then, generate a new resource using kirimase:
kirimase g
follow the instructions. When you hit the index page for the newly created resource, you should see a table under the list of actions.
This should work when you generate a new project both with server actions as well as trpc.
Screenshots