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(toggle): positioning on non-default base font size #3858

Merged
merged 6 commits into from
Aug 29, 2019
Merged

fix(toggle): positioning on non-default base font size #3858

merged 6 commits into from
Aug 29, 2019

Conversation

timrbula
Copy link
Contributor

@timrbula timrbula commented Aug 28, 2019

Closes #3857

Fixes Toggle elements that are mispositioned and overlap if the base font size scss variable or html element attribute font-size is not 16px

Changelog

New

N/A

Changed

  • px values use the rem helper method for sizing e.g. rem(3px)
  • margin-left of the toggle text to have the same offset but uses px instead of spacing variable. It currently evaluates to the width of the toggle + 0.5rem at 16px, so I converted that to a total px value for both the default and small Toggles. (Is there another approach ya'll would prefer to do this?)
  • add width and height to checkmark for the small toggle

Note: I left the active and focus state box-shadow styles defined in px to match mixin and other styles.

Removed

N/A

Testing / Reviewing

  1. Switch to PR branch and change the base font size
  2. View elements correctly positioned
  3. Change base font size back and change font-size on html element in dev tools
  4. View elements correctly positioned

image
image

@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for the-carbon-components ready!

Built with commit c10dcc8

https://deploy-preview-3858--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for carbon-elements ready!

Built with commit c10dcc8

https://deploy-preview-3858--carbon-elements.netlify.com

@@ -410,18 +412,18 @@

.#{$prefix}--toggle__text--off,
.#{$prefix}--toggle__text--on {
margin-left: $carbon--spacing-08;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why we can't still use the carbon--spacing variable here? They should be using a rem function under the hood

Copy link
Contributor Author

@timrbula timrbula Aug 28, 2019

Choose a reason for hiding this comment

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

I think it is because the $carbon--mini-unit-size is defined as 8px and not half of the $carbon--base-font-size. That would explain why changing the html font-size in dev tools doesn't cause the text to be misaligned but changing the font size variable does. So perhaps the min-unit-size variable could be changed as well but I was worried about the impact b/c I see that $carbon--spacing-* and carbon--mini-units() are used throughout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, that makes sense. I think just making the change here is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I will leave it as is

@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for carbon-components-react ready!

Built with commit c10dcc8

https://deploy-preview-3858--carbon-components-react.netlify.com

@tw15egan tw15egan requested a review from a team August 28, 2019 18:44
@ghost ghost requested review from abbeyhrt and dakahn and removed request for a team August 28, 2019 18:44
@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for the-carbon-components ready!

Built with commit 4891486

https://deploy-preview-3858--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for carbon-components-react ready!

Built with commit 4891486

https://deploy-preview-3858--carbon-components-react.netlify.com

@netlify
Copy link

netlify bot commented Aug 28, 2019

Deploy preview for carbon-elements ready!

Built with commit 4891486

https://deploy-preview-3858--carbon-elements.netlify.com

@dakahn
Copy link
Contributor

dakahn commented Aug 28, 2019

@aagonzales just wanted to check in with design and make sure this is cool 👍

@asudoh asudoh requested a review from a team August 28, 2019 21:44
@ghost ghost requested review from aagonzales and removed request for a team August 28, 2019 21:45
Copy link
Member

@aagonzales aagonzales left a comment

Choose a reason for hiding this comment

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

I was having trouble viewing in a local env (user error) but it sounds good to me 👍

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link
Contributor

@abbeyhrt abbeyhrt left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Collaborator

@tw15egan tw15egan left a comment

Choose a reason for hiding this comment

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

@tw15egan tw15egan merged commit d2990fd into carbon-design-system:master Aug 29, 2019
@timrbula timrbula changed the title Fix toggle positioning fix(toggle): positioning on non-default base font size Aug 29, 2019
@timrbula
Copy link
Contributor Author

Awesome thanks yall!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toggle elements mispositioned with different base font size
7 participants