Skip to content

Commit 1841c00

Browse files
authored
Merge pull request #57 from DouglasNeuroInformatics/dev
update
2 parents ccb6115 + 5e1c044 commit 1841c00

File tree

15 files changed

+166
-43
lines changed

15 files changed

+166
-43
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,8 @@ dist
132132
# Storybook
133133
storybook-static
134134

135-
#VScode
136-
.vscode
135+
# VScode
136+
.vscode
137+
138+
# Local Scripts
139+
local/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"zod": "^3.23.6"
6969
},
7070
"dependencies": {
71-
"@douglasneuroinformatics/libjs": "^2.7.0",
71+
"@douglasneuroinformatics/libjs": "^2.8.0",
7272
"@douglasneuroinformatics/libui-form-types": "^0.11.0",
7373
"@radix-ui/react-accordion": "^1.2.3",
7474
"@radix-ui/react-alert-dialog": "^1.1.6",

pnpm-lock.yaml

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const BUTTON_ICON_SIZE = {
1414
};
1515

1616
export const buttonVariants = cva(
17-
'flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
17+
'flex items-center justify-center whitespace-nowrap cursor-pointer rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
1818
{
1919
defaultVariants: {
2020
size: 'md',

src/components/Dialog/DialogContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const DialogContent = forwardRef<
1616
<DialogOverlay />
1717
<Content
1818
className={cn(
19-
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg',
19+
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg',
2020
className
2121
)}
2222
ref={ref}

src/components/Dialog/DialogOverlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const DialogOverlay = forwardRef<
1111
return (
1212
<Overlay
1313
className={cn(
14-
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
14+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80 duration-200',
1515
className
1616
)}
1717
ref={ref}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { describe, expect, it } from 'vitest';
3+
4+
import { ErrorFallback } from './ErrorFallback';
5+
6+
const TEST_ID = 'error-fallback';
7+
8+
describe('ErrorFallback', () => {
9+
it('should render', () => {
10+
const error = new Error('Something went wrong');
11+
render(<ErrorFallback error={error} />);
12+
expect(screen.getByTestId(TEST_ID)).toBeInTheDocument();
13+
});
14+
});

src/components/ErrorFallback/ErrorFallback.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ export const ErrorFallback = ({ error }: ErrorFallbackProps) => {
1212
}, [error]);
1313

1414
return (
15-
<div className="flex min-h-screen flex-col items-center justify-center gap-1 p-3 text-center">
16-
<h1 className="text-sm font-semibold uppercase tracking-wide text-muted-foreground">Unexpected Error</h1>
15+
<div
16+
className="flex min-h-screen flex-col items-center justify-center gap-1 p-3 text-center"
17+
data-testid="error-fallback"
18+
>
19+
<h1 className="text-muted-foreground text-sm font-semibold tracking-wide uppercase">Unexpected Error</h1>
1720
<h3 className="text-3xl font-extrabold tracking-tight sm:text-4xl md:text-5xl">Something Went Wrong</h3>
18-
<p className="mt-2 max-w-prose text-sm text-muted-foreground sm:text-base">
21+
<p className="text-muted-foreground mt-2 max-w-prose text-sm sm:text-base">
1922
We apologize for the inconvenience. Please contact us for further assistance.
2023
</p>
2124
<div className="mt-6">

src/components/Form/ErrorMessage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import * as React from 'react';
22

33
import { CircleAlertIcon } from 'lucide-react';
44

5-
export const ErrorMessage: React.FC<{ error?: null | string[] }> = ({ error }) => {
5+
import { cn } from '@/utils';
6+
7+
export const ErrorMessage: React.FC<{ className?: string; error?: null | string[] }> = ({ className, error }) => {
68
return error ? (
79
<div className="space-y-1.5">
810
{error.map((message) => (
9-
<div className="flex w-full items-center text-sm font-medium text-destructive" key={message}>
11+
<div className={cn('text-destructive flex w-full items-center text-sm font-medium', className)} key={message}>
1012
<CircleAlertIcon className="mr-1" style={{ strokeWidth: '2px' }} />
11-
<span>{message}</span>
13+
<span data-testid="error-message-text">{message}</span>
1214
</div>
1315
)) ?? null}
1416
</div>

src/components/Form/Form.stories.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,3 +530,27 @@ export const WithSuspend: StoryObj<typeof Form<z.ZodType<FormTypes.Data>, { dela
530530
})
531531
}
532532
};
533+
534+
export const WithError: StoryObj<typeof Form> = {
535+
args: {
536+
content: {
537+
name: {
538+
kind: 'string',
539+
label: 'Name',
540+
variant: 'input'
541+
}
542+
},
543+
beforeSubmit: (data) => {
544+
if (data.name === 'Winston') {
545+
return { success: true };
546+
}
547+
return { success: false, errorMessage: "Name must be 'Winston'" };
548+
},
549+
onSubmit: () => {
550+
alert('Success!');
551+
},
552+
validationSchema: $SimpleExampleFormData.extend({
553+
name: z.string().min(3)
554+
})
555+
}
556+
};

0 commit comments

Comments
 (0)