Skip to content

Commit 88c7f3e

Browse files
authored
Merge pull request #60 from DouglasNeuroInformatics/dev
fix some styling issues
2 parents cffedae + d00545f commit 88c7f3e

File tree

8 files changed

+43
-29
lines changed

8 files changed

+43
-29
lines changed

src/components/Form/ErrorMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { cn } from '@/utils';
66

77
export const ErrorMessage: React.FC<{ className?: string; error?: null | string[] }> = ({ className, error }) => {
88
return error ? (
9-
<div className="space-y-1.5">
9+
<div className="flex flex-col gap-1.5">
1010
{error.map((message) => (
1111
<div className={cn('text-destructive flex w-full items-center text-sm font-medium', className)} key={message}>
1212
<CircleAlertIcon className="mr-1" style={{ strokeWidth: '2px' }} />

src/components/Form/Form.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ const ungroupedContent = {
302302
} as const;
303303

304304
export default {
305+
args: {
306+
onBeforeSubmit: null
307+
},
305308
component: Form,
306309
decorators: [
307310
(Story) => (

src/components/Form/Form.tsx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { cn } from '@/utils';
1717

1818
import { Button } from '../Button';
1919
import { Heading } from '../Heading';
20+
import { Separator } from '../Separator';
2021
import { ErrorMessage } from './ErrorMessage';
2122
import { FieldsComponent } from './FieldsComponent';
2223
import { getInitialValues } from './utils';
@@ -38,7 +39,9 @@ type FormProps<TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<T
3839
fieldsFooter?: React.ReactNode;
3940
id?: string;
4041
initialValues?: PartialNullableFormDataType<NoInfer<TData>>;
41-
onBeforeSubmit?: (data: NoInfer<TData>) => Promisable<{ errorMessage: string; success: false } | { success: true }>;
42+
onBeforeSubmit?:
43+
| ((data: NoInfer<TData>) => Promisable<{ errorMessage: string; success: false } | { success: true }>)
44+
| null;
4245
onError?: (error: z.ZodError<NoInfer<TData>>) => void;
4346
onSubmit: (data: NoInfer<TData>) => Promisable<void>;
4447
preventResetValuesOnReset?: boolean;
@@ -165,7 +168,7 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
165168
return (
166169
<form
167170
autoComplete="off"
168-
className={twMerge('relative w-full', isGrouped ? 'space-y-8 divide-y' : 'space-y-6', className)}
171+
className={twMerge('relative flex w-full flex-col', !isGrouped && 'gap-6', className)}
169172
id={id}
170173
onBlur={revalidateOnBlur ? revalidate : undefined}
171174
onSubmit={(event) => void handleSubmit(event)}
@@ -175,26 +178,29 @@ const Form = <TSchema extends z.ZodType<FormDataType>, TData extends z.TypeOf<TS
175178
{isGrouped ? (
176179
content.map((fieldGroup, i) => {
177180
return (
178-
<div className="flex flex-col space-y-6 [&:not(:first-child)]:pt-8" key={i}>
179-
<div className="space-y-1">
180-
{fieldGroup.title && (
181-
<Heading className="text-base" variant="h4">
182-
{fieldGroup.title}
183-
</Heading>
184-
)}
185-
{fieldGroup.description && (
186-
<p className="text-muted-foreground text-sm leading-tight italic">{fieldGroup.description}</p>
187-
)}
181+
<>
182+
<div className="flex flex-col gap-6 [&:not(:first-child)]:pt-8" key={i}>
183+
<div className="flex flex-col gap-1">
184+
{fieldGroup.title && (
185+
<Heading className="text-base" variant="h4">
186+
{fieldGroup.title}
187+
</Heading>
188+
)}
189+
{fieldGroup.description && (
190+
<p className="text-muted-foreground text-sm leading-tight italic">{fieldGroup.description}</p>
191+
)}
192+
</div>
193+
<FieldsComponent
194+
errors={errors}
195+
fields={fieldGroup.fields as FormFields<TData>}
196+
readOnly={readOnly}
197+
setErrors={setErrors}
198+
setValues={setValues}
199+
values={values}
200+
/>
188201
</div>
189-
<FieldsComponent
190-
errors={errors}
191-
fields={fieldGroup.fields as FormFields<TData>}
192-
readOnly={readOnly}
193-
setErrors={setErrors}
194-
setValues={setValues}
195-
values={values}
196-
/>
197-
</div>
202+
<Separator className="mt-8" />
203+
</>
198204
);
199205
})
200206
) : (

src/components/Form/NumberRecordField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ export const NumberRecordField = <T extends NumberRecordFieldValue = NumberRecor
4747
}
4848

4949
return (
50-
<div className="space-y-4">
50+
<div className="flex flex-col gap-4">
5151
<Heading className="font-medium" variant="h5">
5252
{label}
5353
</Heading>
54-
<div className="space-y-6">
54+
<div className="flex flex-col gap-6">
5555
{Object.keys(items).map((name) => {
5656
const item = items[name]!;
5757
return (

src/components/Form/RecordArrayField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ export const RecordArrayField = memo(function RecordArrayField({
5959
};
6060

6161
return (
62-
<div className="space-y-4">
62+
<div className="flex flex-col gap-4">
6363
<Heading className="font-medium" variant="h5">
6464
{label}
6565
</Heading>
66-
<div className="space-y-6">
66+
<div className="flex flex-col gap-6">
6767
{arrayValue.map((fields, i) => (
68-
<div className="space-y-4" key={i}>
68+
<div className="flex flex-col gap-4" key={i}>
6969
<Label className="font-semibold italic">{label + ' ' + (i + 1)}</Label>
7070
{Object.keys(fields).map((name) => {
7171
const field = fieldset[name];

src/components/OneTimePasswordInput/OneTimePasswordInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const OneTimePasswordInput = ({ className, onComplete, ...props }: OneTim
8989
<div className={cn('flex gap-2', className)} {...props}>
9090
{digits.map((_, index) => (
9191
<input
92-
className="w-1/6 rounded-md border border-slate-300 bg-transparent p-2 shadow-xs hover:border-slate-300 focus:border-sky-800 focus:outline-hidden dark:border-slate-600 dark:hover:border-slate-400 dark:focus:border-sky-500"
92+
className="w-1/6 rounded-md border border-slate-300 bg-transparent p-2 text-center shadow-xs hover:border-slate-300 focus:border-sky-800 focus:outline-hidden dark:border-slate-600 dark:hover:border-slate-400 dark:focus:border-sky-500"
9393
key={index}
9494
maxLength={1}
9595
ref={inputRefs[index]}

src/hooks/useOnClickOutside/useOnClickOutside.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEventListener } from '../useEventListener';
44

55
type Handler = (event: MouseEvent) => void;
66

7-
export function useOnClickOutside<T extends HTMLElement = HTMLElement>(
7+
export function useOnClickOutside<T extends HTMLElement | null = HTMLElement>(
88
ref: RefObject<T>,
99
handler: Handler,
1010
mouseEvent: 'mousedown' | 'mouseup' = 'mousedown'

src/tailwind/globals.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@
181181

182182
--radius: 0.5rem;
183183
}
184+
185+
button:not(:disabled),
186+
[role='button']:not(:disabled) {
187+
cursor: pointer;
188+
}
184189
}
185190

186191
@layer base {

0 commit comments

Comments
 (0)