Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add margin_bottom option to component wrapper helper #4494

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Dec 11, 2024

What

Adds a margin_bottom option to the component wrapper helper, effectively copying it out of the shared_helper.

I wanted to write a new set of classes here for margins to stop using the govuk-frontend margin override classes, because they should only be used where an override is necessary (they use !important). However right out the gate it turns out we do need the override classes - just to override the default margin applied to some of the govuk-frontend components (details, for example, where we want a 15px margin and the component comes with 30px by default).

Supercedes #4470

Why

The CW helper seems like the more logical home for this option, rather than the shared helper. Additionally, cleaning up and standardising this will help us make component spacing more consistent later.

I'd remove the shared_helper margin option entirely but other parts of our code are using it, so it seems better to roll out this addition, switch, then remove it from the shared_helper later.

Visual Changes

Hopefully none.

Trello card: https://trello.com/c/Y0pDWbHw/242-move-some-shared-helper-options-into-component-wrapper

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 14:35 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch from 5b71b81 to 3ba2107 Compare December 11, 2024 15:34
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 15:35 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch from 3ba2107 to cb1ea96 Compare December 11, 2024 16:14
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 16:14 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch from cb1ea96 to 458624c Compare December 11, 2024 16:16
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 16:17 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch 2 times, most recently from 1236093 to bdd8464 Compare December 11, 2024 16:31
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 16:32 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch from bdd8464 to c82b361 Compare December 11, 2024 16:41
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 16:41 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 11, 2024 17:06 Inactive
@andysellick andysellick force-pushed the component-wrapper-margin branch from 6ec0fd1 to 6aee663 Compare December 12, 2024 09:23
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 12, 2024 09:23 Inactive
@andysellick andysellick marked this pull request as ready for review December 12, 2024 09:23
@andysellick andysellick requested a review from AshGDS December 12, 2024 09:23
Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work 👍 Just needs a changelog entry, and I left a non-blocking comment

@@ -65,6 +66,9 @@ The component wrapper includes several methods to make managing options easier,
aria_attributes ||= {}
role ||= nil

# margin_bottom will be applied by default, use this line to set a different default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth rewording this a bit, until I read the ruby code I thought this meant that every component using the wrapper will get a margin bottom by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, have removed. That was a hangover from an earlier attempt at this.

@andysellick andysellick force-pushed the component-wrapper-margin branch from 6aee663 to 2ac1f9e Compare December 13, 2024 10:36
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 13, 2024 10:37 Inactive
- add a margin_bottom option, which accepts a number from the govuk-frontend spacing scale to set margin bottom on components. Slightly tricky as it overlaps onto another option - classes - but all we have to do is check the number, generate the right class based on the number, then add it to the end of the classes as they are passed out from all_attributes
- defaults to no margin and no margin class output
- rewrite the component wrapper helper tests a little, firstly to make more specific, secondly to structure and group the tests a bit more logically for readability
- update a trio of components that were broken by these changes, by removing their use of the shared helper for this same functionality and updating tests accordingly
- switch any components using the shared_helper for margin_bottom, that also use the component wrapper helper, to not use the shared_helper for margin_bottom
- note that some components still use the shared_helper for margin_bottom, but aren't using the component wrapper helper yet, so can't be switched
@andysellick andysellick force-pushed the component-wrapper-margin branch from 2ac1f9e to bfad545 Compare December 13, 2024 10:38
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 13, 2024 10:38 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4494 December 13, 2024 10:39 Inactive
@andysellick andysellick merged commit e45c502 into main Dec 13, 2024
12 checks passed
@andysellick andysellick deleted the component-wrapper-margin branch December 13, 2024 10:41
@andysellick andysellick mentioned this pull request Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants