More composable forms #989

Merged
zachgoll merged 8 commits from zachgoll/form-builder-updates into main 2024-07-17 02:08:24 +08:00
zachgoll commented 2024-07-17 01:55:38 +08:00 (Migrated from github.com)

Did a quick run-through of the codebase to make form building a bit more composable.

Previously, ApplicationFormBuilder applied to all form instances and had started to get a little challenging to override when needed.

This PR keeps the core strategy of ApplicationFormBuilder in place, but attempts to separate out responsibilities a bit more clearly:

  • styled_form_with - a helper that allows us to "opt-in" to the form builder (rather than using it as the default for every form)
  • StyledFormBuilder - this form builder should be responsible for styling form labels + inputs. It should not attempt to style the structure of any form (e.g. spacing between inputs, layout of inputs, etc.)
  • form_helpers - I have moved most of the input helpers from the form builder to the helpers file so they can be used both inside and outside of the context of the form builder.

This PR also has a slight re-write of the "Money field" to give forms a bit more flexibility in how they deal with money inputs (currency can be removed, hidden, or directly integrated into the input).

Did a quick run-through of the codebase to make form building a bit more composable. Previously, `ApplicationFormBuilder` applied to all form instances and had started to get a little challenging to override when needed. This PR keeps the core strategy of `ApplicationFormBuilder` in place, but attempts to separate out responsibilities a bit more clearly: - `styled_form_with` - a helper that allows us to "opt-in" to the form builder (rather than using it as the default for every form) - `StyledFormBuilder` - this form builder should be responsible for styling form labels + inputs. It should not attempt to style the _structure_ of any form (e.g. spacing between inputs, layout of inputs, etc.) - `form_helpers` - I have moved most of the input helpers from the form builder to the helpers file so they can be used both inside and outside of the context of the form builder. This PR also has a slight re-write of the "Money field" to give forms a bit more flexibility in how they deal with money inputs (currency can be removed, hidden, or directly integrated into the input).
zachgoll (Migrated from github.com) reviewed 2024-07-17 02:04:35 +08:00
zachgoll (Migrated from github.com) commented 2024-07-17 01:59:51 +08:00

An interim style improvement on multi-selects:

CleanShot 2024-07-16 at 13 59 11@2x

An interim style improvement on multi-selects: ![CleanShot 2024-07-16 at 13 59 11@2x](https://github.com/user-attachments/assets/a93a106c-501f-4191-81ce-7af2e940934c)
@@ -19,6 +19,7 @@ class AccountsController < ApplicationController
end
def list
render layout: false
zachgoll (Migrated from github.com) commented 2024-07-17 02:00:36 +08:00

Bug that has been here for a while—turbo frame was linking to itself since the sidebar (part of the layout) calls this.

Bug that has been here for a while—turbo frame was linking to itself since the sidebar (part of the layout) calls this.
zachgoll (Migrated from github.com) commented 2024-07-17 02:04:17 +08:00

Previously introduced to enable custom select inputs.

Removing it as we are sticking with Rails + HTML native inputs for the time being until we get a proper design system with Lookbook + ViewComponent setup.

Previously introduced to enable custom select inputs. Removing it as we are sticking with Rails + HTML native inputs for the time being until we get a proper design system with Lookbook + ViewComponent setup.
Sign in to join this conversation.