Skip to content

Commit

Permalink
Implement landing page cards (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Jun 3, 2023
1 parent 446dade commit 55fec5d
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 63 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-lizards-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/starlight": patch
---

Add `<Card>` and `<CardGrid>` components for landing pages and other uses
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{
"name": "/index.html",
"path": "dist/index.html",
"limit": "13 kB"
"limit": "14 kB"
},
{
"name": "/_astro/*.js",
Expand All @@ -37,7 +37,7 @@
{
"name": "/_astro/*.css",
"path": "dist/_astro/*.css",
"limit": "11 kB"
"limit": "10 kB"
}
]
}
4 changes: 3 additions & 1 deletion docs/src/assets/landing.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
[data-has-hero] .page {
background: linear-gradient(215deg, var(--overlay-blurple), transparent 40%),
radial-gradient(var(--overlay-blurple), transparent 40%) no-repeat -60vw -40vh /
105vw 200vh;
105vw 200vh,
radial-gradient(var(--overlay-blurple), transparent 65%) no-repeat 50%
calc(100% + 20rem) / 60rem 30rem;
}

[data-has-hero] header {
Expand Down
48 changes: 48 additions & 0 deletions docs/src/components/about-astro.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
interface Props {
title: string;
}
const { title } = Astro.props;
---

<article class="flex" aria-labelledby="about-astro-heading">
<small id="about-astro-heading">
{title}
<span class="sr-only">Astro</span>
</small>
<svg
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 301 79"
fill="var(--sl-color-white)"
>
<path
d="M20.8 66.8c-3.6-3.2-4.6-10-3.1-15 2.5 3.2 6.1 4.2 9.8 4.7 5.7.9 11.3.6 16.5-2l1.9-1.1a9 9 0 0 1 .4 4.3 12 12 0 0 1-5 8.5l-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1.2-10.8-2.7.9-6.1 1.3-10 1.3-5.2 0-7.3-1.4-7.3-5.5v-10l17.5.2c0-3 0-7.6.2-10.6-5.7.2-12.1.2-17.4.2l.1-7.6h-.4Zm35.3 15.8.1-8.4h-11.8a752.4 752.4 0 0 1 0 36.2h13.5c-.2-3.5-.3-9.6-.3-14.7 0-8.1 3.3-10.5 10.8-10.5 3.5 0 6 .5 8.2 1.2 0-3 .6-9 1-11.6-2.3-.6-4.7-1-7.7-1-6.5-.1-11.2 2.5-13.4 8.8h-.4Zm59 9.5c0 6.5-4.7 9.6-12.1 9.6-7.4 0-12.1-2.9-12.1-9.6 0-6.7 4.8-9.2 12-9.2 7.4 0 12.2 2.7 12.2 9.2Zm12.3-.3c0-13-10.1-18.8-24.4-18.8-14.4 0-24.2 5.8-24.2 18.8s9.1 20 24.1 20c15.1 0 24.5-7 24.5-19.9Z"
>
</path>
</svg>
<slot />
</article>

<style>
article {
max-width: 40rem;
margin-inline: auto;
padding-block: 5rem;
flex-direction: column;
align-items: center;
text-align: center;
gap: 0.5rem;
}
article > :global(*) {
margin-top: 0 !important;
max-width: 50ch;
}
small {
color: var(--sl-color-gray-3);
}
svg {
width: 15rem;
}
</style>
42 changes: 25 additions & 17 deletions docs/src/content/docs/de/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,31 @@ hero:
link: https://github.com/withastro/starlight
---

:::caution[Laufende Arbeiten]
Starlight befindet sich in einem fr眉hen Entwicklungsstadium, also rechne mit Fehlern und 脛nderungen, w盲hrend wir es weiterentwickeln.
Wenn du etwas findest, das nicht funktioniert, [枚ffne bitte ein Issue auf GitHub](https://github.com/withastro/starlight/issues/new/choose) oder gib uns auf [Discord](https://astro.build/chat) Bescheid.
:::
import { CardGrid, Card } from '@astrojs/starlight/components';
import AboutAstro from '../../../components/about-astro.astro';

## Was ist im Lieferumfang enthalten?
<CardGrid stagger>
<Card title="Dokumentation, die begeistert" icon="open-book">
Site-Navigation, Suche, Internationalisierung, SEO, leicht lesbare
Typografie, Code-Hervorhebung, Dunkelmodus und mehr.
</Card>
<Card title="Angetrieben durch Astro" icon="rocket">
Nutze die volle Kraft und Leistung von Astro. Erweitere Starlight mit deinen
bevorzugten Astro-Integrationen.
</Card>
<Card title="Markdown, Markdoc und MDX" icon="document">
Bringe deine bevorzugte Dokumentenformat mit. Starlight beh盲lt alles im Auge
mit integrierte Frontmatter-Validierung.
</Card>
<Card title="Bringe deine eigenen Komponenten mit" icon="puzzle">
Starlight wird als Framework-unabh盲ngige, vollst盲ndige Dokumentationsl枚sung
geliefert. Erweitere mit React, Vue, Svelte, Solid und mehr.
</Card>
</CardGrid>

Starlight enth盲lt alle notwendige Funktionen, um eine Dokumentationsseite schnell zum Laufen zu bringen:
<AboutAstro title="Pr盲sentiert von">
Astro ist ein Web-Framework, das eine Komplettl枚sung zur Erstellung schneller Websites darstellt. Rufe deine Inhalte von 眉berall ab und stelle sie 眉berall bereit, alles unterst眉tzt durch deine bevorzugten UI-Komponenten und Bibliotheken.

- Unterst眉tzung von Markdown und MDX
- Leicht zu lesende typografische Stile
- Syntaxhervorhebung f眉r Code-Beispiele
- Einfach zu konfigurierende Navigationsmen眉s
- Eingebaute Suchfunktion
- [Internationalisierungsfunktionen](/de/guides/i18n)
- Barrierfreie Seitenaufbau
- Unterst眉tzung von [Komponenten im Inhalt](/de/guides/components) mit MDX
- Unterst眉tzung f眉r benutzerdefinierte Stile
- Schnelle und [umweltfreundliche](/de/environmental-impact) Architektur
- Kompatibilit盲t mit dem [Astro-脰kosystem](https://astro.build/integrations)
[Erfahre mehr 眉ber Astro](https://astro.build/)

</AboutAstro>
49 changes: 49 additions & 0 deletions docs/src/content/docs/guides/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,52 @@ The code above generates the following tabs on the page:
<TabItem label="Stars">Sirius, Vega, Betelgeuse</TabItem>
<TabItem label="Moons">Io, Europa, Ganymede</TabItem>
</Tabs>

### Cards

import { Card, CardGrid } from '@astrojs/starlight/components';

You can display content in a box matching Starlight鈥檚 styles using the `<Card>` component.
Wrap multiple cards in the `<CardGrid>` component to display cards side-by-side when there鈥檚 enough space.

A `<Card>` should have a `title` and can optionally include an `icon` attribute set to the name of [one of Starlight鈥檚 built-in icons](https://github.com/withastro/starlight/blob/main/packages/starlight/components/Icons.ts).

```mdx
import { Card, CardGrid } from '@astrojs/starlight/components';

<Card title="Check this out">Interesting content you want to highlight.</Card>

<CardGrid>
<Card title="Stars" icon="star">
Sirius, Vega, Betelgeuse
</Card>
<Card title="Moons" icon="moon">
Io, Europa, Ganymede
</Card>
</CardGrid>
```

The code above generates the following on the page:

<Card title="Check this out">Interesting content you want to highlight.</Card>

<CardGrid>
<Card title="Stars" icon="star">
Sirius, Vega, Betelgeuse
</Card>
<Card title="Moons" icon="moon">
Io, Europa, Ganymede
</Card>
</CardGrid>

:::tip
Use a card grid on your home page to display your project鈥檚 key features.
Add the `stagger` attribute to shift the second column of cards vertically and add visual interest:

```astro
<CardGrid stagger>
<!-- cards -->
</CardGrid>
```

:::
43 changes: 26 additions & 17 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,32 @@ hero:
link: https://github.com/withastro/starlight
---

:::caution[Work in progress]
Starlight is in early development so expect bugs and changes as we develop it.
If you find something that鈥檚 not working, [open an issue on GitHub](https://github.com/withastro/starlight/issues/new/choose) or let us know on [Discord](https://astro.build/chat).
:::
import { CardGrid, Card } from '@astrojs/starlight/components';
import AboutAstro from '../../components/about-astro.astro';

## What鈥檚 in the box?
<CardGrid stagger>
<Card title="Documentation that delights" icon="open-book">
Includes: Site navigation, search, i18n, SEO, easy-to-read typography, code
highlighting, dark mode and more.
</Card>
<Card title="Powered by Astro" icon="rocket">
Leverage the full power and performance of Astro. Extend Starlight with your
favorite Astro integrations and libraries.
</Card>
<Card title="Markdown, Markdoc, and MDX" icon="document">
Bring your favorite markup language. Starlight gives you built-in
frontmatter validation with TypeScript type-safety.
</Card>
<Card title="Bring your own UI components" icon="puzzle">
Starlight ships as a framework-agnostic, complete docs solution. Extend with
React, Vue, Svelte, Solid, and more.
</Card>
</CardGrid>

Starlight includes all the features you need to get a documentation site up and running quickly:
<AboutAstro title="Brought to you by">
Astro is the all-in-one web framework designed for speed.
Pull your content from anywhere and deploy everywhere, all powered by your favorite UI components and libraries.

- Markdown and MDX support
- Easy-to-read typographic styles
- Syntax highlighting for code blocks
- Simple-to-configure navigation menus
- Built-in site search
- [Internationalization features](/guides/i18n)
- Accessible site structure
- [Component in content](/guides/components) support with MDX
- Support for custom styles
- Fast and [eco-friendly](/environmental-impact) architecture
- Compatibility with the [Astro ecosystem](https://astro.build/integrations)
[Learn about Astro](https://astro.build/)

</AboutAstro>
2 changes: 2 additions & 0 deletions packages/starlight/components.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { default as Card } from './user-components/Card.astro';
export { default as CardGrid } from './user-components/CardGrid.astro';
export { default as Tabs } from './user-components/Tabs.astro';
export { default as TabItem } from './user-components/TabItem.astro';
2 changes: 1 addition & 1 deletion packages/starlight/components/CallToAction.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { link, variant, icon } = Astro.props;
gap: 0.5em;
align-items: center;
border-radius: 999rem;
padding: 0.75rem 1.125rem;
padding: 0.5rem 1.125rem;
color: var(--sl-color-white);
line-height: 1.1875;
text-decoration: none;
Expand Down
1 change: 1 addition & 0 deletions packages/starlight/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const {
display: grid;
align-items: center;
gap: 1rem;
padding-bottom: 1rem;
}

.hero > img,
Expand Down

0 comments on commit 55fec5d

Please sign in to comment.