Skip to content

Commit a231a73

Browse files
authored
Merge pull request #2146 from VaishnaviMankala19/glowing-cursor
added cursor
2 parents 5387f9e + 48d2c12 commit a231a73

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

src/components/GlowingCursor.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { useEffect } from 'react';
2+
import '../css/custom.css';
3+
4+
const CursorComponent = () => {
5+
useEffect(() => {
6+
const cursor = document.querySelector('.cursor');
7+
8+
const moveCursor = (e) => {
9+
cursor.style.left = e.pageX + 'px';
10+
cursor.style.top = e.pageY + 'px';
11+
};
12+
13+
document.addEventListener('mousemove', moveCursor);
14+
15+
return () => {
16+
document.removeEventListener('mousemove', moveCursor);
17+
};
18+
}, []);
19+
20+
return (
21+
<div className="cursor-container">
22+
<div className="cursor"></div>
23+
</div>
24+
);
25+
};
26+
27+
export default CursorComponent;

src/css/custom.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,30 @@ th {
368368
.row .col .card {
369369
margin-top: 10px;
370370
}
371+
372+
/* Define the glowing cursor */
373+
html {
374+
cursor: none;
375+
}
376+
377+
.cursor {
378+
position: absolute;
379+
width: 20px;
380+
height: 20px;
381+
border-radius: 50%;
382+
background-color: deepskyblue;
383+
mix-blend-mode: difference;
384+
pointer-events: none;
385+
transform: translate(-50%, -50%);
386+
transition: width 0.3s, height 0.3s, background-color 0.3s;
387+
animation: glow 1s infinite alternate;
388+
}
389+
390+
@keyframes glow {
391+
0% {
392+
box-shadow: 0 0 10px 5px rgba(0, 191, 255, 0.5);
393+
}
394+
100% {
395+
box-shadow: 0 0 20px 10px rgba(0, 191, 255, 0.9);
396+
}
397+
}

src/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'swiper/css/navigation';
1717
import 'swiper/css/pagination';
1818
import { Swiper, SwiperSlide } from 'swiper/react';
1919
import { Navigation, Pagination, Autoplay } from 'swiper/modules';
20+
import CursorComponent from '../components/GlowingCursor'
2021

2122
function TweetsSection() {
2223
const tweetColumns = [[], [], []];
@@ -107,7 +108,7 @@ export default function Home() {
107108
</div>
108109

109110
<TweetsSection />
110-
111+
<CursorComponent/>
111112
<ScrollTopToButton />
112113
<ScrollBottomToTop />
113114
</main>

0 commit comments

Comments
 (0)