Skip to content

Commit 02b3a07

Browse files
committed
use zod
1 parent c868c9c commit 02b3a07

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/components/Width.astro

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
22
import { z } from "astro:schema";
33
4+
type Props = z.infer<typeof props>;
5+
46
const props = z.object({
5-
size: z.enum(["large", "medium", "small"])
7+
size: z.enum(["large", "medium", "small"]),
68
});
79
8-
type Props = z.infer<typeof props>;
9-
const { size } = Astro.props;
10+
const { size } = props.parse(Astro.props);
1011
1112
const widthClasses = {
12-
large: "w-3/4",
13-
medium: "w-1/2",
14-
small: "w-1/4"
13+
large: "w-3/4",
14+
medium: "w-1/2",
15+
small: "w-1/4",
1516
};
1617
---
1718

1819
<div class={widthClasses[size]}>
19-
<slot />
20+
<slot />
2021
</div>

0 commit comments

Comments
 (0)