Skip to content

Commit fc5ea3d

Browse files
authored
Merge pull request #1 from SARVESHYOGI/dev
removed redundancy
2 parents ae42591 + 27123bf commit fc5ea3d

45 files changed

Lines changed: 1210 additions & 1569 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/Templates/HashDataStructureTemp.tsx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState, useEffect } from "react";
22
import { Button } from "../ui/button";
33
import Link from "next/link";
4+
import { accentColors, primaryColors, secondaryColors } from "@/lib/data";
45

56
const hashStructures = [
67
{ id: "hash-map", name: "Hash Map" },
@@ -60,47 +61,7 @@ function HashAnimation() {
6061
}, [isAnimating]);
6162

6263
const getHashColor = (index: number) => {
63-
// const theme = document.documentElement.getAttribute("data-theme");
6464
const value = Math.floor(Math.random() * 100);
65-
const primaryColors = [
66-
// "--primary-50",
67-
// "--primary-100",
68-
"--primary-200",
69-
"--primary-300",
70-
"--primary-400",
71-
"--primary-500",
72-
"--primary-600",
73-
"--primary-700",
74-
"--primary-800",
75-
"--primary-900",
76-
"--primary-950",
77-
];
78-
const secondaryColors = [
79-
// "--secondary-50",
80-
// "--secondary-100",
81-
"--secondary-200",
82-
"--secondary-300",
83-
"--secondary-400",
84-
"--secondary-500",
85-
"--secondary-600",
86-
"--secondary-700",
87-
"--secondary-800",
88-
"--secondary-900",
89-
"--secondary-950",
90-
];
91-
const accentColors = [
92-
// "--accent-50",
93-
// "--accent-100",
94-
"--accent-200",
95-
"--accent-300",
96-
"--accent-400",
97-
"--accent-500",
98-
"--accent-600",
99-
"--accent-700",
100-
"--accent-800",
101-
"--accent-900",
102-
"--accent-950",
103-
];
10465

10566
let colorSet = primaryColors;
10667

src/components/Templates/LinearDataStructureTemp.tsx

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState, useEffect } from "react";
22
import { Button } from "../ui/button";
33
import Link from "next/link";
4+
import { accentColors, primaryColors, secondaryColors } from "@/lib/data";
45

56
const linearStructures = [
67
{ id: "stack", name: "Stack" },
@@ -45,48 +46,6 @@ function LinearAnimation() {
4546
}, [isAnimating]);
4647

4748
const getElementColor = (value: number, index: number) => {
48-
// const theme = document.documentElement.getAttribute("data-theme");
49-
50-
const primaryColors = [
51-
// "--primary-50",
52-
// "--primary-100",
53-
"--primary-200",
54-
"--primary-300",
55-
"--primary-400",
56-
"--primary-500",
57-
"--primary-600",
58-
"--primary-700",
59-
"--primary-800",
60-
"--primary-900",
61-
"--primary-950",
62-
];
63-
const secondaryColors = [
64-
// "--secondary-50",
65-
// "--secondary-100",
66-
"--secondary-200",
67-
"--secondary-300",
68-
"--secondary-400",
69-
"--secondary-500",
70-
"--secondary-600",
71-
"--secondary-700",
72-
"--secondary-800",
73-
"--secondary-900",
74-
"--secondary-950",
75-
];
76-
const accentColors = [
77-
// "--accent-50",
78-
// "--accent-100",
79-
"--accent-200",
80-
"--accent-300",
81-
"--accent-400",
82-
"--accent-500",
83-
"--accent-600",
84-
"--accent-700",
85-
"--accent-800",
86-
"--accent-900",
87-
"--accent-950",
88-
];
89-
9049
let colorSet = primaryColors;
9150

9251
if (index % 3 === 1) colorSet = secondaryColors;

src/components/Templates/NonLinearDataStructureTemp.tsx

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState, useEffect } from "react";
22
import { Button } from "../ui/button";
3+
import { accentColors, primaryColors, secondaryColors } from "@/lib/data";
34

45
const nonLinearStructures = [
56
{ id: "binary-tree", name: "Binary Tree" },
@@ -49,48 +50,6 @@ function NonLinearAnimation() {
4950
}, [isAnimating]);
5051

