Files
supabase/apps/docs/components/Feedback/FeedbackModal.tsx
Ivan Vasilov 308cd791a2 chore: Prep work for migrating to Tailwind v4 (#45285)
This PR preps the monorepo for a migration to Tailwind v4:
- Bump all Tailwind dependencies and libraries to the latest possible
version, while still compatible with Tailwind 3.
- Cleans up obsolete Tailwind 3 specific options and configs.
- Cleans up unused CSS files and fixes the CSS imports.
- Migrates all `important` uses in `@apply` lines to using the `!`
prefix.
- Move `typography.css` to the `config` package and import it from the
apps.
- Migrated all occurrences of `flex-grow`, `flex-shrink`,
`overflow-clip` and `overflow-ellipsis` since they're deprecated and
will be removed in Tailwind 4.
- Make the default theme object typesafe in the `ui` package.
- Migrate all `bg-opacity`, `border-opacity`, `ring-opacity` and
`divider-opacity` to the new format where they're declared as part of
the property color.
- Bump and unify all imports of `postcss` dependency.
2026-04-28 11:33:53 +02:00

114 lines
3.6 KiB
TypeScript

import { zodResolver } from '@hookform/resolvers/zod'
import { SubmitHandler, useForm } from 'react-hook-form'
import { Button, Form, FormControl, FormField, Input_Shadcn_, Modal, Textarea } from 'ui'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import * as z from 'zod'
const formSchema = z.object({
page: z.string(),
title: z.string().min(1, 'Required'),
comment: z.string().min(1, 'Required'),
})
export type FeedbackFields = z.infer<typeof formSchema>
type FeedbackModalProps = {
visible: boolean
page: string
onCancel: () => void
onSubmit: (values: FeedbackFields) => void
}
function FeedbackModal({ visible, page, onCancel, onSubmit }: FeedbackModalProps) {
const form = useForm<FeedbackFields>({
defaultValues: { page, title: '', comment: '' },
resolver: zodResolver(formSchema),
})
const { reset } = form
const { isSubmitting } = form.formState
const handleCancel = () => {
reset()
onCancel()
}
const handleSubmit: SubmitHandler<FeedbackFields> = (values) => {
onSubmit(values)
reset()
}
return (
<Modal
hideFooter
header="Leave a comment"
visible={visible}
onCancel={handleCancel}
onEscapeKeyDown={handleCancel}
>
<Form {...form}>
<form onSubmit={form.handleSubmit(handleSubmit)}>
<Modal.Content className="pt-4 pb-2 flex flex-col gap-2">
<input type="hidden" id="page" {...form.register('page')} />
<FormField
control={form.control}
name="title"
render={({ field }) => (
<FormItemLayout layout="vertical" label="Title">
<FormControl className="col-span-6">
<Input_Shadcn_ {...field} />
</FormControl>
</FormItemLayout>
)}
/>
<FormField
control={form.control}
name="comment"
render={({ field }) => (
<FormItemLayout layout="vertical" label="Comment" afterLabel="(not anonymous)">
<FormControl className="col-span-6">
<Textarea {...field} rows={4} className="resize-none" />
</FormControl>
</FormItemLayout>
)}
/>
<div className="flex gap-2 text-xs text-foreground-light leading-relaxed">
<span className="shrink-0 mt-0.5">💡</span>
<div>
<strong>Need help or support?</strong> This feedback form is for documentation
improvements only. For technical support, please submit a{' '}
<a
href="https://supabase.com/dashboard/support/new"
target="_blank"
rel="noopener noreferrer"
className="text-brand-link hover:underline"
>
support request
</a>
.
</div>
</div>
</Modal.Content>
<Modal.Separator />
<Modal.Content className="pt-2 pb-4">
<div className="flex items-center justify-end gap-2">
<Button
htmlType="reset"
type="default"
onClick={handleCancel}
disabled={isSubmitting}
>
Cancel
</Button>
<Button htmlType="submit" loading={isSubmitting} disabled={isSubmitting}>
Submit feedback
</Button>
</div>
</Modal.Content>
</form>
</Form>
</Modal>
)
}
export { FeedbackModal }