Skip to content

Commit

Permalink
feat: add a simple playground (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hebilicious committed Aug 29, 2023
1 parent e2fd13d commit 3f48956
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 63 deletions.
2 changes: 0 additions & 2 deletions playgrounds/advanced/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"@hebilicious/server-block-nuxt": "0.3.4",
"@hebilicious/sfc-server-volar": "0.3.4",
"@nuxt/devtools": "^0.8.2",
"h3": "^1.8.1",
"nitropack": "2.6.2",
"nuxt": "3.7.0"
}
}
1 change: 1 addition & 0 deletions playgrounds/simple/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
9 changes: 9 additions & 0 deletions playgrounds/simple/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default defineNuxtConfig({
modules: ["@hebilicious/form-actions-nuxt"],
devtools: {
enabled: true,
timeline: {
enabled: true
}
}
})
14 changes: 14 additions & 0 deletions playgrounds/simple/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "simple-playground",
"private": true,
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"start": "nuxi preview"
},
"devDependencies": {
"@hebilicious/form-actions-nuxt": "latest",
"@nuxt/devtools": "^0.8.2",
"nuxt": "3.7.0"
}
}
5 changes: 5 additions & 0 deletions playgrounds/simple/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<NuxtLink to="login">
Login
</NuxtLink>
</template>
13 changes: 13 additions & 0 deletions playgrounds/simple/pages/login.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<form method="POST">
<label>
Email
<input name="email" type="email" autocomplete="username">
</label>
<label>
Password
<input name="password" type="password" autocomplete="current-password">
</label>
<button>Log in</button>
</form>
</template>
9 changes: 9 additions & 0 deletions playgrounds/simple/pages/profile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
Redirected to profile !
<NuxtLink to="login">
Login
</NuxtLink>
<NuxtLink to="/">
Home
</NuxtLink>
</template>
13 changes: 13 additions & 0 deletions playgrounds/simple/server/actions/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const validValue = (v: unknown): v is string => typeof v === "string" && v.length > 0
export default defineFormActions({
default: async (event) => {
const formData = await readFormData(event)
const email = formData.get("email")
const password = formData.get("password")
// eslint-disable-next-line no-console
console.log({ email, password })
if (!validValue(email)) return actionResponse(event, { email, missing: true }, { error: { message: "Missing email" } })
const user = { email } // Load the user somehow
return actionResponse(event, { user }, { redirect: "/profile" })
}
})
3 changes: 3 additions & 0 deletions playgrounds/simple/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
3 changes: 3 additions & 0 deletions playgrounds/simple/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
6 changes: 1 addition & 5 deletions playgrounds/vorms-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
"devDependencies": {
"@hebilicious/form-actions-nuxt": "latest",
"@nuxt/devtools": "^0.8.2",
"@vorms/core": "^1.1.0",
"@vorms/resolvers": "^1.1.0",
"h3": "^1.8.1",
"nitropack": "2.6.2",
"nuxt": "3.7.0",
"zod": "^3.22.2"
},
"dependencies": {
"@vorms/core": "^1.1.0"
}
}
88 changes: 32 additions & 56 deletions pnpm-lock.yaml

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

0 comments on commit 3f48956

Please sign in to comment.