-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs Site] Add components for type highlighting (#17056)
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
import { z } from "astro:schema"; | ||
type Props = z.infer<typeof props>; | ||
const props = z | ||
.object({ | ||
text: z.string(), | ||
}) | ||
.strict(); | ||
const { text } = props.parse(Astro.props); | ||
--- | ||
|
||
<span class="text-xs align-middle">{text}</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
import { z } from "astro:schema"; | ||
import { Badge } from "@astrojs/starlight/components"; | ||
type Props = z.infer<typeof props>; | ||
const props = z | ||
.object({ | ||
text: z.string(), | ||
}) | ||
.strict(); | ||
const { text } = props.parse(Astro.props); | ||
--- | ||
|
||
<Badge | ||
text={text} | ||
size="small" | ||
style={{ | ||
color: "var(--sl-text-white)", | ||
backgroundColor: "var(--sl-color-gray-6)", | ||
borderColor: "var(--sl-color-gray-3)", | ||
fontSize: "0.7rem", | ||
fontWeight: "bold", | ||
}} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/content/docs/style-guide/components/type-highlighting.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: Type highlighting | ||
description: Components for styling type information for CLI/function parameters. | ||
--- | ||
|
||
## Type | ||
|
||
```mdx live | ||
import { Type } from "~/components"; | ||
|
||
<Type text="Promise<T | string | ArrayBuffer>" /> | ||
``` | ||
|
||
## MetaInfo | ||
|
||
```mdx live | ||
import { MetaInfo } from "~/components"; | ||
|
||
<MetaInfo text="(default: false) optional" /> | ||
``` | ||
|
||
## Combined example | ||
|
||
```mdx live | ||
import { Type, MetaInfo } from "~/components"; | ||
|
||
- `name` <Type text="string" /> | ||
- The name of your service. | ||
- `local` <Type text="boolean" /> <MetaInfo text="(default: true) optional" /> | ||
- If the service should run locally or not. | ||
``` |