brand-twitch-icon
itshover/brand-twitch-iconFreeComponent
itshover publishes no description for this item.
Install it
npx shadcn@latest add https://itshover.com/r/brand-twitch-icon.jsonSource
1import { forwardRef, useImperativeHandle, useCallback, useRef } from "react";2import type { AnimatedIconHandle, AnimatedIconProps } from "./types";3import { motion, useAnimate } from "motion/react";45const BrandTwitchIcon = forwardRef<AnimatedIconHandle, AnimatedIconProps>(6 (7 { size = 24, color = "currentColor", strokeWidth = 2, className = "" },8 ref,9 ) => {10 const [scope, animate] = useAnimate();11 const isAnimatingRef = useRef(false);1213 const start = useCallback(async () => {14 if (isAnimatingRef.current) return;15 isAnimatingRef.current = true;1617 // 1. Color Shift to Twitch Purple18 animate(19 scope.current,20 { color: "#9146FF", stroke: "#9146FF" },21 { duration: 0.3 },22 );2324 while (isAnimatingRef.current) {25 // 2. The Blink (Random intervals)26 await animate(27 ".twitch-eyes",28 { scaleY: [1, 0, 1] },29 { duration: 0.1, ease: "easeInOut" },30 );3132 if (!isAnimatingRef.current) break;3334 // 3. The Glitch (Rare sharp shift)35 if (Math.random() > 0.6) {36 await animate(37 ".twitch-path",38 { x: [0, -1, 1, 0], y: [0, 0.5, -0.5, 0] },39 { duration: 0.15, ease: "linear" },40 );41 }4243 await new Promise((resolve) =>44 setTimeout(resolve, 800 + Math.random() * 2000),45 );46 }47 }, [animate, scope]);4849 const stop = useCallback(() => {50 isAnimatingRef.current = false;51 animate(scope.current, { color, stroke: color }, { duration: 0.3 });52 animate(".twitch-eyes", { scaleY: 1 }, { duration: 0.3 });53 animate(".twitch-path", { x: 0, y: 0 }, { duration: 0.3 });54 }, [animate, color, scope]);5556 useImperativeHandle(ref, () => ({57 startAnimation: start,58 stopAnimation: stop,59 }));6061 return (62 <motion.svg63 ref={scope}64 onHoverStart={start}65 onHoverEnd={stop}66 xmlns="http://www.w3.org/2000/svg"67 width={size}68 height={size}69 viewBox="0 0 24 24"70 fill="none"71 stroke={color}72 strokeWidth={strokeWidth}73 strokeLinecap="round"74 strokeLinejoin="round"75 className={`cursor-pointer ${className}`}76 style={{ overflow: "visible" }}77 >78 <motion.path79 className="twitch-path"80 d="M21 2H3v16h5v4l4-4h5l4-4V2z"81 style={{ transformOrigin: "center" }}82 />83 <motion.g84// … truncated
What it pulls in
npm packages
Files it writes
More from itshover
All 263 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accessibility-iconaccessibility-icon | itshover | Components | Free | 1 dep · 2 files | |
| airplane-iconairplane-icon | itshover | Components | Free | 1 dep · 2 files | |
| alarm-clock-plus-iconalarm-clock-plus-icon | itshover | Components | Free | 1 dep · 2 files | |
| align-center-iconalign-center-icon | itshover | Components | Free | 1 dep · 2 files | |
| align-vertical-space-around-iconalign-vertical-space-around-icon | itshover | Components | Free | 1 dep · 2 files | |
| ambulance-iconambulance-icon | itshover | Components | Free | 1 dep · 2 files | |
| ampersand-iconampersand-icon | itshover | Components | Free | 1 dep · 2 files | |
| angry-iconangry-icon | itshover | Components | Free | 1 dep · 2 files |
