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: update Error to use click event handler #445

Merged
merged 1 commit into from
Jan 3, 2025
Merged
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
1 change: 1 addition & 0 deletions apps/web/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }],
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": { "attributes": false } }],
"@typescript-eslint/strict-boolean-expressions": ["error", { "allowString": false }],
"complexity": ["error", 20],
"eqeqeq": ["error", "smart"],
Expand Down
10 changes: 9 additions & 1 deletion apps/web/vibes/soul/examples/pages/error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const paymentIconsArray: React.ReactNode[] = [
<Bitcoin key="Bitcoin" />,
];

async function ctaAction() {
'use server';

await new Promise<void>((resolve) => {
setTimeout(() => resolve(), 1000);
});
}

export default function Preview() {
return (
<>
Expand All @@ -67,7 +75,7 @@ export default function Preview() {
searchHref="#"
/>

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

<Subscribe
action={action}
Expand Down
23 changes: 11 additions & 12 deletions apps/web/vibes/soul/sections/error/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
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 | Promise<void>;
}

export function Error({
title = 'Something went wrong!',
subtitle = 'Please try again or contact our support team for assistance.',
cta,
ctaLabel = 'Try again',
ctaAction,
}: Props) {
return (
<section className="@container">
Expand All @@ -24,10 +21,12 @@ 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>
{ctaAction && (
<form action={ctaAction}>
<Button className="mt-8" size="large" type="submit" variant="primary">
{ctaLabel}
</Button>
</form>
)}
jorgemoya marked this conversation as resolved.
Show resolved Hide resolved
</div>
</section>
Expand Down
Loading