mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 11:55:05 +03:00
## Problem - The database role form still uses `formik` and we want to remove it in favour of `react-hook-form` to keep only one form library - The database role form does not follow the design system guidelines ## Solution - Migrate to `react-hook-form` - Apply the design system guidelines - Make sure you can toggle switches by clicking their labels too - Fix accessibility issues ## Notes In the new design system, labels for disabled inputs have the same style as those for enabled inputs ## Screenshots Before: <img width="1325" height="288" alt="image" src="https://github.com/user-attachments/assets/5e558618-3227-42be-b085-4ee388c0aff6" /> <img width="1328" height="402" alt="image" src="https://github.com/user-attachments/assets/9e41a4c2-ab38-4772-b619-548a1a0b9556" /> After: <img width="1281" height="325" alt="image" src="https://github.com/user-attachments/assets/698e526c-5ae3-4e89-bcb5-0bfee1b70f72" /> <img width="1285" height="428" alt="image" src="https://github.com/user-attachments/assets/65b30dc2-9724-4609-9fd0-f32171e37abd" />
Writing components
Where to create your components
- For components that declare the general structure and layout of a page:
/components/layouts/xxx
- For components that are tightly coupled to a specific interface:
/components/interfaces/xxx
- For components that are meant to be reusable across multiple pages:
/components/ui/xxx
- Note: We're gradually moving files out of the
to-be-cleanedfolder into the respective folders as we refactor
Component structure
- If a component has constants and utility methods that are tightly coupled to itself, keep them close to the component and enclose them in a folder with an
index.tsxas an entry point - Otherwise it can just be a file on its own
- For example:
-
components/ui - SampleComponentA - SampleComponentA.tsx - SampleComponentA.constants.ts - SampleComponentA.utils.ts - SampleComponentA.types.ts - index.ts - SampleComponentB.tsx
-
Template for building components
// Declare the prop types of your component
interface ComponentAProps {
sampleProp: string
}
// Name your component accordingly
const ComponentA = ({ sampleProp }: ComponentAProps) => {
return <div>ComponentA: {sampleProp}</div>
}
export default ComponentA