Skip to content
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

feat(docs): start any example in stackblitz #1576

Merged
merged 13 commits into from
Oct 6, 2023
Prev Previous commit
Next Next commit
feat: linted and formatted
  • Loading branch information
mqshaikh8 committed Sep 25, 2023
commit a5aed4cd26715dde85d66ebbbb6829d59fee174a
73 changes: 35 additions & 38 deletions www/src/components/docs/exampleOptionForm.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,63 @@ const options = {
prisma: "Prisma",
tailwind: "Tailwind CSS",
trpc: "tRPC",
drizzle: 'drizzle'
drizzle: "drizzle",
mqshaikh8 marked this conversation as resolved.
Show resolved Hide resolved
};
---

<script>
import sdk from '@stackblitz/sdk';
import sdk from "@stackblitz/sdk";

function directToStackBlitz(checkedInputs:any){
function directToStackBlitz(checkedInputs: any) {
try {
sdk.openProject(
{
title: 'T3 Examples',
description: 'T3 example apps.',
template: 'node',
files: {
'package.json':`{
{
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 my-app --CI ${checkedInputs} && cd ./my-app && rm ../package.json " }
}`
},
settings: {
compile: {
trigger: 'auto',
clearConsole: false,
},
},
},
{
newWindow: true,
openFile: ['package.json'],
"dev": " echo 'y' | npx create-t3-app example-app --CI ${checkedInputs} && cd ./my-app && rm ../package.json " }
mqshaikh8 marked this conversation as resolved.
Show resolved Hide resolved
}`,
},
settings: {
compile: {
trigger: "auto",
clearConsole: false,
},
);
},
},
{
newWindow: true,
openFile: ["package.json"],
},
);
} catch (error) {
console.error("Error", error)
console.error("Error", error);
}

}

function handleFormSubmit(e: Event) {
e.preventDefault();

const inputs = Array.from(
(e.target as HTMLFormElement).querySelectorAll("input")
(e.target as HTMLFormElement).querySelectorAll("input"),
);
let checkedInputs = ''
inputs.filter((input) => input.checked).map((input) => checkedInputs += ` --${input.value}`);
let checkedInputs = "";
inputs
.filter((input) => input.checked)
.map((input) => (checkedInputs += ` --${input.value}`));


directToStackBlitz(checkedInputs)
directToStackBlitz(checkedInputs);
}


const form = document.getElementById("componentForm") as HTMLFormElement;

form.addEventListener('submit', handleFormSubmit);
form.addEventListener("submit", handleFormSubmit);
</script>

<form
Expand All @@ -83,12 +83,9 @@ const options = {
</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">
<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>
Loading