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

fix: Icon spacing in jump link stories #100

Merged
merged 6 commits into from
Jun 30, 2023
Merged

fix: Icon spacing in jump link stories #100

merged 6 commits into from
Jun 30, 2023

Conversation

meissadia
Copy link
Contributor

@meissadia meissadia commented Jun 30, 2023

Closes #99

Based on my investigation, it feels more logical to utilize css for icon spacing as opposed to relying on devs inserting an   between elements. I hope this saves someone else's sanity in the future.

This PR got a bit large but it:

Happy to chat about this approach or walk through changes if need.

@netlify
Copy link

netlify bot commented Jun 30, 2023

Deploy Preview for cfpb-design-stories ready!

Name Link
🔨 Latest commit 8da83d7
🔍 Latest deploy log https://app.netlify.com/sites/cfpb-design-stories/deploys/649f42a66c3e4d000858fea5
😎 Deploy Preview https://deploy-preview-100--cfpb-design-stories.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@contolini
Copy link
Member

After hours of comparing and contrasting, I've established that the source of the gap between the icon and the text in the design system example was....a space character.

😮 🏆

...they appear to have different font weights (though the setting is 500 in both) and text spacings.

See if -webkit-font-smoothing: antialiased; adjusts the visual weight.

@meissadia
Copy link
Contributor Author

Moving investigation notes to a comment for posterity

Spacing fix

After hours of comparing and contrasting, I've established that the source of the gap between the icon and the text in the design system example was....a space character. It was hard to see because it was between the <span.a-link_text> and the icon <svg>.

Other issue (Chrome)

There is still an issue with vertical alignment due to a gap between the text and bottom border (noticeable on the "j" and "p"). This gap seems to come from the font face. The font-family for both instances shown below is 'Avenir Next', Arial, sans-serif, inherited from the body element as defined in the CFPB DS, yet they appear to have different font weights (though the setting is 500 in both) and text spacings.

Storybook Design System docs
Screen Shot 2023-06-29 at 5 00 19 PM Screen Shot 2023-06-29 at 5 00 33 PM

Deleting 'Avenir Next' from the font-family stack in both apps seems to better align the styles, though the Storybook text still looks slightly heavier (I also used macOS Digital Color Meter to verify that they are the same color).

Storybook Design System docs
Screen Shot 2023-06-29 at 5 15 54 PM Screen Shot 2023-06-29 at 5 16 16 PM

I really don't know what to make of these findings. Could the `Avenir Next` in the DS docs be different than the one in Storybook???...though both should be using the Design System so it doesn't seem a logical explanation.

Cross Browser checks

The Design System doc links are consistent across Chrome, Safari, and Firefox.

The Storybook links match the Design System docs in Firefox but not in Chrome or Safari (though the mismatch is consistent in both browsers).

Rendered Font Name

Browser Storybook DS Docs
Chrome Avenir Next Medium no font name displayed but I think Avenir Next because when I delete it from the font-family the UI changes and the Arial font name is displayed.
Safari Avenir Next Same as above
Firefox Arial Avenir Next (Avenir Next LT W01 Medium)

@meissadia meissadia marked this pull request as ready for review June 30, 2023 18:33
@contolini
Copy link
Member

Turns out to fix the antialiasing we just had to install the latest version of the design system. I also added a typescript alias that points ~ to the project's root so we can avoid lots of ../../ import statements.

Copy link
Member

@contolini contolini 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!

@contolini contolini merged commit 45e571a into main Jun 30, 2023
6 checks passed
@contolini contolini deleted the 99-icon-spacing branch June 30, 2023 21:05
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.

[Bug][Component] Icon - Spacing is off
2 participants