starlight icon indicating copy to clipboard operation
starlight copied to clipboard

Feat: Add badge to LinkCard component

Open lorenzolewis opened this issue 2 years ago • 9 comments

What kind of changes does this PR include?

  • Changes to Starlight code

Description

  • Exposes an optional badge prop to the LinkCard component Screenshot 2023-09-12 at 10 04 20

  • I'm not 100% sure if I used BadgeConfigSchema().parse() correctly in LinkCard.astro as this is my first time working with that bit of Zod, so any review/feedback on that would be much appreciated.

lorenzolewis avatar Sep 12 '23 16:09 lorenzolewis

🦋 Changeset detected

Latest commit: 921d4ccc18131ebfd35121663fe6a15e56947f1d

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 Patch

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

changeset-bot[bot] avatar Sep 12 '23 16:09 changeset-bot[bot]

Deploy Preview for astro-starlight processing.

Name Link
Latest commit c37e5bafa07e865da0111fcd98b1ddc3c32757a8
Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/6500c299a2f1910007f62d94

netlify[bot] avatar Sep 12 '23 16:09 netlify[bot]

I really like the idea of this PR personally. Left a few comments mostly regarding the technical aspect.

Thanks! Appreciate it!

UI-wise, I am not sure if it's just me or not but the label does not feel vertically centered but I'll have to take a closer look when I have more time.

I agree. I think the sidebar has the same sort of issue and this is the same CSS as that. I think it's aligned to the text baseline here, but I wonder if it would make sense to centre it overall vertically instead via flex or similar?

lorenzolewis avatar Sep 12 '23 18:09 lorenzolewis

Gonna throw my idea in here: Automatic application of the "New" badge to the sidebar and LinkCards based on the pages created age according to Git, with a configuration for how old you consider to still be new. Could also have an "Updated" badge based on changed in Git. Similar to how the last changed footer feature works.

simonhyll avatar Sep 13 '23 06:09 simonhyll

based on the pages created age according to Git

The issue with this kind of features is that certain hosting providers don't allow for deep clones of their repos so you don't get any of the git history data when building there.

Still an interesting idea tho, I also think later this could be done by a custom integration/plugin through component customization.

HiDeoo avatar Sep 13 '23 08:09 HiDeoo

UI-wise, I am not sure if it's just me or not but the label does not feel vertically centered but I'll have to take a closer look when I have more time.

I agree. I think the sidebar has the same sort of issue and this is the same CSS as that. I think it's aligned to the text baseline here, but I wonder if it would make sense to centre it overall vertically instead via flex or similar?

Yeah, this is due to us relying on inline styling in the sidebar. Can be fixed with a flex layout if that works for this case. In the case of the sidebar we couldn’t use flex because of our layout requirements and how we’d want lines to wrap. I actually spent a good afternoon researching this, but there’s no silver bullet for the sidebar case because we don’t know what font is used and font metrics need to be known with current CSS options (see e.g. https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align). There are some hopes that vertical-align: central will improve this when available, but for now, middle means align to the center of the x height, not cap height resulting in these off-center appearance when inline flow is required.

delucis avatar Sep 19 '23 21:09 delucis

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Feb 9, 2024 8:03pm

vercel[bot] avatar Feb 09 '24 20:02 vercel[bot]

How does this thing still not have any conflicts? 😅

How are we feeling now that Badges are merged in? Do we want to update this to use them or toss this out? I would personally still like to have it for the sake of having feature parity with sidebar entries (this was really some pre-work to build a "Table of Contents" component for a section of a sidebar).

lorenzolewis avatar Jun 05 '24 19:06 lorenzolewis

20 minutes ago I removed badge from my content collections, just because LinkCard doesn't support it. Good news, PR exists! Bad news, last update 6 mo ago.

sergeysova avatar Aug 30 '24 20:08 sergeysova