5152
const getElementColor = (value: number, index: number) => {
52-
// const theme = document.documentElement.getAttribute("data-theme");
53-
54-
const primaryColors = [
55-
// "--primary-50",
56-
// "--primary-100",
57-
"--primary-200",
58-
"--primary-300",
59-
"--primary-400",
60-
"--primary-500",
61-
"--primary-600",
62-
"--primary-700",
63-
"--primary-800",
64-
"--primary-900",
65-
"--primary-950",
66-
];
67-
const secondaryColors = [
68-
// "--secondary-50",
69-
// "--secondary-100",
70-
"--secondary-200",
71-
"--secondary-300",
72-
"--secondary-400",
73-
"--secondary-500",
74-
"--secondary-600",
75-
"--secondary-700",
76-
"--secondary-800",
77-
"--secondary-900",
78-
"--secondary-950",
79-
];
80-
const accentColors = [
81-
// "--accent-50",
82-
// "--accent-100",
83-
"--accent-200",
84-
"--accent-300",
85-
"--accent-400",
86-
"--accent-500",
87-
"--accent-600",
88-
"--accent-700",
89-
"--accent-800",
90-
"--accent-900",
91-
"--accent-950",
92-
];
93-
9453
let colorSet = primaryColors;
9554

9655
if (index % 3 === 1) colorSet = secondaryColors;
@@ -109,7 +68,7 @@ function NonLinearAnimation() {
10968
value: number,
11069
x: number,
11170
y: number,
112-
level: number
71+
level: number,
11372
) => {
11473
return (
11574
<div

src/components/Templates/SearchingTemp.tsx

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
import React, { useState, useEffect } from "react";
33
import Link from "next/link";
44
import { Button } from "../ui/button";
5-
import { searchAlgorithms } from "@/lib/data";
5+
import {
6+
accentColors,
7+
primaryColors,
8+
searchAlgorithms,
9+
secondaryColors,
10+
} from "@/lib/data";
611

712
function SearchingAnimation() {
813
const [isAnimating, setIsAnimating] = useState<boolean>(false);
@@ -14,7 +19,7 @@ function SearchingAnimation() {
1419
const generateRandomArray = () => {
1520
const arr = Array.from(
1621
{ length: 12 },
17-
() => Math.floor(Math.random() * 80) + 10
22+
() => Math.floor(Math.random() * 80) + 10,
1823
);
1924
return arr.sort((a, b) => a - b);
2025
};
@@ -71,48 +76,6 @@ function SearchingAnimation() {
7176
};
7277

7378
const getBarColor = (value: number, index: number) => {
74-
// const theme = document.documentElement.getAttribute("data-theme");
75-
76-
const primaryColors = [
77-
// "--primary-50",
78-
// "--primary-100",
79-
"--primary-200",
80-
"--primary-300",
81-
"--primary-400",
82-
"--primary-500",
83-
"--primary-600",
84-
"--primary-700",
85-
"--primary-800",
86-
"--primary-900",
87-
"--primary-950",
88-
];
89-
const secondaryColors = [
90-
// "--secondary-50",
91-
// "--secondary-100",
92-
"--secondary-200",
93-
"--secondary-300",
94-
"--secondary-400",
95-
"--secondary-500",
96-
"--secondary-600",
97-
"--secondary-700",
98-
"--secondary-800",
99-
"--secondary-900",
100-
"--secondary-950",
101-
];
102-
const accentColors = [
103-
// "--accent-50",
104-
// "--accent-100",
105-
"--accent-200",
106-
"--accent-300",
107-
"--accent-400",
108-
"--accent-500",
109-
"--accent-600",
110-
"--accent-700",
111-
"--accent-800",
112-
"--accent-900",
113-
"--accent-950",
114-
];
115-
11679
let colorSet = primaryColors;
11780

11881
if (index % 3 === 1) colorSet = secondaryColors;
@@ -134,7 +97,6 @@ function SearchingAnimation() {
13497
height: `${getBarHeight(value)}px`,
13598
backgroundColor: "#00FF00",
13699
borderRadius: "50%",
137-
// transform: "scale(1.3)",
138100
transition: "all 0.5s ease",
139101
boxShadow: "0 6px 12px rgba(0, 128, 0, 0.4)",
140102
};
@@ -201,10 +163,10 @@ function SearchingAnimation() {
201163
{isAnimating
202164
? "Searching in progress..."
203165
: foundIndex !== null && foundIndex !== -1
204-
? `Target found at index ${foundIndex}!`
205-
: foundIndex === -1
206-
? "Target not found."
207-
: "Ready to search again"}
166+
? `Target found at index ${foundIndex}!`
167+
: foundIndex === -1
168+
? "Target not found."
169+
: "Ready to search again"}
208170
</span>
209171
</div>
210172
</div>

src/components/Templates/SortingTemp.tsx

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import React, { useState, useEffect } from "react";
22
import Link from "next/link";
33
import { Button } from "../ui/button";
4-
import { sortingAlgorithms } from "@/lib/data";
4+
import {
5+
accentColors,
6+
primaryColors,
7+
secondaryColors,
8+
sortingAlgorithms,
9+
} from "@/lib/data";
510

611
function SortingAnimation() {
712
const [isAnimating, setIsAnimating] = useState(false);
@@ -10,7 +15,7 @@ function SortingAnimation() {
1015
const generateRandomArray = () => {
1116
return Array.from(
1217
{ length: 12 },
13-
() => Math.floor(Math.random() * 80) + 10
18+
() => Math.floor(Math.random() * 80) + 10,
1419
);
1520
};
1621

@@ -56,48 +61,6 @@ function SortingAnimation() {
5661
};
5762

5863
const getBarColor = (value: number, index: number) => {
59-
// const theme = document.documentElement.getAttribute("data-theme");
60-
61-
const primaryColors = [
62-
// "--primary-50",
63-
// "--primary-100",
64-
"--primary-200",
65-
"--primary-300",
66-
"--primary-400",
67-
"--primary-500",
68-
"--primary-600",
69-
"--primary-700",
70-
"--primary-800",
71-
"--primary-900",
72-
"--primary-950",
73-
];
74-
const secondaryColors = [
75-
// "--secondary-50",
76-
// "--secondary-100",
77-
"--secondary-200",
78-
"--secondary-300",
79-
"--secondary-400",
80-
"--secondary-500",
81-
"--secondary-600",
82-
"--secondary-700",
83-
"--secondary-800",
84-
"--secondary-900",
85-
"--secondary-950",
86-
];
87-
const accentColors = [
88-
// "--accent-50",
89-
// "--accent-100",
90-
"--accent-200",
91-
"--accent-300",
92-
"--accent-400",
93-
"--accent-500",
94-
"--accent-600",
95-
"--accent-700",
96-
"--accent-800",
97-
"--accent-900",
98-
"--accent-950",
99-
];
100-
10164
let colorSet = primaryColors;
10265

10366
if (index % 3 === 1) colorSet = secondaryColors;

0 commit comments

Comments
 (0)