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

Rework search icon styles #3900

Merged
merged 1 commit into from Mar 5, 2024
Merged

Rework search icon styles #3900

merged 1 commit into from Mar 5, 2024

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Mar 4, 2024

What

Rework the sass for the search component SVG icon, which used a mixin with a calc function to determine the correct top and left values based on a given container size. Instead use a simpler effect - set the icon to be the height and width of the parent, but scale it by half (origin defaults to the center). Since the button is 40px and the icon should be 20px this should result in no visual difference.

For the large icon, the search icon should remain the same size, despite the button being 10px larger at 50px. Instead we apply a scale of .4, which results in the same size.

Why

Trying to use the search component in the govuk-dev-docs, which is running on an older version of Sass and doesn't interpret the calc part properly (it outputs it without calculating it, resulting in an invalid CSS value), which looks like this:

Screenshot 2024-03-04 at 15 26 36
Screenshot 2024-03-04 at 15 26 47

This change fixes this.

Visual Changes

Shouldn't be any, thought it might be different by a pixel or so compared to the original but the visual diff passes. I've tested this in a few browsers and it looks like it always did. Anything below IE10 doesn't work (because IE9 didn't support transform) but the result is that the icon is just a bit bigger than it should be. Since we don't support IE I think this falls into the acceptable category of 'looks a bit strange but still works'.

- used a mixin relying on calc, but the same effect can be achieved using absolute positioning and a scale transform (which defaults to an origin of the centre, meaning that it shrinks in place)
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-3900 March 4, 2024 15:36 Inactive
@andysellick andysellick marked this pull request as ready for review March 4, 2024 15:38
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.

Nice work!, really like the approach here, basing the icon size off the button size.

Checked Percy and no visual changes here either 👍

@andysellick andysellick merged commit 03e0c89 into main Mar 5, 2024
12 checks passed
@andysellick andysellick deleted the rework-search-icon branch March 5, 2024 10:14
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