Skip to content

Commit c868c9c

Browse files
committed
[Docs Site] Add Width component
1 parent fd395fe commit c868c9c

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

src/components/Width.astro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
import { z } from "astro:schema";
3+
4+
const props = z.object({
5+
size: z.enum(["large", "medium", "small"])
6+
});
7+
8+
type Props = z.infer<typeof props>;
9+
const { size } = Astro.props;
10+
11+
const widthClasses = {
12+
large: "w-3/4",
13+
medium: "w-1/2",
14+
small: "w-1/4"
15+
};
16+
---
17+
18+
<div class={widthClasses[size]}>
19+
<slot />
20+
</div>

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export { default as Type } from "./Type.astro";
5959
export { default as TypeScriptExample } from "./TypeScriptExample.astro";
6060
export { default as WranglerConfig } from "./WranglerConfig.astro";
6161
export { default as WARPReleases } from "./WARPReleases.astro";
62+
export { default as Width } from "./Width.astro";
6263
export { default as WorkersArchitectureDiagram } from "./WorkersArchitectureDiagram.astro";
6364
export { default as WorkersIsolateDiagram } from "./WorkersIsolateDiagram.astro";
6465
export { default as WorkerStarter } from "./WorkerStarter.astro";
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Width
3+
styleGuide:
4+
component: Width
5+
---
6+
7+
This component can be used to constrain the width of content, such as text or images.
8+
9+
## Import
10+
11+
```mdx
12+
import { Width } from "~/components";
13+
```
14+
15+
## Usage
16+
17+
```mdx live
18+
import { Width } from "~/components";
19+
20+
<Width size="large">This content will take up 75% of the container width</Width>
21+
22+
<Width size="medium">
23+
This content will take up 50% of the container width
24+
</Width>
25+
26+
<Width size="small">This content will take up 25% of the container width</Width>
27+
```
28+
29+
## `<Width>` Props
30+
31+
### `size`
32+
33+
**required**
34+
35+
**type:** `"large" | "medium" | "small"`
36+
37+
Controls the width of the container:
38+
39+
- `large`: 75% of container width
40+
- `medium`: 50% of container width
41+
- `small`: 25% of container width

0 commit comments

Comments
 (0)