Skip to content

Commit 2eebb35

Browse files
authored
chore: set custom icon size (#6102)
1 parent 81366df commit 2eebb35

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/fern-docs/components/src/FernSvgIcon.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ export const FernSvgIcon: React.FC<FernSvgIconProps> = ({ src, alt, className })
3030
const svgDoc = parser.parseFromString(svgContent, "image/svg+xml");
3131
const svgElement = svgDoc.querySelector("svg");
3232

33-
if (svgElement && className) {
34-
const existingClass = svgElement.getAttribute("class");
35-
svgElement.setAttribute("class", existingClass ? `${existingClass} ${className}` : className);
33+
if (svgElement) {
34+
if (className) {
35+
const existingClass = svgElement.getAttribute("class");
36+
svgElement.setAttribute("class", existingClass ? `${existingClass} ${className}` : className);
37+
}
38+
39+
// size of svg should be set by parent element
40+
svgElement.setAttribute("width", "100%");
41+
svgElement.setAttribute("height", "100%");
3642
}
3743

3844
return svgElement ? new XMLSerializer().serializeToString(svgElement) : svgContent;

0 commit comments

Comments
 (0)