Skip to content

Commit 1e64cc0

Browse files
committed
refactor: improve code consistency by standardizing quotation marks and enhancing state management in various components
1 parent e30e38e commit 1e64cc0

File tree

5 files changed

+52
-47
lines changed

5 files changed

+52
-47
lines changed

apps/torus-governance/src/app/(expanded-pages)/proposal/[id]/_components/proposal-expanded-view.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { VoteData } from "~/app/_components/vote-data";
1515
import { useGovernance } from "~/context/governance-provider";
1616
import type { VoteStatus } from "~/utils/types";
1717
import { LoaderCircle } from "lucide-react";
18-
import { useState, useEffect } from "react";
18+
import { useEffect, useState } from "react";
1919
import { ProposalStatusLabel } from "../../../../_components/proposal/proposal-status-label";
2020
import { handleCustomProposal } from "../../../../../utils";
2121

@@ -58,7 +58,7 @@ export function ProposalExpandedView(props: Readonly<CustomContent>) {
5858
selectedAccount,
5959
torusCacheUrl,
6060
} = useGovernance();
61-
61+
6262
const [isMobile, setIsMobile] = useState(() => {
6363
if (typeof window !== "undefined") {
6464
return window.innerWidth < 768;
@@ -71,8 +71,8 @@ export function ProposalExpandedView(props: Readonly<CustomContent>) {
7171
setIsMobile(window.innerWidth < 768);
7272
};
7373

74-
window.addEventListener('resize', handleResize);
75-
return () => window.removeEventListener('resize', handleResize);
74+
window.addEventListener("resize", handleResize);
75+
return () => window.removeEventListener("resize", handleResize);
7676
}, []);
7777

7878
const content = (() => {

apps/torus-page/src/app/_components/hover-header/_components/desktop/buttons-section.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { Button } from "@torus-ts/ui/components/button";
32
import { Card } from "@torus-ts/ui/components/card";
43
import { ScrollArea } from "@torus-ts/ui/components/scroll-area";

apps/torus-page/src/app/_components/hover-header/index.tsx

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,39 @@ export function HoverHeader() {
2222

2323
const [isExpanded, setIsExpanded] = useState(false);
2424

25-
const calculateDistance = useCallback((
26-
x1: number,
27-
y1: number,
28-
x2: number,
29-
y2: number,
30-
): number => {
31-
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
32-
}, []);
33-
34-
const handleMouseMove = useCallback((event: MouseEvent) => {
35-
const logoRect = contentRef.current?.getBoundingClientRect();
36-
if (!logoRect) {
37-
setGlowSize(0.8);
38-
return;
39-
}
40-
41-
const logoCenterX = logoRect.left + logoRect.width / 2;
42-
const logoCenterY = logoRect.top + logoRect.height / 2;
43-
44-
const distance = calculateDistance(
45-
event.clientX,
46-
event.clientY,
47-
logoCenterX,
48-
logoCenterY,
49-
);
50-
const maxDistance = Math.sqrt(
51-
Math.pow(window.innerWidth, 2) + Math.pow(window.innerHeight, 2),
52-
);
25+
const calculateDistance = useCallback(
26+
(x1: number, y1: number, x2: number, y2: number): number => {
27+
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
28+
},
29+
[],
30+
);
5331

54-
const scale = 0.15 + (maxDistance - distance) / maxDistance;
55-
setGlowSize(scale / 1.2);
56-
}, [calculateDistance]);
32+
const handleMouseMove = useCallback(
33+
(event: MouseEvent) => {
34+
const logoRect = contentRef.current?.getBoundingClientRect();
35+
if (!logoRect) {
36+
setGlowSize(0.8);
37+
return;
38+
}
39+
40+
const logoCenterX = logoRect.left + logoRect.width / 2;
41+
const logoCenterY = logoRect.top + logoRect.height / 2;
42+
43+
const distance = calculateDistance(
44+
event.clientX,
45+
event.clientY,
46+
logoCenterX,
47+
logoCenterY,
48+
);
49+
const maxDistance = Math.sqrt(
50+
Math.pow(window.innerWidth, 2) + Math.pow(window.innerHeight, 2),
51+
);
52+
53+
const scale = 0.15 + (maxDistance - distance) / maxDistance;
54+
setGlowSize(scale / 1.2);
55+
},
56+
[calculateDistance],
57+
);
5758

5859
useEffect(() => {
5960
window.addEventListener("mousemove", handleMouseMove);
@@ -63,16 +64,19 @@ export function HoverHeader() {
6364
};
6465
}, [handleMouseMove]);
6566

66-
const glowVariants = useMemo(() => ({
67-
pulse: (scale: number) => ({
68-
scale: [scale, scale * 1.2, scale],
69-
transition: {
70-
duration: 2,
71-
repeat: Infinity,
72-
ease: "easeInOut",
73-
},
67+
const glowVariants = useMemo(
68+
() => ({
69+
pulse: (scale: number) => ({
70+
scale: [scale, scale * 1.2, scale],
71+
transition: {
72+
duration: 2,
73+
repeat: Infinity,
74+
ease: "easeInOut",
75+
},
76+
}),
7477
}),
75-
}), []);
78+
[],
79+
);
7680

7781
const handleClickOutside = useCallback((event: MouseEvent) => {
7882
if (

apps/torus-page/src/app/_components/torus-animation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const Torus: FC = () => {
9191
}, []);
9292

9393
useFrame((_state, delta) => {
94-
if (torusRef.current?.material && 'uniforms' in torusRef.current.material) {
94+
if (torusRef.current?.material && "uniforms" in torusRef.current.material) {
9595
const material = torusRef.current.material as THREE.ShaderMaterial;
9696
if (material.uniforms.time) {
9797
material.uniforms.time.value += 0.1 * 60 * delta;

apps/torus-wallet/src/app/_components/transactions-sheet.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function TransactionsSheet() {
2323
const timer = setTimeout(() => setShouldRenderContent(true), 150);
2424
return () => clearTimeout(timer);
2525
} else {
26-
const frameId = requestAnimationFrame(() => setShouldRenderContent(false));
26+
const frameId = requestAnimationFrame(() =>
27+
setShouldRenderContent(false),
28+
);
2729
return () => cancelAnimationFrame(frameId);
2830
}
2931
}, [isOpen]);

0 commit comments

Comments
 (0)