File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
content/docs/style-guide/components Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ import { z } from " astro:schema" ;
3+
4+ type Props = z .infer <typeof props >;
5+
6+ const props = z .object ({
7+ size: z .enum ([" large" , " medium" , " small" ]),
8+ center: z .boolean ().default (false ),
9+ });
10+
11+ const { size, center } = props .parse (Astro .props );
12+
13+ const widthClasses = {
14+ large: " w-3/4" ,
15+ medium: " w-1/2" ,
16+ small: " w-1/4" ,
17+ };
18+ ---
19+
20+ <div class:list ={ [widthClasses [size ], center ? " mx-auto" : " " ]} >
21+ <slot />
22+ </div >
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export { default as Type } from "./Type.astro";
5959export { default as TypeScriptExample } from "./TypeScriptExample.astro" ;
6060export { default as WranglerConfig } from "./WranglerConfig.astro" ;
6161export { default as WARPReleases } from "./WARPReleases.astro" ;
62+ export { default as Width } from "./Width.astro" ;
6263export { default as WorkersArchitectureDiagram } from "./WorkersArchitectureDiagram.astro" ;
6364export { default as WorkersIsolateDiagram } from "./WorkersIsolateDiagram.astro" ;
6465export { default as WorkerStarter } from "./WorkerStarter.astro" ;
Original file line number Diff line number Diff line change 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+ <Width size = " small" center >
29+ This content will take up 25% of the container width and be centered
30+ </Width >
31+ ```
32+
33+ ## ` <Width> ` Props
34+
35+ ### ` size `
36+
37+ ** required**
38+
39+ ** type:** ` "large" | "medium" | "small" `
40+
41+ Controls the width of the container:
42+
43+ - ` large ` : 75% of container width
44+ - ` medium ` : 50% of container width
45+ - ` small ` : 25% of container width
46+
47+ ### ` center `
48+
49+ ** type:** ` boolean `
50+
51+ Whether to horizontally center the content.
You can’t perform that action at this time.
0 commit comments