Skip to content

Commit

Permalink
feat: update Error to use click event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanarldt committed Dec 31, 2024
1 parent dcd193c commit 01f71c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/web/vibes/soul/examples/pages/error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function Preview() {
searchHref="#"
/>

<Error cta={{ label: 'Try again', href: '#' }} />
<Error ctaAction={() => null} />

<Subscribe
action={action}
Expand Down
27 changes: 14 additions & 13 deletions apps/web/vibes/soul/sections/error/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { ButtonLink } from '@/vibes/soul/primitives/button-link';

interface Link {
label: string;
href: string;
}
import { Button } from '@/vibes/soul/primitives/button';

interface Props {
title?: string;
subtitle?: string;
cta?: Link;
ctaLabel?: string;
ctaAction?: () => void;
}

function defaultAction() {
window.location.reload();
}

export function Error({
title = 'Something went wrong!',
subtitle = 'Please try again or contact our support team for assistance.',
cta,
ctaLabel = 'Try again',
ctaAction = defaultAction,
}: Props) {
return (
<section className="@container">
Expand All @@ -24,11 +25,11 @@ export function Error({
</h1>
<p className="text-lg text-contrast-500">{subtitle}</p>

{cta !== undefined && cta.href !== '' && cta.label !== '' && (
<ButtonLink className="mt-8" href={cta.href} size="large" type="button" variant="primary">
{cta.label}
</ButtonLink>
)}
<form action={ctaAction}>
<Button className="mt-8" size="large" type="submit" variant="primary">
{ctaLabel}
</Button>
</form>
</div>
</section>
);
Expand Down

0 comments on commit 01f71c9

Please sign in to comment.