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

[Badge] Fix font sizes, padding, and colors to align with visual design #23379

Merged
merged 15 commits into from
Jul 12, 2022

Conversation

behowell
Copy link
Contributor

@behowell behowell commented Jun 2, 2022

Current Behavior

  • The visuals of Badge doesn't match the design:
    • Sizes small and medium have the wrong font size
    • Size extra-large has the wrong border size
    • There is 2px extra left/right padding on the icon, which makes icon-only badges not square
    • All appearances other than ghost have an extra 1px of padding from their border
    • Some colors tokens are incorrect
  • Badge uses flex gap, which isn't supported in older browsers
  • Screener tests are not very comprehensive for Badge

New Behavior

  • Update the styles to match the design
  • The border is now in an :after pseudo-element to avoid affecting layout between ghost and other appearances
  • Replace flex gap with an extra margin between the icon and text
  • Added screener stories for Badge's size variations

Related Issue(s)

@fabricteam
Copy link
Collaborator

fabricteam commented Jun 2, 2022

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-badge
Badge
21.653 kB
6.862 kB
22.494 kB
7.157 kB
841 B
295 B
react-badge
CounterBadge
22.557 kB
7.172 kB
23.397 kB
7.449 kB
840 B
277 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-alert
Alert
80.938 kB
20.342 kB
react-avatar
Avatar
47.36 kB
13.625 kB
react-avatar
AvatarGroup
136.845 kB
40.741 kB
react-avatar
AvatarGroupItem
67.075 kB
18.96 kB
react-badge
PresenceBadge
23.947 kB
7.022 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.182 kB
52.141 kB
react-components
react-components: FluentProvider & webLightTheme
31.883 kB
10.516 kB
🤖 This report was generated against d1f223054dba804964e010518ec0d09dbca2c584

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 2, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7297dec:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Jun 2, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: d1f223054dba804964e010518ec0d09dbca2c584 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Jun 2, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1279 1258 5000
Button mount 886 883 5000
FluentProvider mount 1568 1603 5000
FluentProviderWithTheme mount 552 551 10
FluentProviderWithTheme virtual-rerender 535 536 10
FluentProviderWithTheme virtual-rerender-with-unmount 571 577 10
MakeStyles mount 1957 1961 50000
SpinButton mount 2430 2449 5000

@behowell behowell changed the title [Badge] Fix padding/font sizes to align with visual design. Add weight prop. [Badge] Fix font sizes, padding, and colors to align with visual design Jun 2, 2022
@behowell behowell marked this pull request as ready for review June 2, 2022 23:29
@behowell behowell requested review from a team as code owners June 2, 2022 23:29
@behowell behowell assigned behowell and unassigned ling1726 Jun 2, 2022
groupSet: {
display: 'inline-flex',
flexDirection: 'column',
...shorthands.padding(0, '16px'),
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: Use spacing tokens for paddings, gaps, etc.

...shorthands.padding('2px'),
...shorthands.gap('4px'),
fontSize: '8px',
...shorthands.padding(0, '4px'), // 2px root padding + 2px text padding
Copy link
Contributor

Choose a reason for hiding this comment

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

My first thought is that we should be using spacing tokens here but the comment is making me think you intentionally didn't use them.

Is there a reason to not use spacing tokens here? If so, can the comment explicitly state that so we don't update them at a later date? If not, can they be changed to tokens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. It's listed in the spec as pixel values, but that might have been written before there were spacing tokens. I'll follow up with design to double check if these should be using tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use tokens in this PR. I'm still waiting to hear back from design, but it does seem like the right approach.

@github-actions github-actions bot removed this from the June Project Cycle Q2 2022 milestone Jul 11, 2022
@github-actions github-actions bot added this to the July Project Cycle Q3 2022 milestone Jul 11, 2022
},
small: {
minWidth: '16px',
height: '16px',
...shorthands.padding('2px'),
...shorthands.gap('4px'),
Copy link
Member

Choose a reason for hiding this comment

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

Our current browser support matrix actually supports flex gap

Copy link
Member

Choose a reason for hiding this comment

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

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 think we're still determining if we need to accommodate browsers that don't support flex gap.

In any case, this still needed to be fixed to accommodate the extra padding that needed to be added around the text but not the icon, and the resulting styles wouldn't be made much simpler by using flex gap.

Also, the gap here would have been applied to any child elements as well (if the badge contained elements other than just text), which is probably unexpected.

@behowell behowell merged commit 4cb5696 into microsoft:master Jul 12, 2022
khmakoto pushed a commit to khmakoto/fluentui that referenced this pull request Jul 13, 2022
…gn (microsoft#23379)

Update Badge font sizes, padding, and colors to match the design.
Add screener stories for Badge's size variations.
@behowell behowell deleted the badge-font-styles branch February 15, 2024 21:30
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.

[Bug]: Badge styles don't match the design
5 participants