Skip to content

Commit 8552c0a

Browse files
committed
use unique ID for gradient identifier
1 parent 60d07ce commit 8552c0a

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stellaraf/logo",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Stellar's Logo as a React Component",
55
"type": "module",
66
"main": "dist/cjs/index.js",

src/logo.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, useMemo } from "react";
1+
import { forwardRef, useMemo, useId } from "react";
22
import { motion, isValidMotionProp } from "framer-motion";
33

44
import type { MotionProps, AnimationProps } from "framer-motion";
@@ -31,6 +31,8 @@ export const StellarLogo: ComponentType = forwardRef<SVGSVGElement, StellarLogoP
3131
...rest
3232
} = props;
3333

34+
const gradientId = useId();
35+
3436
const motionProps: MotionProps = Object.fromEntries(
3537
Object.entries(rest).filter(([k]) => isValidMotionProp(k)),
3638
);
@@ -61,10 +63,7 @@ export const StellarLogo: ComponentType = forwardRef<SVGSVGElement, StellarLogoP
6163
: { scale: [0, 0.5, 1, 1.25, 1.5, 1, 0.75, 1], rotate: [0, 0, 0, 15, 20, 0, 0, 0] };
6264
}, [noAnimate]);
6365

64-
const fill = useMemo<string>(
65-
() => (colorMode === "light" ? "url(#logoGradient)" : "currentColor"),
66-
[colorMode],
67-
);
66+
const fill = colorMode === "light" ? `url(#${gradientId})` : "currentColor";
6867

6968
const viewBox = useMemo<string>(() => {
7069
let x = "380";
@@ -89,7 +88,7 @@ export const StellarLogo: ComponentType = forwardRef<SVGSVGElement, StellarLogoP
8988
{...motionProps}
9089
>
9190
<defs>
92-
<linearGradient id="logoGradient" gradientTransform="rotate(90)">
91+
<linearGradient id={gradientId} gradientTransform="rotate(90)">
9392
<stop offset="5%" stopColor={StellarColors.purple} />
9493
<stop offset="95%" stopColor={StellarColors.blue} />
9594
</linearGradient>

0 commit comments

Comments
 (0)