Greater-London-Authority / ldn-viz-tools

https://greater-london-authority.github.io/ldn-viz-tools/
1 stars 0 forks source link

Proposal to replace individual modal props with a modalProps prop for components like SidebarHint and Tooltip #314

Open PaulioRandall opened 1 month ago

PaulioRandall commented 1 month ago

Is your feature request related to a problem? Please describe.

Currently modal properties supplied to components that allow opening and closing of a modal use the following props:

While this suffices, any additional properties will need to be added to each dependent component. It also means extra work is needed to make sure these props align across all dependent components.

Describe the solution you'd like

Specify a single object property called modalProps, e.g:

<SidebarHint modalProps={{
  modalDescription: "More information will be made available as it is published.",
  modalTitle: "More information",
}}>

<Tooltip modalProps={{
  modalTitle: "Visitor Counts (BT Footfall)",
  modalWidth: "xl",
}}>

It's easy to check for errors in specifying these objects using an interface or type exposed by the modal package (perhaps in a <script context="module"> tag):

interface ModalProps {
  modalTitle: string;
  modalDescription?: string;
  modalWidth?: string;
}

This pattern can be applied in other areas where multiple props are passed specifically and only to a single sub component.

Describe alternatives you've considered

None.

Additional context

None.