Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 3 additions & 1 deletion packages/starpod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ validates your config and lists every problem with its field path.
and YouTube
- `rssFeed` — the feed your episodes are read from at build time
- `links` (optional) — extra navigation links after About and Contact, e.g.
`[{ label: 'Store', href: 'https://example.com/store' }]`
`[{ label: 'Store', href: 'https://example.com/store', icon: 'store' }]`.
`icon` is one of `external`, `heart`, `link`, `sponsor`, or `store`; it
defaults to `external` for URLs and `link` for local pages.

## Video

Expand Down
3 changes: 0 additions & 3 deletions packages/starpod/src/assets/rocket-dark.svg

This file was deleted.

3 changes: 0 additions & 3 deletions packages/starpod/src/assets/rocket-light.svg

This file was deleted.

14 changes: 7 additions & 7 deletions packages/starpod/src/components/AdPackageCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ export interface Props {
const { bullets, heading, price } = Astro.props;
---

<div class="dark:bg-dark-background relative z-10 mb-6 rounded-lg bg-white p-1">
<div class="bg-surface relative z-10 mb-6 rounded-lg p-1">
<h2
class="bg-light-card text-light-text-heading dark:bg-dark-card px-5 py-4 font-bold lg:py-6 dark:text-white"
class="bg-raised text-ink px-5 py-4 font-bold lg:py-6"
>
{heading}
</h2>

<ul class="list-disc px-8">
{
bullets.map((bullet) => {
return <li class="dark:border-dark-border border-b py-6">{bullet}</li>;
return <li class="border-line border-b py-6">{bullet}</li>;
})
}

<h3
class="text-light-text-heading mt-8 mb-12 px-5 text-4xl font-bold tabular-nums dark:text-white"
class="text-ink mt-8 mb-12 px-5 text-4xl font-bold tabular-nums"
>
{price}
<span
class="text-light-text-body dark:text-dark-text-body text-3xl font-light"
class="text-text text-3xl font-light"
>
/
</span>
<span class="text-light-text-body dark:text-dark-text-body text-2xl">
<span class="text-text text-2xl">
per episode
</span>
</h3>

<div class="flex w-full">
<a class="btn mb-8 w-full justify-center" href="/contact">
<span
class="text-light-text-heading rounded-full px-8 py-3 text-center text-sm dark:text-white"
class="text-ink rounded-full px-8 py-3 text-center text-sm"
>
Become a sponsor
</span>
Expand Down
127 changes: 85 additions & 42 deletions packages/starpod/src/components/ContactForm.tsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,113 @@
import { useState } from 'preact/hooks';

type Status =
| { state: 'idle' }
| { state: 'sending' }
| { state: 'sent'; message: string }
| { state: 'error'; message: string };

const FIELD =
'block w-full rounded-xl border border-line bg-surface px-4 py-3 text-ink placeholder:text-muted outline-none! transition-[border-color,box-shadow] duration-200 focus:border-accent focus:ring-4 focus:ring-accent-soft';
const LABEL = 'text-ink mb-2 block text-sm font-semibold';

export default function ContactForm() {
const [formSubmitted, setFormSubmitted] = useState(false);
const [responseMessage, setResponseMessage] = useState('');
const [status, setStatus] = useState<Status>({ state: 'idle' });

async function submit(e: SubmitEvent) {
e.preventDefault();
setStatus({ state: 'sending' });

const formData = new FormData(e.target as HTMLFormElement);
try {
const response = await fetch('/api/contact', {
method: 'POST',
body: formData
});
const data = await response.json().catch(() => ({}));
const message: string | undefined = data.message ?? data.error?.message;

const data = await response.json();
setStatus(
response.ok
? { state: 'sent', message: message ?? 'Thanks! Your message is on its way.' }
: {
state: 'error',
message: message ?? 'Your message didn’t go through. Please try again.'
}
);
} catch {
setStatus({
state: 'error',
message: 'We couldn’t reach the server. Check your connection and try again.'
});
}
}

if (data.message) {
setResponseMessage(data.message);
}
if (response.ok) {
setFormSubmitted(true);
}
} catch {}
if (status.state === 'sent') {
return (
<div
class="border-line bg-surface max-w-xl rounded-2xl border p-6"
role="status"
>
<p class="text-ink m-0 text-lg font-bold">Message sent</p>
<p class="text-text mt-1 mb-0">{status.message}</p>
</div>
);
}

const sending = status.state === 'sending';

return (
<>
{formSubmitted ? (
`${responseMessage}`
) : (
<form class="flex flex-col gap-2" onSubmit={submit}>
<form class="flex max-w-xl flex-col gap-5" onSubmit={submit}>
<div class="grid gap-5 sm:grid-cols-2">
<div>
<label class={LABEL} for="name">
Name
</label>
<input autocomplete="name" class={FIELD} id="name" name="name" required type="text" />
</div>
<div>
<label class={LABEL} for="email">
Email
</label>
<input
class="input"
type="text"
id="name"
name="name"
placeholder="Enter your name"
required
/>
<input
class="input"
type="email"
autocomplete="email"
class={FIELD}
id="email"
name="email"
placeholder="Enter your email"
required
type="email"
/>
</div>
</div>

<textarea
class="input"
id="message"
name="message"
placeholder="Write a message"
required
/>
<div>
<label class={LABEL} for="message">
Message
</label>
<textarea
class={`${FIELD} min-h-40 resize-y`}
id="message"
name="message"
placeholder="A question, a topic for the show, a whiskey we should try…"
required
/>
</div>

<div class="my-6 flex w-full justify-end">
<button class="btn w-full justify-center lg:w-auto">
<span class="text-light-text-heading rounded-full px-12 py-3 text-center text-sm dark:text-white">
Submit
</span>
</button>
</div>
</form>
{status.state === 'error' && (
<p class="text-ink border-line m-0 rounded-xl border px-4 py-3 text-sm" role="alert">
{status.message}
</p>
)}
</>

<div>
<button
class="button-primary w-full justify-center disabled:cursor-progress disabled:opacity-70 sm:w-auto"
disabled={sending}
type="submit"
>
{sending ? 'Sending…' : 'Send message'}
</button>
</div>
</form>
);
}
43 changes: 32 additions & 11 deletions packages/starpod/src/components/InfoCard.astro
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
---
import starpodConfig from 'virtual:starpod/config';
import { ArrowOutIcon, InfoIcon, MailIcon } from './icons';
import type { NavLinkIcon } from '../utils/config';
import {
ArrowOutIcon,
BagIcon,
HeartIcon,
InfoIcon,
LinkIcon,
MailIcon,
MegaphoneIcon
} from './icons';

const links = starpodConfig.links ?? [];
const path = Astro.url.pathname.replace(/\/$/, '');
const isExternal = (href: string) => /^https?:\/\//.test(href);
const ICONS: Record<NavLinkIcon, typeof LinkIcon> = {
external: ArrowOutIcon,
heart: HeartIcon,
link: LinkIcon,
sponsor: MegaphoneIcon,
store: BagIcon
};
const iconFor = (link: (typeof links)[number]) =>
ICONS[link.icon ?? (isExternal(link.href) ? 'external' : 'link')];
---

<a aria-current={path === '/about' ? 'page' : undefined} href="/about">
Expand All @@ -16,14 +34,17 @@ const isExternal = (href: string) => /^https?:\/\//.test(href);
<span>Contact</span>
</a>
{
links.map((link) => (
<a
aria-current={path === link.href ? 'page' : undefined}
href={link.href}
rel={isExternal(link.href) ? 'noopener' : undefined}
>
<ArrowOutIcon />
<span>{link.label}</span>
</a>
))
links.map((link) => {
const Icon = iconFor(link);
return (
<a
aria-current={path === link.href ? 'page' : undefined}
href={link.href}
rel={isExternal(link.href) ? 'noopener' : undefined}
>
<Icon />
<span>{link.label}</span>
</a>
);
})
}
Loading
Loading