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 custom css exclude list to Asset Helper #4656

Merged
merged 7 commits into from
Mar 5, 2025
Merged

Conversation

KludgeKML
Copy link
Contributor

@KludgeKML KludgeKML commented Feb 26, 2025

What

Add an option to supply a custom css exclude list - this is like the current list that excludes anything always supplied by static from the individual component support, but for non-static based apps, where they might as a stopgap want to provide their own application.css with a hardcoded list of styles to include, but that might not be the same list as static's list.

Also mild refactoring of the asset helper to improve test coverage.

Why

To support a bundled set of stylesheets for email-alert-frontend, as here: alphagov/email-alert-frontend#1890.

https://trello.com/c/O6JhukLu/487-remove-slimmer-email-alert-frontend

Visual Changes

None.

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 February 26, 2025 11:55 Inactive
@KludgeKML KludgeKML changed the title Custom css exclude list Add custom css exclude list to Asset Helper Feb 27, 2025
@KludgeKML KludgeKML force-pushed the custom-css-exclude-list branch from 4be7861 to 23b3184 Compare February 27, 2025 16:21
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 February 27, 2025 16:21 Inactive
@KludgeKML KludgeKML force-pushed the custom-css-exclude-list branch from 23b3184 to 39482d9 Compare February 27, 2025 16:59
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 February 27, 2025 16:59 Inactive
@KludgeKML KludgeKML marked this pull request as ready for review February 27, 2025 17:03
@KludgeKML KludgeKML force-pushed the custom-css-exclude-list branch from 39482d9 to de924eb Compare March 3, 2025 09:27
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 March 3, 2025 09:27 Inactive
- Add a translation function
  that adds the required path
  to the list of components.

- Make the method always use an exclusion array, which is set
  by another method to either an empty array or the static
  exclude array.
- We don't have explicit tests for when we've got
  exclude_css_from_static set and we're visiting the
  component guide. Add that test, and also replace the
  chained safe navigation operator with a guard clause (we
  might not get a request, but if we do get one, it will
  definitely be a request.
- this adds another option to the asset helper's css_exclude_list
  method - if a custom exclude list is set, return that if we're not
  in the component guide (ignoring the STATIC_STYLESHEET_LIST)
- We want this for applications that don't use static, but will benefit
  from having a small number of hardcoded component styles in
  their application stylesheets (this is a stepping stone to getting
  back to a shared basic styles stylesheet without static).
- scenarios don't seem to reset config,
  so we also need to explicitly set this
  to nil in other tests
@KludgeKML KludgeKML force-pushed the custom-css-exclude-list branch from de924eb to e4ef91c Compare March 4, 2025 16:00
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 March 4, 2025 16:01 Inactive
Copy link
Contributor

@MartinJJones MartinJJones left a comment

Choose a reason for hiding this comment

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

Very nice work on this! I like the addition of the custom_css_exclude_list feature, the refactored code and updated tests look good to me as well 👍

Looks like it needs a Changelog entry

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4656 March 5, 2025 10:57 Inactive
@KludgeKML
Copy link
Contributor Author

Looks like it needs a Changelog entry

Ah yeah, this is definitely not purely internal! Thanks, added!

@KludgeKML KludgeKML merged commit 855071b into main Mar 5, 2025
12 checks passed
@KludgeKML KludgeKML deleted the custom-css-exclude-list branch March 5, 2025 11:00
@andysellick andysellick mentioned this pull request Mar 5, 2025
KludgeKML added a commit to alphagov/email-alert-frontend that referenced this pull request Mar 6, 2025
- This version has the custom_css_exclude_list feature (alphagov/govuk_publishing_components#4656)
  needed for the bundle css to work without individually loading
  stylesheets for the bundled components.
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