@grove-dev/starlight 0.2.20 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,111 @@
1
+ ---
2
+ /**
3
+ * Starlight `<Card>` override that adds an optional `href` prop.
4
+ *
5
+ * The upstream `Card.astro` in `@astrojs/starlight@0.40` only accepts
6
+ * `icon` and `title`, so a `<Card title="..." href="...">` call silently
7
+ * dropped the link and rendered a non-clickable `<article>`. We wrap the
8
+ * inner content in an `<a>` when `href` is present so the entire card
9
+ * surface is interactive (the same affordance the `LinkCard` component
10
+ * uses, but with our visual `Card` styling).
11
+ *
12
+ * Visual styles are identical to upstream — only the structure gains a
13
+ * single `<a>` wrapper when `href` is set.
14
+ */
15
+ import { Icon } from '@astrojs/starlight/components';
16
+ import type { StarlightIcon } from '@astrojs/starlight/components-internals/Icons';
17
+
18
+ interface Props {
19
+ icon?: StarlightIcon;
20
+ title: string;
21
+ href?: string;
22
+ }
23
+
24
+ const { icon, title, href } = Astro.props;
25
+ ---
26
+
27
+ <article class="card sl-flex">
28
+ <p class="title sl-flex">
29
+ {icon && <Icon name={icon} class="icon" size="1.333em" />}
30
+ <span set:html={title} />
31
+ </p>
32
+ <div class="body">
33
+ {href ? <a {href} class="sl-card-link"><slot /></a> : <slot />}
34
+ </div>
35
+ </article>
36
+
37
+ <style>
38
+ @layer starlight.components {
39
+ .card {
40
+ --sl-card-border: var(--sl-color-purple);
41
+ --sl-card-bg: var(--sl-color-purple-low);
42
+ border: 1px solid var(--sl-color-gray-5);
43
+ background-color: var(--sl-color-black);
44
+ padding: clamp(1rem, calc(0.125rem + 3vw), 2.5rem);
45
+ flex-direction: column;
46
+ gap: clamp(0.5rem, calc(0.125rem + 1vw), 1rem);
47
+ transition: border-color 0.15s ease, transform 0.15s ease;
48
+ }
49
+ .card:nth-child(4n + 1) {
50
+ --sl-card-border: var(--sl-color-orange);
51
+ --sl-card-bg: var(--sl-color-orange-low);
52
+ }
53
+ .card:nth-child(4n + 3) {
54
+ --sl-card-border: var(--sl-color-green);
55
+ --sl-card-bg: var(--sl-color-green-low);
56
+ }
57
+ .card:nth-child(4n + 4) {
58
+ --sl-card-border: var(--sl-color-red);
59
+ --sl-card-bg: var(--sl-color-red-low);
60
+ }
61
+ .card:nth-child(4n + 5) {
62
+ --sl-card-border: var(--sl-color-blue);
63
+ --sl-card-bg: var(--sl-color-blue-low);
64
+ }
65
+ .title {
66
+ font-weight: 600;
67
+ font-size: var(--sl-text-h4);
68
+ color: var(--sl-color-white);
69
+ line-height: var(--sl-line-height-headings);
70
+ gap: 1rem;
71
+ align-items: center;
72
+ }
73
+ .card .icon {
74
+ border: 1px solid var(--sl-card-border);
75
+ background-color: var(--sl-card-bg);
76
+ padding: 0.2em;
77
+ border-radius: 0.25rem;
78
+ flex-shrink: 0;
79
+ }
80
+ .card .body {
81
+ margin: 0;
82
+ font-size: clamp(var(--sl-text-sm), calc(0.5rem + 1vw), var(--sl-text-body));
83
+ }
84
+ .card .body .sl-card-link {
85
+ /* The link is invisible text-decoration-wise; the card itself
86
+ * is the click target thanks to the ::before pseudo-element
87
+ * below. Display:contents lets the link wrap the body text
88
+ * without breaking the flex/grid layout. */
89
+ display: contents;
90
+ color: inherit;
91
+ }
92
+ .card:has(.sl-card-link) {
93
+ position: relative;
94
+ cursor: pointer;
95
+ }
96
+ .card:has(.sl-card-link):hover {
97
+ border-color: var(--sl-color-gray-2);
98
+ }
99
+ .card:has(.sl-card-link):hover .title {
100
+ color: var(--sl-color-accent-high);
101
+ }
102
+ /* a11y: a transparent overlay makes the whole card clickable
103
+ * without changing layout. Same trick Starlight's LinkCard uses. */
104
+ .card:has(.sl-card-link) .sl-card-link::before {
105
+ content: '';
106
+ position: absolute;
107
+ inset: 0;
108
+ border-radius: inherit;
109
+ }
110
+ }
111
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grove-dev/starlight",
3
- "version": "0.2.20",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Grove's theme for Starlight (the Astro native documentation site generator)",
6
6
  "author": "grove-dev",
package/styles/base.css CHANGED
@@ -330,6 +330,11 @@
330
330
  /* built-in Starlight Cards and LinkCards */
331
331
  .sl-markdown-content .card-grid {
332
332
  gap: 1rem;
333
+ grid-auto-rows: 1fr;
334
+ }
335
+
336
+ .sl-markdown-content .card-grid > * {
337
+ height: 100%;
333
338
  }
334
339
 
335
340
  .sl-markdown-content :is(.card, .sl-link-card) {
@@ -339,6 +344,7 @@
339
344
  background-color: var(--code-background);
340
345
  box-shadow: none;
341
346
  transition: background-color 0.15s;
347
+ height: 100%;
342
348
  }
343
349
 
344
350
  .sl-markdown-content :is(.card, .sl-link-card):hover {
@@ -1,3 +1,4 @@
1
+ export { default as Card } from './components/custom/Card.astro';
1
2
  export { default as ContainerSection } from './components/custom/ContainerSection.astro';
2
3
  export { default as LinkButton } from './components/custom/LinkButton.astro';
3
4
  export { default as Dropdown } from './components/custom/dropdown';