Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/components/MetaInfo.astro
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>
26 changes: 26 additions & 0 deletions src/components/Type.astro
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",
}}
/>
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { default as LinkTitleCard } from "./LinkTitleCard.astro";
export { default as ListExamples } from "./ListExamples.astro";
export { default as ListTutorials } from "./ListTutorials.astro";
export { default as Markdown } from "./Markdown.astro";
export { default as MetaInfo } from "./MetaInfo.astro";
export { default as NetworkMap } from "./NetworkMap.astro";
export { default as PagesBuildEnvironment } from "./PagesBuildEnvironment.astro";
export { default as PagesBuildEnvironmentLanguages } from "./PagesBuildEnvironmentLanguages.astro";
Expand All @@ -48,6 +49,7 @@ export { default as Stream } from "./Stream.astro";
export { default as ThreeCardGrid } from "./ThreeCardGrid.astro";
export { default as TroubleshootingList } from "./TroubleshootingList.astro";
export { default as TunnelCalculator } from "./TunnelCalculator.astro";
export { default as Type } from "./Type.astro";
export { default as WorkersAIModels } from "./WorkersAIModels.astro";
export { default as WorkersArchitectureDiagram } from "./WorkersArchitectureDiagram.astro";
export { default as WorkersIsolateDiagram } from "./WorkersIsolateDiagram.astro";
Expand Down
31 changes: 31 additions & 0 deletions src/content/docs/style-guide/components/type-highlighting.mdx
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.
```