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

Beta badge inner visual alignment #8255

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

ek-so
Copy link
Contributor

@ek-so ek-so commented Dec 30, 2024

Summary

  • Current EuiBetaBadge looks slightly unbalanced in terms of text baseline: the label with uppercase letters by nature feels like being shifted a bit more towards the top of the badge, so I pulled it down very slightly.
  • It also looks a bit too harsh when the text inside is bold, so I tried what if we make it semibold, and increase the font-size for smaller badge at the same time for better readability. This also makes the text better visually balanced with icon-only badge in terms of the line thickness.
    Badge

@ek-so ek-so marked this pull request as ready for review December 30, 2024 18:00
@ek-so ek-so requested a review from a team as a code owner December 30, 2024 18:00
@ek-so
Copy link
Contributor Author

ek-so commented Dec 30, 2024

Hey team, before reviewing from a technical side I'd like to ask somebody from design side to check the visual part and my considerations. @MichaelMarcialis @ryankeairns what are your thoughts?

@MichaelMarcialis
Copy link
Contributor

Hey team, before reviewing from a technical side I'd like to ask somebody from design side to check the visual part and my considerations. @MichaelMarcialis @ryankeairns what are your thoughts?

I think this looks great visually. It's a small but noticeable improvement.

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@mgadewoll
Copy link
Contributor

Minute alignment is tricky as browsers handle sub-pixels differently. One browser might round a 0.4px offset to 0.5px, another to 0 or 1px or not round at all. It won't always look as expected.

See this comparison:

  • Chrome (seems to round < 0.5 to 0 and > 0.5 to 1)
Screen.Recording.2025-01-07.at.14.49.05.mov
Screen.Recording.2025-01-08.at.10.20.04.mov
  • Firefox (seems to round > 0 to 1px)
Screen.Recording.2025-01-07.at.14.49.40.mov
Screen.Recording.2025-01-08.at.10.18.29.mov

Based on this, I think it doesn't make sense to try adjust based on sub-pixels. According to these changes we could just add 1px padding-top for m size and nothing for s.
I'm afraid we'll generally have to accept that it won't look perfectly aligned in all scenarios 🙈

m: css`
font-size: ${euiFontSizeFromScale('xs', euiTheme)};
line-height: ${euiTheme.size.l};
line-height: ${mathWithUnits(euiTheme.size.l, (x) => x * 0.96)};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm really not a fan of using magic numbers or static values here 🙈
I do like that you're adding a height to the badge and with that the line-height is not really that important anymore, we could just use the same height.

What I'm thinking

// simplified code

const badgeSizes = {
    m: euiTheme.size.l,
    s: mathWithUnits(euiTheme.size.base, (x) => x * 1.25),
};

euiBetaBadge: {
  m: css`
      line-height: ${badgeSizes.m};
  `,
  s: css`
      line-height: ${badgeSizes.s};
  `,

...

  badgeSizes: {
    default: {
        m: `
          ${logicalCSS('height', badgeSizes.m)}
        `,
        s: `
          ${logicalCSS('height', badgeSizes.s)}
    },
   }
 }

@kyrspl
Copy link
Contributor

kyrspl commented Jan 8, 2025

@mgadewoll - following up on your comment regarding various browsers:
Does it make sense to align specifically for each major browser and have a general fallback?

Badges are used so extensively across our UIs that this minute change may make a bigger difference across the board.

@mgadewoll
Copy link
Contributor

mgadewoll commented Jan 8, 2025

@mgadewoll - following up on your comment regarding various browsers: Does it make sense to align specifically for each major browser and have a general fallback?

Badges are used so extensively across our UIs that this minute change may make a bigger difference across the board.

@kyrspl I would vote against it. Mainly because we don't even know which browser versions handle sub-pixel in what way (a new version might introduce changes) or how they handle font rendering.
Trying to adjust for browsers specifically will introduce complexity that's - imho - an overkill for this change and the impact.

While I understand it's not looking perfect, I'm wondering if it's mostly something our eyes notice more than a users' 😅
But I can spend a bit more time to check if I can propose an alternative.

@kyrspl
Copy link
Contributor

kyrspl commented Jan 8, 2025

> a new version might introduce changes
That's something i didn't consider. Makes sense not to make it more complex than it has to be

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.

6 participants