-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs): start any example in stackblitz (#1576)
Co-authored-by: Julius Marminge <[email protected]>
- Loading branch information
1 parent
9614d84
commit 3d74370
Showing
5 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,104 @@ | ||
--- | ||
const options = { | ||
nextAuth: "NextAuth.js", | ||
prisma: "Prisma", | ||
tailwind: "Tailwind CSS", | ||
trpc: "tRPC", | ||
drizzle: "Drizzle", | ||
}; | ||
--- | ||
|
||
<script> | ||
import sdk from "@stackblitz/sdk"; | ||
|
||
function directToStackBlitz(checkedInputs: any) { | ||
try { | ||
sdk.openProject( | ||
{ | ||
title: "T3 Examples", | ||
description: "T3 example apps.", | ||
template: "node", | ||
files: { | ||
"package.json": `{ | ||
"name": "T3 Examples", | ||
"version": "1.0.0", | ||
"description": "My Next.js app", | ||
"scripts":{ | ||
"dev": " echo 'y' | npx create-t3-app example-app --CI ${checkedInputs} && cd ./example-app && rm ../package.json " } | ||
}`, | ||
}, | ||
settings: { | ||
compile: { | ||
trigger: "auto", | ||
clearConsole: false, | ||
}, | ||
}, | ||
}, | ||
{ | ||
newWindow: true, | ||
openFile: ["package.json"], | ||
}, | ||
); | ||
} catch (error) { | ||
console.error("Error", error); | ||
} | ||
} | ||
|
||
function handleFormSubmit(e: Event) { | ||
e.preventDefault(); | ||
|
||
const inputs = Array.from( | ||
(e.target as HTMLFormElement).querySelectorAll("input"), | ||
); | ||
let checkedInputs = ""; | ||
inputs | ||
.filter((input) => input.checked) | ||
.map((input) => (checkedInputs += ` --${input.value}`)); | ||
|
||
directToStackBlitz(checkedInputs); | ||
} | ||
|
||
const form = document.getElementById("componentForm") as HTMLFormElement; | ||
|
||
const prismaInput = document.getElementById("prisma") as HTMLInputElement; | ||
const drizzleInput = document.getElementById("drizzle") as HTMLInputElement; | ||
|
||
function handleCheckboxChange(e: Event) { | ||
if (e.target === prismaInput && drizzleInput.checked) { | ||
drizzleInput.checked = false; | ||
} else if (e.target === drizzleInput && prismaInput.checked) { | ||
prismaInput.checked = false; | ||
} | ||
} | ||
|
||
prismaInput.addEventListener("change", handleCheckboxChange); | ||
drizzleInput.addEventListener("change", handleCheckboxChange); | ||
|
||
form.addEventListener("submit", handleFormSubmit); | ||
</script> | ||
|
||
<form | ||
method="get" | ||
id="componentForm" | ||
class="mb-4 w-full rounded border border-t3-purple-300 p-4 text-lg" | ||
> | ||
{ | ||
Object.entries(options).map(([code, name]) => ( | ||
<div> | ||
<input | ||
id={code} | ||
type="checkbox" | ||
name={name} | ||
value={code} | ||
class="h-4 w-4" | ||
/> | ||
<label for={code}>{name}</label> | ||
</div> | ||
)) | ||
} | ||
<button | ||
class="text-md inline-flex cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md border-2 bg-t3-purple-200/50 px-3 py-2 font-medium hover:bg-t3-purple-200/75 dark:border-t3-purple-200/20 dark:bg-t3-purple-200/10 dark:hover:border-t3-purple-200/50" | ||
> | ||
View in StackBlitz | ||
</button> | ||
</form> |
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,22 @@ | ||
--- | ||
title: Examples | ||
description: Examples of different live apps | ||
layout: ../../layouts/docs.astro | ||
lang: en | ||
isMdx: true | ||
--- | ||
|
||
import Callout from "../../components/docs/callout.tsx"; | ||
import Form from "../../components/docs/exampleOptionForm.astro"; | ||
|
||
You can try out different combinations of technologies that create-t3-app offers. | ||
|
||
<Callout type="info"> | ||
You cannot select `prisma` and `drizzle` at the same time. | ||
</Callout> | ||
|
||
<Form /> | ||
|
||
<Callout type="warning"> | ||
Some features might not work unless you create an env file | ||
</Callout> |
3d74370
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.
Successfully deployed to the following URLs:
t3-upgrade – ./upgrade
t3-upgrade-t3-oss.vercel.app
t3-upgrade.vercel.app
t3-upgrade-git-next-t3-oss.vercel.app
3d74370
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.
Successfully deployed to the following URLs:
create-t3-app – ./www
create-t3-app-nu.vercel.app
create-t3-app-git-next-t3-oss.vercel.app
create.t3.wtf
create-t3-app-t3-oss.vercel.app
www.ct3.app
create.t3.gg
ct3.app
beta.create.t3.gg