From f18661fc47da152e7555d24b23143f0b481c852b Mon Sep 17 00:00:00 2001 From: Harry Ross Date: Sat, 17 Aug 2024 05:18:24 +1000 Subject: [PATCH] Types - Added Better Typings for Width, Height + Size (#219) * added string to union type for height, width and size * added changeset * Updated docs with new props --- .changeset/nine-poems-teach.md | 5 +++++ packages/core/components/Icon.astro | 6 +++--- packages/www/src/content/docs/guides/components.mdx | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/nine-poems-teach.md diff --git a/.changeset/nine-poems-teach.md b/.changeset/nine-poems-teach.md new file mode 100644 index 0000000..08dfbbc --- /dev/null +++ b/.changeset/nine-poems-teach.md @@ -0,0 +1,5 @@ +--- +"astro-icon": patch +--- + +Added better typings for height, width and size to accept non-number values (i.e. 2 rem) diff --git a/packages/core/components/Icon.astro b/packages/core/components/Icon.astro index 43d202d..341ef0a 100644 --- a/packages/core/components/Icon.astro +++ b/packages/core/components/Icon.astro @@ -11,9 +11,9 @@ interface Props extends HTMLAttributes<"svg"> { name: Icon; "is:inline"?: boolean; title?: string; - size?: number; - width?: number; - height?: number; + size?: number | string; + width?: number | string; + height?: number | string; } class AstroIconError extends Error { diff --git a/packages/www/src/content/docs/guides/components.mdx b/packages/www/src/content/docs/guides/components.mdx index fb5378b..a475cc3 100644 --- a/packages/www/src/content/docs/guides/components.mdx +++ b/packages/www/src/content/docs/guides/components.mdx @@ -31,9 +31,9 @@ interface Props extends HTMLAttributes<"svg"> { /** Shorthand for including a {props.title} element in the SVG */ title?: string; /** Shorthand for setting width and height */ - size?: number; - width?: number; - height?: number; + size?: number | string; + width?: number | string; + height?: number | string; } ```