Files
supabase/studio/components
Joshen Lim 237fdb8db0 Chore/update branch selection UI (#18402)
* Set up branch selection UI in EnableBranchingModal to be text input

* Scaffold new CreateBranchModal

* Refactor Enable Branching Modal to use RHF and implement async validation

* midway updating create branch modal

* Update create branch modal with branch checking through text input

* Deprecate create branch side panel

* Remove unused import

* Small improvement to validation

* Remove console log
2023-10-24 18:29:42 +08:00
..
Fix
2023-08-28 13:37:19 +08:00
2023-10-24 11:33:53 +02:00
2023-08-07 13:56:43 +08:00

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-cleaned folder 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.tsx as 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

import { observer } from 'mobx-react-lite'

// Declare the prop types of your component
interface ComponentAProps {
  sampleProp: string
}

// Name your component accordingly
const ComponentA = ({ sampleProp }: ComponentAProps) => {
  return <div>ComponentA: {sampleProp}</div>
}

// Observer is so that components listen to mobx store changes
export default observer(ComponentA)