Skip to content

Commit eb8251b

Browse files
committed
fix: eslint disable on animated grid pattern ui component
1 parent bb5109c commit eb8251b

File tree

5 files changed

+91
-102
lines changed

5 files changed

+91
-102
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { ReactNode } from "react";
1+
import { ReactNode } from 'react'
22

3-
import { cn } from "@/lib/utils";
3+
import { cn } from '@/lib/utils'
44

55
export default function AnimatedGradientText({
66
children,
7-
className,
7+
className
88
}: {
9-
children: ReactNode;
10-
className?: string;
9+
children: ReactNode
10+
className?: string
1111
}) {
1212
return (
1313
<div
1414
className={cn(
15-
"group relative mx-auto flex max-w-fit flex-row items-center justify-center rounded-2xl bg-white/40 px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f] backdrop-blur-sm transition-shadow duration-500 ease-out [--bg-size:300%] hover:shadow-[inset_0_-5px_10px_#8fdfff3f] dark:bg-black/40",
16-
className,
15+
'group relative mx-auto flex max-w-fit flex-row items-center justify-center rounded-2xl bg-white/40 px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f] backdrop-blur-sm transition-shadow duration-500 ease-out [--bg-size:300%] hover:shadow-[inset_0_-5px_10px_#8fdfff3f] dark:bg-black/40',
16+
className
1717
)}
1818
>
1919
<div
@@ -22,5 +22,5 @@ export default function AnimatedGradientText({
2222

2323
{children}
2424
</div>
25-
);
25+
)
2626
}
Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
"use client";
1+
/* eslint-disable react-hooks/exhaustive-deps */
2+
/* eslint-disable @typescript-eslint/no-unused-vars */
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
'use client'
25

3-
import { useEffect, useId, useRef, useState } from "react";
4-
import { motion } from "framer-motion";
6+
import { useEffect, useId, useRef, useState } from 'react'
7+
import { motion } from 'framer-motion'
58

6-
import { cn } from "@/lib/utils";
9+
import { cn } from '@/lib/utils'
710

811
interface GridPatternProps {
9-
width?: number;
10-
height?: number;
11-
x?: number;
12-
y?: number;
13-
strokeDasharray?: any;
14-
numSquares?: number;
15-
className?: string;
16-
maxOpacity?: number;
17-
duration?: number;
18-
repeatDelay?: number;
12+
width?: number
13+
height?: number
14+
x?: number
15+
y?: number
16+
strokeDasharray?: any
17+
numSquares?: number
18+
className?: string
19+
maxOpacity?: number
20+
duration?: number
21+
repeatDelay?: number
1922
}
2023

2124
export function GridPattern({
@@ -31,24 +34,24 @@ export function GridPattern({
3134
repeatDelay = 0.5,
3235
...props
3336
}: GridPatternProps) {
34-
const id = useId();
35-
const containerRef = useRef(null);
36-
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
37-
const [squares, setSquares] = useState(() => generateSquares(numSquares));
37+
const id = useId()
38+
const containerRef = useRef(null)
39+
const [dimensions, setDimensions] = useState({ width: 0, height: 0 })
40+
const [squares, setSquares] = useState(() => generateSquares(numSquares))
3841

3942
function getPos() {
4043
return [
4144
Math.floor((Math.random() * dimensions.width) / width),
42-
Math.floor((Math.random() * dimensions.height) / height),
43-
];
45+
Math.floor((Math.random() * dimensions.height) / height)
46+
]
4447
}
4548

4649
// Adjust the generateSquares function to return objects with an id, x, and y
4750
function generateSquares(count: number) {
4851
return Array.from({ length: count }, (_, i) => ({
4952
id: i,
50-
pos: getPos(),
51-
}));
53+
pos: getPos()
54+
}))
5255
}
5356

5457
// Function to update a single square's position
@@ -58,70 +61,60 @@ export function GridPattern({
5861
sq.id === id
5962
? {
6063
...sq,
61-
pos: getPos(),
64+
pos: getPos()
6265
}
63-
: sq,
64-
),
65-
);
66-
};
66+
: sq
67+
)
68+
)
69+
}
6770

6871
// Update squares to animate in
6972
useEffect(() => {
7073
if (dimensions.width && dimensions.height) {
71-
setSquares(generateSquares(numSquares));
74+
setSquares(generateSquares(numSquares))
7275
}
73-
}, [dimensions, numSquares]);
76+
// eslint-disable-next-line react-hooks/exhaustive-deps
77+
}, [dimensions, numSquares])
7478

7579
// Resize observer to update container dimensions
7680
useEffect(() => {
7781
const resizeObserver = new ResizeObserver((entries) => {
78-
for (let entry of entries) {
82+
for (const entry of entries) {
7983
setDimensions({
8084
width: entry.contentRect.width,
81-
height: entry.contentRect.height,
82-
});
85+
height: entry.contentRect.height
86+
})
8387
}
84-
});
88+
})
8589

8690
if (containerRef.current) {
87-
resizeObserver.observe(containerRef.current);
91+
resizeObserver.observe(containerRef.current)
8892
}
8993

9094
return () => {
9195
if (containerRef.current) {
92-
resizeObserver.unobserve(containerRef.current);
96+
resizeObserver.unobserve(containerRef.current)
9397
}
94-
};
95-
}, [containerRef]);
98+
}
99+
}, [containerRef])
96100

