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: initial version of Deno Hunt and restructure #106

Merged
merged 8 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ This will automatically configure the database tables and their settings for us.
3. Listen locally to Stripe events:

```
stripe listen --forward-to localhost:8000/api/subscription
stripe listen --forward-to localhost:8000/api/stripe-webhooks
```

4. Copy the webhook signing secret to [.env](.env) as `STRIPE_WEBHOOK_SECRET`.
Expand Down Expand Up @@ -146,7 +146,7 @@ as the user will be taken to Stripe's checkout page when they upgrade.
Keep your `customers` database up to date with billing changes by
[registering a webhook endpoint in Stripe](https://stripe.com/docs/development/dashboard/register-webhook).

- Endpoint URL: `https://{{ YOUR DOMAIN }}/api/subscription`
- Endpoint URL: `https://{{ YOUR DOMAIN }}/api/stripe-webhooks`
- Listen to `Events on your account`
- Select `customer.subscription.created` and `customer.subscription.deleted`

Expand Down
2 changes: 1 addition & 1 deletion components/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface AuthFormProps {

export default function AuthForm({ type }: AuthFormProps) {
return (
<form method="POST" class="space-y-4" action={`/api/${type.toLowerCase()}`}>
<form method="POST" class="space-y-4" action={`/${type.toLowerCase()}`}>
<input
placeholder="Email"
name="email"
Expand Down
110 changes: 0 additions & 110 deletions components/Dashboard.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions components/Footer.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions components/Header.tsx

This file was deleted.

119 changes: 119 additions & 0 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
import type { ComponentChild, ComponentChildren, JSX } from "preact";
import { BASE_SITE_WIDTH_STYLES, SITE_NAME } from "@/utils/constants.ts";
import Logo from "./Logo.tsx";

interface NavProps extends JSX.HTMLAttributes<HTMLElement> {
active?: string;
items: (JSX.HTMLAttributes<HTMLAnchorElement> & { inner: ComponentChild })[];
}

function Nav(props: NavProps) {
return (
<nav>
<ul
class={`flex gap-x-8 gap-y-2 items-center justify-between h-full ${
props.class ?? ""
}`}
>
{props.items.map((item) => (
<li>
<a href={item.href}>{item.inner}</a>
</li>
))}
</ul>
</nav>
);
}

function Header(props: JSX.HTMLAttributes<HTMLElement>) {
return (
<header
{...props}
class={`p-8 justify-between ${BASE_SITE_WIDTH_STYLES} flex z-10 ${
props.class ?? ""
}`}
>
<a href="/">
<Logo height="48" />
</a>
{props.children}
</header>
);
}

function Footer(props: JSX.HTMLAttributes<HTMLElement>) {
return (
<footer
{...props}
class={`flex flex-col md:flex-row p-8 justify-between gap-y-4 ${BASE_SITE_WIDTH_STYLES} ${
props.class ?? ""
}`}
>
<span>
<strong>{SITE_NAME}</strong>
</span>
{props.children}
</footer>
);
}

interface LayoutProps {
children: ComponentChildren;
}

export default function Layout(props: LayoutProps) {
/** @todo Make dynamic */
const headerNavItems = [
{
href: "/blog",
inner: "Blog",
},
{
href: "/submit",
inner: "Submit",
},
{
href: "/account",
inner: "Account",
},
{
href: "/login",
inner: "Login",
},
{
href: "/logout",
inner: "Logout",
},
];

const footerNavItems = [
{
inner: "Source code",
href: "https://github.com/denoland/saaskit",
},
{
href: "https://fresh.deno.dev",
inner: (
<img
width="197"
height="37"
src="https://fresh.deno.dev/fresh-badge.svg"
alt="Made with Fresh"
/>
),
},
];

return (
<div class="flex flex-col min-h-screen">
<Header>
<Nav items={headerNavItems} />
</Header>
{props.children}
<Footer>
<Nav items={footerNavItems} />
</Footer>
</div>
);
}
25 changes: 0 additions & 25 deletions components/Nav.tsx

This file was deleted.

7 changes: 4 additions & 3 deletions components/OAuthLoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
import type { Provider } from "@supabase/supabase-js";
import type { ComponentChild } from "preact";
import { BASE_BUTTON_STYLES } from "@/utils/constants.ts";

interface OAuthLoginButtonProps {
provider: Provider;
Expand All @@ -10,11 +9,13 @@ interface OAuthLoginButtonProps {

export default function OAuthLoginButton(props: OAuthLoginButtonProps) {
return (
<form action="/api/oauth" method="POST">
<form action="/login/oauth" method="POST">
<input type="hidden" value={props.provider} name="provider" />
<button
type="submit"
class={`w-full !bg-white !text-black border-black border-2 align-middle ${BASE_BUTTON_STYLES}`}
class="px-4 py-2 w-full bg-white text-black text-lg rounded-lg border-2 border-black disabled:(opacity-50 cursor-not-allowed)"
/** @todo disabled for preview deployment */
disabled
>
{props.children}
</button>
Expand Down
Loading