Skip to content

Remove trailing whitespace from <Badge> and <Icon> components #2924

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

Merged

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Feb 26, 2025

Description

In Astro, components that include styles render with a trailing space. This behavior is not ideal for components like <Badge> and <Icon> that are often used in inline text.

For example, the following code:

Feature (<Badge text="New" />)

will render as:

Feature (New )

This PR removes the trailing space from <Badge> and <Icon> components by wrapping them in a fragment which prevents the trailing space from being rendered.

image

If we ship this change and its associated documentation change to accommodate the new behavior, we could potentially update the docs for all languages as it's purely structural changes and mark it as i18n ignored

Copy link

changeset-bot bot commented Feb 26, 2025

🦋 Changeset detected

Latest commit: e140163

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added 📚 docs Documentation website changes 🌟 core Changes to Starlight’s main package labels Feb 26, 2025
Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit e140163
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/67f3e8fc67b57f0007e66b6d
😎 Deploy Preview https://deploy-preview-2924--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@astrobot-houston
Copy link
Collaborator

astrobot-houston commented Feb 26, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en components/badges.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
Contributor

@SnowDingo SnowDingo left a comment

Choose a reason for hiding this comment

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

@HiDeoo, thank you for making this change.

I'm still a rookie coder so I can't give any suggestions on the code, but I feel like the new style without the trailing space is nice. I hope this PR will get merged.

-snowdingo

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

Changes all look great and the the changeset is really excellent and clear 👏

I wish we didn’t need to rely on the weird fragment hack, but I’m glad we at least have good testing in place in case that ever breaks.

@delucis delucis added the 🌟 minor Change that triggers a minor release label Mar 24, 2025
@delucis delucis added this to the v0.33 milestone Apr 5, 2025
@delucis delucis added the ✅ approved Pull requests that have been approved and are ready to merge when next cutting a release label Apr 5, 2025
@delucis delucis merged commit 6a56d1b into withastro:main Apr 7, 2025
16 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ approved Pull requests that have been approved and are ready to merge when next cutting a release 🌟 core Changes to Starlight’s main package 📚 docs Documentation website changes 🌟 minor Change that triggers a minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants