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

Update on this page and disclosure components to use SVG icons #3261

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

davidrapson
Copy link
Contributor

@davidrapson davidrapson commented Mar 25, 2024

Background

We currently ship two different sets of icons within the design system. A new SVG icon set and the previous icon font. We've long wanted to remove the icon font completely but to do that we need to ensure that no internal components are using icon fonts.

This pull request makes steps to remove them from two related components: On this page and disclosure.

Changes

Inline toggle code

This is the biggest surface change. The on this page and disclosure components previously shared code via a utility method. In retrospect this makes it quite hard to change each component independently and in practice the disclosure component had subtly different behaviour which had to be patched in separately.

Practically these are both an implementation of https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/, much like targeted content is so it's reasonable to duplicate the pattern here to keep things flexible.

To account for this an additional cypress test has been added to cover the on this page toggle behaviour. This is preferable to the previous test anyway as it checks against a real component example rather than the lower level fixture used by the utility code.

Use SVG icons in place of icon fonts

For both components the same pattern has been used to make use of the PlusMinus icon component. Like with previous versions of this move the SVG icons are slightly thinner than the icon versions so there is a small visual change.

@davidrapson davidrapson mentioned this pull request Mar 25, 2024
4 tasks
@davidrapson davidrapson force-pushed the toggle-svg-icons branch 5 times, most recently from 0a30cef to 24e0efe Compare March 26, 2024 10:00
it { is_expected.to have_css "[data-toggle-target-id='my-id']" }
it { is_expected.to have_css "[aria-controls='my-id']" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been switched out as the component no longer needs data-toggle-target-id to work. Testing against aria attributes is preferable too.

@davidrapson davidrapson marked this pull request as ready for review March 26, 2024 10:53
@davidrapson davidrapson requested a review from a team as a code owner March 26, 2024 10:53
@davidrapson davidrapson requested review from leeky, akamike, cnorthwood, marianayovcheva and davidsauntson and removed request for leeky and akamike March 26, 2024 10:53
@marianayovcheva marianayovcheva added the docs preview If this is added a preview version of the docs site will be deployed label Mar 27, 2024
@marianayovcheva
Copy link
Contributor

Yay for moving away from the icon font! 🎉 Looks really good!
A wild opinion - I think we don't necessarily need to get rid of the show-hide util. When I was comparing the two files (disclosure.ts and on-this-page.ts) I noticed that the main difference was the disclosure has the setSummaryText function. We could update show-hide with the tidied up common functionality and add the differences in the files. That being said, I don't know if there will be more differences between the two in the future, and the separate approach is also good.
Leaving open for David and Chris to also have a look.

@davidrapson
Copy link
Contributor Author

A wild opinion - I think we don't necessarily need to get rid of the show-hide util

My (loosely held) but strong preference is to keep them separate, especially as we only have two examples of slightly similar code. Not against extracting it again in future though. I'm very much optimising for "make the components easy to change" vs "share the most code" here.

This change removes the use of icon fonts from the disclosure component.
To enable this the component has been refactored to inline the toggle
logic rather than sharing it between two components to make
per-component changes simpler to manage.

This change also makes sure the component consistently uses cads
prefixed classes including for js-cads classes.
This change removes the use of icon fonts from the on this page
component. To enable this the component has been refactored to inline
the toggle logic rather than sharing it between two components to make
per-component changes simpler to manage.

Includes an additional cypress tests to make sure we have test coverage
as some is lost by inlining the shared code.
This behaviour is now included and tested on a per-component basis.
@citizensadvice citizensadvice deleted a comment from github-actions bot Apr 17, 2024
@davidrapson davidrapson removed the docs preview If this is added a preview version of the docs site will be deployed label Apr 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.

None yet

3 participants