97101
return (
98102
<svg
99103
ref={containerRef}
100-
aria-hidden="true"
104+
aria-hidden='true'
101105
className={cn(
102-
"pointer-events-none absolute inset-0 h-full w-full fill-gray-400/30 stroke-gray-400/30",
103-
className,
106+
'pointer-events-none absolute inset-0 h-full w-full fill-gray-400/30 stroke-gray-400/30',
107+
className
104108
)}
105109
{...props}
106110
>
107111
<defs>
108-
<pattern
109-
id={id}
110-
width={width}
111-
height={height}
112-
patternUnits="userSpaceOnUse"
113-
x={x}
114-
y={y}
115-
>
116-
<path
117-
d={`M.5 ${height}V.5H${width}`}
118-
fill="none"
119-
strokeDasharray={strokeDasharray}
120-
/>
112+
<pattern id={id} width={width} height={height} patternUnits='userSpaceOnUse' x={x} y={y}>
113+
<path d={`M.5 ${height}V.5H${width}`} fill='none' strokeDasharray={strokeDasharray} />
121114
</pattern>
122115
</defs>
123-
<rect width="100%" height="100%" fill={`url(#${id})`} />
124-
<svg x={x} y={y} className="overflow-visible">
116+
<rect width='100%' height='100%' fill={`url(#${id})`} />
117+
<svg x={x} y={y} className='overflow-visible'>
125118
{squares.map(({ pos: [x, y], id }, index) => (
126119
<motion.rect
127120
initial={{ opacity: 0 }}
@@ -130,21 +123,21 @@ export function GridPattern({
130123
duration,
131124
repeat: 1,
132125
delay: index * 0.1,
133-
repeatType: "reverse",
126+
repeatType: 'reverse'
134127
}}
135128
onAnimationComplete={() => updateSquarePosition(id)}
136129
key={`${x}-${y}-${index}`}
137130
width={width - 1}
138131
height={height - 1}
139132
x={x * width + 1}
140133
y={y * height + 1}
141-
fill="currentColor"
142-
strokeWidth="0"
134+
fill='currentColor'
135+
strokeWidth='0'
143136
/>
144137
))}
145138
</svg>
146139
</svg>
147-
);
140+
)
148141
}
149142

150-
export default GridPattern;
143+
export default GridPattern

src/components/ui/blur-fade.tsx

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
"use client";
1+
'use client'
22

3-
import { useRef } from "react";
4-
import {
5-
AnimatePresence,
6-
motion,
7-
useInView,
8-
UseInViewOptions,
9-
Variants,
10-
} from "framer-motion";
3+
import { useRef } from 'react'
4+
import { AnimatePresence, motion, useInView, UseInViewOptions, Variants } from 'framer-motion'
115

12-
type MarginType = UseInViewOptions["margin"];
6+
type MarginType = UseInViewOptions['margin']
137

148
interface BlurFadeProps {
15-
children: React.ReactNode;
16-
className?: string;
9+
children: React.ReactNode
10+
className?: string
1711
variant?: {
18-
hidden: { y: number };
19-
visible: { y: number };
20-
};
21-
duration?: number;
22-
delay?: number;
23-
yOffset?: number;
24-
inView?: boolean;
25-
inViewMargin?: MarginType;
26-
blur?: string;
12+
hidden: { y: number }
13+
visible: { y: number }
14+
}
15+
duration?: number
16+
delay?: number
17+
yOffset?: number
18+
inView?: boolean
19+
inViewMargin?: MarginType
20+
blur?: string
2721
}
2822

2923
export default function BlurFade({
@@ -34,34 +28,34 @@ export default function BlurFade({
3428
delay = 0,
3529
yOffset = 6,
3630
inView = false,
37-
inViewMargin = "-50px",
38-
blur = "6px",
31+
inViewMargin = '-50px',
32+
blur = '6px'
3933
}: BlurFadeProps) {
40-
const ref = useRef(null);
41-
const inViewResult = useInView(ref, { once: true, margin: inViewMargin });
42-
const isInView = !inView || inViewResult;
34+
const ref = useRef(null)
35+
const inViewResult = useInView(ref, { once: true, margin: inViewMargin })
36+
const isInView = !inView || inViewResult
4337
const defaultVariants: Variants = {
4438
hidden: { y: yOffset, opacity: 0, filter: `blur(${blur})` },
45-
visible: { y: -yOffset, opacity: 1, filter: `blur(0px)` },
46-
};
47-
const combinedVariants = variant || defaultVariants;
39+
visible: { y: -yOffset, opacity: 1, filter: `blur(0px)` }
40+
}
41+
const combinedVariants = variant || defaultVariants
4842
return (
4943
<AnimatePresence>
5044
<motion.div
5145
ref={ref}
52-
initial="hidden"
53-
animate={isInView ? "visible" : "hidden"}
54-
exit="hidden"
46+
initial='hidden'
47+
animate={isInView ? 'visible' : 'hidden'}
48+
exit='hidden'
5549
variants={combinedVariants}
5650
transition={{
5751
delay: 0.04 + delay,
5852
duration,
59-
ease: "easeOut",
53+
ease: 'easeOut'
6054
}}
6155
className={className}
6256
>
6357
{children}
6458
</motion.div>
6559
</AnimatePresence>
66-
);
60+
)
6761
}

src/pages/docs/_meta.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const meta = {
2+
index: 'Documentations',
23
drowser: 'Drowser',
34
gelda: 'Gelda'
45
}

src/pages/docs/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Index

0 commit comments

Comments
 (0)