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

Merged
merged 13 commits into from
Jan 9, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const euiBetaBadgeStyles = (euiThemeContext: UseEuiTheme) => {
border-radius: ${euiTheme.size.l};
cursor: default;

font-weight: ${euiTheme.font.weight.bold};
font-weight: ${euiTheme.font.weight.semiBold};
text-transform: uppercase;
letter-spacing: 0.05em;
text-align: center;
Expand All @@ -50,22 +50,28 @@ export const euiBetaBadgeStyles = (euiThemeContext: UseEuiTheme) => {
${badgeColors.hollow.borderColor};
`,
warning: css(badgeColors.warning),
// Font sizes
// Font sizes (line height + padding-block-start = height of the badge)
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)}
    },
   }
 }

`,
s: css`
font-size: 0.625rem;
line-height: ${mathWithUnits(euiTheme.size.xs, (x) => x + euiTheme.base)};
font-size: 0.7rem;
line-height: ${mathWithUnits('20px', (x) => x * 0.98)};
`,
// Padding/width sizes
badgeSizes: {
default: {
m: `
${logicalCSS('padding-horizontal', euiTheme.size.base)}`,
${logicalCSS('height', euiTheme.size.l)}
${logicalCSS('padding-horizontal', euiTheme.size.base)}
padding-block-start: ${mathWithUnits(euiTheme.size.l, (x) => x * 0.04)}
`,
s: `
${logicalCSS('padding-horizontal', euiTheme.size.m)}`,
${logicalCSS('height', '20px')}
${logicalCSS('padding-horizontal', euiTheme.size.m)}
padding-block-start: ${mathWithUnits('20px', (x) => x * 0.02)};
`,
},
// When it's just an icon or a single letter, make the badge a circle
circle: {
Expand Down
Loading