diff --git a/badge-maker/lib/badge-renderers.js b/badge-maker/lib/badge-renderers.js index a20201b863430..76cfee81587b6 100644 --- a/badge-maker/lib/badge-renderers.js +++ b/badge-maker/lib/badge-renderers.js @@ -160,7 +160,7 @@ class Badge { } let rightWidth = messageWidth + 2 * horizPadding if (hasLogo && !hasLabel) { - rightWidth += totalLogoWidth + horizPadding - 1 + rightWidth += totalLogoWidth + message.length ? horizPadding - 1 : 0 } const width = leftWidth + rightWidth @@ -804,11 +804,13 @@ function forTheBadge({ // there is no label. When `needsLabelRect` is true, render a label rect and a // message rect; when false, only a message rect. const hasLabel = Boolean(label.length) + const noText = !hasLabel && !message const needsLabelRect = hasLabel || (logo && labelColor) + const gutter = noText ? LOGO_TEXT_GUTTER - LOGO_MARGIN : LOGO_TEXT_GUTTER let logoMinX, labelTextMinX if (logo) { logoMinX = LOGO_MARGIN - labelTextMinX = logoMinX + logoWidth + LOGO_TEXT_GUTTER + labelTextMinX = logoMinX + logoWidth + gutter } else { labelTextMinX = TEXT_MARGIN } @@ -823,9 +825,8 @@ function forTheBadge({ messageRectWidth = 2 * TEXT_MARGIN + messageTextWidth } else { if (logo) { - messageTextMinX = TEXT_MARGIN + logoWidth + LOGO_TEXT_GUTTER - messageRectWidth = - 2 * TEXT_MARGIN + logoWidth + LOGO_TEXT_GUTTER + messageTextWidth + messageTextMinX = TEXT_MARGIN + logoWidth + gutter + messageRectWidth = 2 * TEXT_MARGIN + logoWidth + gutter + messageTextWidth } else { messageTextMinX = TEXT_MARGIN messageRectWidth = 2 * TEXT_MARGIN + messageTextWidth