Skip to content

Commit fce07f1

Browse files
christina-de-martinezchristinamartineznatemoo-re
authored
feat(desc): support desc svg tag. (#247)
* feat(desc): support desc svg tag. * Create curvy-lions-dream.md --------- Co-authored-by: christinamartinez <[email protected]> Co-authored-by: Nate Moore <[email protected]>
1 parent 4060744 commit fce07f1

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

.changeset/curvy-lions-dream.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro-icon": patch
3+
---
4+
5+
Adds a `desc` prop shorthand which maps to the SVG `<desc>` tag, similar to `title`.

packages/core/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ interface Props extends HTMLAttributes<"svg"> {
101101
name: string;
102102
"is:inline"?: boolean;
103103
title?: string;
104+
desc?: string;
104105
size?: number | string;
105106
width?: number | string;
106107
height?: number | string;

packages/core/components/Icon.astro

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Props extends HTMLAttributes<"svg"> {
1111
name: Icon;
1212
"is:inline"?: boolean;
1313
title?: string;
14+
desc?: string;
1415
size?: number | string;
1516
width?: number | string;
1617
height?: number | string;
@@ -25,7 +26,7 @@ class AstroIconError extends Error {
2526
}
2627
2728
const req = Astro.request;
28-
const { name = "", title, "is:inline": inline = false, ...props } = Astro.props;
29+
const { name = "", title, desc, "is:inline": inline = false, ...props } = Astro.props;
2930
const map = cache.get(req) ?? new Map();
3031
const i = map.get(name) ?? 0;
3132
map.set(name, i + 1);
@@ -116,6 +117,7 @@ const normalizedBody = renderData.body;
116117

117118
<svg {...normalizedProps} data-icon={name}>
118119
{title && <title>{title}</title>}
120+
{desc && <desc>{desc}</desc>}
119121
{
120122
inline ? (
121123
<Fragment id={id} set:html={normalizedBody} />

packages/www/src/content/docs/guides/components.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ interface Props extends HTMLAttributes<"svg"> {
3030
name: string;
3131
/** Shorthand for including a <title>{props.title}</title> element in the SVG */
3232
title?: string;
33+
/** Shorthand for including a <desc>{props.desc}</desc> element in the SVG */
34+
desc?: string;
3335
/** Shorthand for setting width and height */
3436
size?: number | string;
3537
width?: number | string;

0 commit comments

Comments
 (0)