ConvoyPanel/resources/scripts/components
2024-12-22 18:57:06 -06:00
..
interfaces idk 2024-12-21 21:40:48 -06:00
layouts Snapshots/Backups WIP 2024-10-03 19:10:48 -04:00
ui Add datatables 2024-12-22 18:57:06 -06:00
README.md Refactor ui components 2024-03-16 15:46:52 -05: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

Template for building components

If props are exported


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

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

export default ComponentA

If props are not exported

interface Props {
    sampleProp: string
}

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

export default ComponentB