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

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/red-monkeys-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
'@astrojs/starlight': minor
---

⚠️ **BREAKING CHANGE:** Ensures that the `<Badge>` and `<Icon>` components no longer render with a trailing space.

In Astro, components that include styles render with a trailing space which can prevent some use cases from working as expected, e.g. when using such components inlined with text. This change ensures that the `<Badge>` and `<Icon>` components no longer render with a trailing space.

If you were previously relying on that implementation detail, you may need to update your code to account for this change. For example, considering the following code:

```mdx
<Badge text="New" />Feature
```

The rendered text would previously include a space between the badge and the text due to the trailing space automatically added by the component:

```
New Feature
```

Such code will now render the badge and text without a space:

```
NewFeature
```

To fix this, you can add a space between the badge and the text:

```diff
- <Badge text="New" />Feature
+ <Badge text="New" /> Feature
```
48 changes: 24 additions & 24 deletions docs/src/content/docs/components/badges.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ To use a built-in badge color, set the [`variant`](#variant) attribute to one of
```mdx
import { Badge } from '@astrojs/starlight/components';

<Badge text="Note" variant="note" />
<Badge text="Success" variant="success" />
<Badge text="Tip" variant="tip" />
<Badge text="Caution" variant="caution" />
<Badge text="Danger" variant="danger" />
- <Badge text="Note" variant="note" />
- <Badge text="Success" variant="success" />
- <Badge text="Tip" variant="tip" />
- <Badge text="Caution" variant="caution" />
- <Badge text="Danger" variant="danger" />
```

<Fragment slot="markdoc">

```markdoc
{% badge text="Note" variant="note" /%}
{% badge text="Success" variant="success" /%}
{% badge text="Tip" variant="tip" /%}
{% badge text="Caution" variant="caution" /%}
{% badge text="Danger" variant="danger" /%}
- {% badge text="Note" variant="note" /%}
- {% badge text="Success" variant="success" /%}
- {% badge text="Tip" variant="tip" /%}
- {% badge text="Caution" variant="caution" /%}
- {% badge text="Danger" variant="danger" /%}
```

</Fragment>

<Fragment slot="preview">
<Badge text="Note" variant="note" />
<Badge text="Success" variant="success" />
<Badge text="Tip" variant="tip" />
<Badge text="Caution" variant="caution" />
<Badge text="Danger" variant="danger" />
- <Badge text="Note" variant="note" />
- <Badge text="Success" variant="success" />
- <Badge text="Tip" variant="tip" />
- <Badge text="Caution" variant="caution" />
- <Badge text="Danger" variant="danger" />
</Fragment>

</Preview>
Expand All @@ -71,25 +71,25 @@ Use the [`size`](#size) attribute to control the size of the badge text.
```mdx /size="\w+"/
import { Badge } from '@astrojs/starlight/components';

<Badge text="New" size="small" />
<Badge text="New and improved" size="medium" />
<Badge text="New, improved, and bigger" size="large" />
- <Badge text="New" size="small" />
- <Badge text="New and improved" size="medium" />
- <Badge text="New, improved, and bigger" size="large" />
```

<Fragment slot="markdoc">

```markdoc /size="\w+"/
{% badge text="New" size="small" /%}
{% badge text="New and improved" size="medium" /%}
{% badge text="New, improved, and bigger" size="large" /%}
- {% badge text="New" size="small" /%}
- {% badge text="New and improved" size="medium" /%}
- {% badge text="New, improved, and bigger" size="large" /%}
```

</Fragment>

<Fragment slot="preview">
<Badge text="New" size="small" />
<Badge text="New and improved" size="medium" />
<Badge text="New, improved, and bigger" size="large" />
- <Badge text="New" size="small" />
- <Badge text="New and improved" size="medium" />
- <Badge text="New, improved, and bigger" size="large" />
</Fragment>

</Preview>
Expand Down
Loading