FarmData2 / FarmData2

Main development repository for the FarmData2 Drupal module.
Other
1 stars 6 forks source link

Components: Improve prop / update idiom consistency #167

Open braughtg opened 2 months ago

braughtg commented 2 months ago

Currently components are handling props in different ways (e.g. with v-bind + watch or v-model). it would be better to have a consistent idiom for the way(s) that components handle props. This issue outlines a proposal for discussion and eventual implementation:

A component will include a prop for:

A prop that is not changed by the component (required, showValidityStyling, label, options, etc) will be used directly in the template (e.g. v-bind or {{ }}. There is no need to store them in a local data value or watch them.

For a prop representing a value collected by the component:

Note: This structure means avoiding the v-model shortcut for updating a data value without a v-on when its component changes. The reason for doing that is that we need to emit the update event anyway, so we still need the v-on and by doing the update manually it is more explicit and consistent across all values making the code easier to understand.

When the idiom is finalized,

The components that should be evaluated and refactored are:

braughtg commented 2 months ago

Seems like there is a difference between a base component that is using the BootstrapVueNext components and one that is using the FarmData2 components.

I think it may be necessary to have two distinct idioms. One for when using a FarmData2 component as a sub-component and one when using a BootStrapVueNext component as a sub-component.