pr_01m47d24b0e6n91zwymwxg0vpx/apps/docs/src/components/LinkCard.astro
| 1 | --- |
| 2 | // Starlight's <LinkCard>, with Lucide's arrow. |
| 3 | import type { HTMLAttributes } from 'astro/types'; |
| 4 | |
| 5 | import LucideIcon from './LucideIcon.astro'; |
| 6 | |
| 7 | interface Props extends Omit<HTMLAttributes<'a'>, 'title'> { |
| 8 | title: string; |
| 9 | description?: string; |
| 10 | } |
| 11 | |
| 12 | const { title, description, ...attributes } = Astro.props; |
| 13 | --- |
| 14 | |
| 15 | <div class="sl-link-card"> |
| 16 | <span class="sl-flex stack"> |
| 17 | <a {...attributes}> |
| 18 | <span class="title" set:html={title} /> |
| 19 | </a> |
| 20 | {description && <span class="description" set:html={description} />} |
| 21 | </span> |
| 22 | <LucideIcon name="arrow-right" size="1.333em" class="icon rtl:flip" /> |
| 23 | </div> |
| 24 | |
| 25 | <style> |
| 26 | @layer starlight.components { |
| 27 | .sl-link-card { |
| 28 | display: grid; |
| 29 | grid-template-columns: 1fr auto; |
| 30 | gap: 0.5rem; |
| 31 | border: 1px solid var(--sl-color-gray-5); |
| 32 | border-radius: 0.5rem; |
| 33 | padding: 1rem; |
| 34 | box-shadow: var(--sl-shadow-sm); |
| 35 | position: relative; |
| 36 | } |
| 37 | a { |
| 38 | text-decoration: none; |
| 39 | line-height: var(--sl-line-height-headings); |
| 40 | } |
| 41 | /* The whole card is the link. */ |
| 42 | a::before { |
| 43 | content: ''; |
| 44 | position: absolute; |
| 45 | inset: 0; |
| 46 | } |
| 47 | .stack { |
| 48 | flex-direction: column; |
| 49 | gap: 0.5rem; |
| 50 | } |
| 51 | .title { |
| 52 | color: var(--sl-color-white); |
| 53 | font-weight: 600; |
| 54 | font-size: var(--sl-text-lg); |
| 55 | } |
| 56 | .description { |
| 57 | color: var(--sl-color-gray-3); |
| 58 | line-height: 1.5; |
| 59 | } |
| 60 | .sl-link-card :global(.icon) { |
| 61 | color: var(--sl-color-gray-3); |
| 62 | } |
| 63 | .sl-link-card:hover { |
| 64 | background: var(--sl-color-gray-7, var(--sl-color-gray-6)); |
| 65 | border-color: var(--sl-color-gray-2); |
| 66 | } |
| 67 | .sl-link-card:hover :global(.icon) { |
| 68 | color: var(--sl-color-white); |
| 69 | } |
| 70 | } |
| 71 | </style> |