Skip to content

Conversation

@engfragui
Copy link
Contributor

@engfragui engfragui commented Feb 17, 2023

Short description

This PR tweaks our (existing) Badge component:

  1. Content of the Badge is now bold (as per this request on Twist). We should be able to see this very clearly via our visual regression tests, but here's some screenshots:
BeforeAfter
Screenshot 2023-02-17 at 12 57 43 Screenshot 2023-02-17 at 12 25 37
  1. The appropriate line-height is enforced. No line-height set was causing the background of the badge to expand vertically when inside flex containers:

Screenshot 2023-02-17 at 12 51 43

Although this can be easily set in the client, I figured we would want to enforce this in Reactist _once and for all_.

I'm also taking this chance to fix a couple of typos in the Banner stories (25 instead of 24 px -- I was probably drunk, who knows 🤷‍♀️).

PR Checklist

  • Added tests for bugs / new features
  • Updated docs (storybooks, readme)
  • Executed npm run validate and made sure no errors / warnings were shown
  • Described changes in CHANGELOG.md
  • Bumped version in package.json and package-lock.json (npm --no-git-tag-version version <major|minor|patch>) ref
  • Updated all static build artifacts (npm run build-all)
  • Reviewed and approved Chromatic visual regression tests in CI

Versioning

I think this is a minor fix, so I'm just bumping the patch.

@engfragui engfragui force-pushed the francesca/badge-update branch from 378d96c to d5f9d2d Compare February 17, 2023 11:48
@engfragui engfragui marked this pull request as ready for review February 17, 2023 11:57
@engfragui engfragui self-assigned this Feb 17, 2023
@engfragui
Copy link
Contributor Author

engfragui commented Feb 17, 2023

We should be able to see this very clearly via our visual regression tests

Errr not true (see this build -- you can see that there's no side by side comparison of all the badges). Looking into it now 👀

Edit: I think the

{PlaygroundTemplate.bind({})}

inside the main storybook demo prevents the tests from working correctly 🤔

padding: var(--reactist-badge-paddingY) var(--reactist-badge-paddingX);
color: var(--reactist-badge-tint);
background-color: var(--reactist-badge-fill);
line-height: calc(var(--reactist-badge-font-size) + 2 * var(--reactist-badge-paddingY));
Copy link
Contributor

@gnapse gnapse Feb 17, 2023

Choose a reason for hiding this comment

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

I think it would be a bit simpler if instead of applying a vertical padding, we just apply a line height and that's it. That alone would enforce the height and the vertical spacing around the text, even if it's not padding, right?

With that in mind, I would also hard-code the line-height to be font-size + 2px, instead of doing all this calculation. Something along these lines:

.badge {
  padding: 0 var(--reactist-spacing-xsmall);
  line-height: calc(var(--reactist-badge-font-size) + 2);
}

I also feel that offering badge-specific CSS variables for the padding of the badge may be unnecessary. I'd rather add that API later if needed, than committing to it today. Any new CSS variables we add becomes public Reactist API that we later need to support or deprecate if we want to remove it or change it.

Copy link
Contributor Author

@engfragui engfragui Feb 17, 2023

Choose a reason for hiding this comment

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

That makes a lot of sense, thank you, I will test this now.

Copy link
Contributor Author

@engfragui engfragui Feb 17, 2023

Choose a reason for hiding this comment

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

Err actually it seems like I still need to set the padding value to what I actually want the padding to be.

padding: 0 var(--reactist-spacing-xsmall);

Screenshot 2023-02-17 at 14 19 00

vs.

padding: 3px var(--reactist-spacing-xsmall);

Screenshot 2023-02-17 at 14 18 50

@gnapse
Copy link
Contributor

gnapse commented Feb 17, 2023

@engfragui upon inspecting the Chromatic snapshots:

CleanShot 2023-02-17 at 10 03 46@2x

I find it odd that in there the vertical padding looks almost non-existent. Could it be that 1px is too little?

@engfragui
Copy link
Contributor Author

Could it be that 1px is too little?

@gnapse Errr the Figma mocks say the padding should be 3px 😅

Screenshot 2023-02-17 at 14 06 16

I think it still looked good because the background was anyway expanding vertically to fill the entire vertical height, so we never noticed this. I will change to 3px.

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.

3 participants