astro-better-cards 0.1.0

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.
Files changed (3) hide show
  1. package/Card.astro +44 -0
  2. package/README.md +72 -0
  3. package/package.json +13 -0
package/Card.astro ADDED
@@ -0,0 +1,44 @@
1
+ ---
2
+ const {
3
+ href,
4
+ title,
5
+ description,
6
+ icon,
7
+ darkIcon,
8
+ cardImage,
9
+ variant = 'full',
10
+ comingSoon = false,
11
+ label,
12
+ labelFirst = false,
13
+ } = Astro.props;
14
+ ---
15
+ {variant === 'full' && (
16
+ <a href={href} class="border border-slate-300 dark:bg-slate-900 bg-white border-solid block dark:hover:bg-slate-700 dark:border-slate-600 group hover:bg-slate-300 hover:border-indigo-500 dark:hover:border-indigo-600 rounded-lg overflow-hidden">
17
+ {cardImage && <img src={cardImage} class="w-full object-cover" alt="" aria-hidden="true" />}
18
+ <div class="flex items-start gap-x-6 p-5">
19
+ {icon && <img class:list={["block w-14 shrink-0", darkIcon ? "dark:hidden" : ""]} src={icon} alt="" aria-hidden="true" />}
20
+ {darkIcon && <img class="hidden dark:block w-14 shrink-0" src={darkIcon} alt="" aria-hidden="true" />}
21
+ <div>
22
+ <p class="font-bold group-hover:text-indigo-500 pb-1 text-xl sm:leading-tight sm:pb-2 sm:text-lg md:text-xl lg:text-2xl 2xl:leading-tight" set:html={title}></p>
23
+ {description && <p class="font-normal lg:leading-4 sm:leading-4 text-sm">{description}</p>}
24
+ </div>
25
+ </div>
26
+ </a>
27
+ )}
28
+ {variant === 'compact' && (
29
+ <a href={href} class="border border-solid block rounded-lg border-slate-200 dark:bg-slate-900 dark:border-slate-800 bg-white dark:hover:bg-slate-800 dark:hover:border-indigo-500 group hover:bg-slate-100 hover:border-indigo-500">
30
+ <div class="flex items-center gap-x-6 px-5 py-3">
31
+ {!labelFirst && label && <p class="basis-7 shrink-0">{label}</p>}
32
+ <p class={(labelFirst ? "text-right " : "text-left ") + "basis-full font-medium group-hover:text-indigo-500 sm:leading-tight text-md 1xl:leading-tight"} set:html={title}></p>
33
+ {labelFirst && label && <p class="basis-7 shrink-0">{label}</p>}
34
+ </div>
35
+ </a>
36
+ )}
37
+ {variant === 'quickstart' && (
38
+ <a href={href} class={"border border-solid block rounded-lg " + (comingSoon ? "border-slate-800 dark:border-slate-700" : "border-slate-200 dark:bg-slate-900 dark:border-slate-800 bg-white dark:hover:bg-slate-800 dark:hover:border-indigo-500 group hover:bg-slate-100 hover:border-indigo-500")}>
39
+ <div class="flex items-center gap-x-6 px-5 py-3">
40
+ {icon && <img class={"h-9 shrink-0" + (comingSoon ? " opacity-40" : "")} src={icon} alt="" aria-hidden="true" />}
41
+ <p class={"font-medium group-hover:text-indigo-500 sm:leading-tight text-sm 1xl:leading-tight " + (comingSoon ? "text-slate-400" : "")} set:html={comingSoon ? title + ' * Coming Soon' : title}></p>
42
+ </div>
43
+ </a>
44
+ )}
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # astro-better-cards
2
+
3
+ Clickable card components for Astro docs sites. Three variants: `full` (large card with optional image/icon), `compact` (nav row with optional label), and `quickstart` (small icon + title, with coming-soon support).
4
+
5
+ ## Install
6
+
7
+ ```
8
+ npm install astro-better-cards
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```mdx
14
+ import Card from 'astro-better-cards/Card.astro';
15
+ ```
16
+
17
+ ### full (default)
18
+
19
+ Large bordered card. Good for section index pages.
20
+
21
+ ```mdx
22
+ <Card href="/docs/section" title="Section Title" description="A short description." />
23
+ ```
24
+
25
+ With an icon:
26
+
27
+ ```mdx
28
+ <Card href="/docs/section" title="Section Title" icon="/img/icon.svg" darkIcon="/img/icon-dark.svg" />
29
+ ```
30
+
31
+ With a card image (displayed above the content):
32
+
33
+ ```mdx
34
+ <Card href="/docs/section" title="Section Title" cardImage="/img/banner.png" />
35
+ ```
36
+
37
+ ### compact
38
+
39
+ Small nav row, often used for prev/next links. The `label` prop renders a short badge (e.g. an arrow). `labelFirst` controls which side the label appears on.
40
+
41
+ ```mdx
42
+ <Card variant="compact" href="/docs/next-page" title="Next Page" label="->" labelFirst={true} />
43
+ <Card variant="compact" href="/docs/prev-page" title="Previous Page" label="<-" labelFirst={false} />
44
+ ```
45
+
46
+ ### quickstart
47
+
48
+ Small icon + title card for quickstart grids. Supports a `comingSoon` state that greys out the card.
49
+
50
+ ```mdx
51
+ <Card variant="quickstart" href="/docs/quickstart/react" title="React" icon="/img/react.svg" />
52
+ <Card variant="quickstart" href="" title="Vue" icon="/img/vue.svg" comingSoon={true} />
53
+ ```
54
+
55
+ ## Props
56
+
57
+ | Prop | Variants | Type | Default | Description |
58
+ |------|----------|------|---------|-------------|
59
+ | `href` | all | `string` | — | Link destination. |
60
+ | `title` | all | `string` | — | Card title. Rendered with `set:html` so HTML entities and inline markup work. |
61
+ | `variant` | all | `'full' \| 'compact' \| 'quickstart'` | `'full'` | Which card style to render. |
62
+ | `description` | `full` | `string` | — | Optional subtitle below the title. |
63
+ | `icon` | `full`, `quickstart` | `string` | — | Icon image URL. Hidden in dark mode when `darkIcon` is also set. |
64
+ | `darkIcon` | `full` | `string` | — | Dark-mode icon image URL. |
65
+ | `cardImage` | `full` | `string` | — | Banner image displayed above the card content. |
66
+ | `label` | `compact` | `string` | — | Short badge text (e.g. `"->"`, `"<-"`, a step number). |
67
+ | `labelFirst` | `compact` | `boolean` | `false` | When `true`, the label appears after the title (right-aligned). |
68
+ | `comingSoon` | `quickstart` | `boolean` | `false` | Greys out the card and appends `* Coming Soon` to the title. |
69
+
70
+ ## Styling
71
+
72
+ Cards use Tailwind CSS utility classes and respond to dark mode via the `dark:` variant. No Tailwind integration is required in your project -- classes are inlined in the component.
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "astro-better-cards",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "exports": {
6
+ "./Card.astro": "./Card.astro"
7
+ },
8
+ "peerDependencies": {
9
+ "astro": ">=4.0.0"
10
+ },
11
+ "keywords": ["astro", "cards", "docs", "navigation"],
12
+ "license": "MIT"
13
+ }