diff --git a/app/components/SectionsDisplay.jsx b/app/components/SectionsDisplay.jsx index 3c57315..7ef4919 100755 --- a/app/components/SectionsDisplay.jsx +++ b/app/components/SectionsDisplay.jsx @@ -6,7 +6,7 @@ import { useState } from 'react'; const InfoPopup = ({ info }) => { return ( -
+
{Object.entries(info).map(([key, value]) => (
{key}: @@ -28,12 +28,12 @@ const SectionsDisplay = ({ sections, searchQuery }) => { initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.3, delay: sectionIndex * 0.05 }} - className="group relative bg-white dark:bg-gray-900 rounded-2xl shadow-sm border border-gray-200 dark:border-gray-700/50 overflow-hidden transition-all duration-300 hover:shadow-lg hover:border-blue-400/30 dark:hover:border-blue-500/30" + className="group relative bg-white dark:bg-neutral-950 rounded-2xl shadow-sm border border-gray-200 dark:border-gray-700/50 overflow-hidden transition-all duration-300 hover:shadow-lg hover:border-blue-400/30 dark:hover:border-blue-500/30" > {/* Section Header */} -
+
-
+
{section.icon}

{section.title}

@@ -66,7 +66,7 @@ const SectionsDisplay = ({ sections, searchQuery }) => { {/* Hover effect */}
@@ -116,11 +116,11 @@ const SectionsDisplay = ({ sections, searchQuery }) => { transition={{ duration: 0.3 }} className="text-center py-16" > -
- +
+

- No results found for "{searchQuery}" + No results found

Try searching for different terms or browse our categories diff --git a/app/components/ui/SearchBar.jsx b/app/components/ui/SearchBar.jsx index 5f79770..f58484a 100755 --- a/app/components/ui/SearchBar.jsx +++ b/app/components/ui/SearchBar.jsx @@ -1,5 +1,4 @@ - 'use client'; - +'use client'; import { useState, useEffect } from 'react'; const SearchBar = ({ sections, onSearchResults }) => { @@ -51,11 +50,11 @@ const SearchBar = ({ sections, onSearchResults }) => { }; return ( -

+
diff --git a/app/components/ui/TutorialOverlay.jsx b/app/components/ui/TutorialOverlay.jsx index 2079c94..cb3259e 100755 --- a/app/components/ui/TutorialOverlay.jsx +++ b/app/components/ui/TutorialOverlay.jsx @@ -56,7 +56,7 @@ export default function TutorialOverlay() { ref={overlayRef} className="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50" > -
+
- -
- - {/* Playback Controls */} - {steps.length > 0 && ( -
-
- - - -
- -
- Speed: - - -
- Step {currentStep + 1} of {steps.length} -
-
- - {/* Progress bar */} -
-
-
-
- )} +
+

+ Visualize the conversion from infix to prefix notation +

+
+ {/* Input & Controls */} +
+
+ setInfix(e.target.value)} + placeholder="Enter infix expression (e.g., (A+B)*C)" + className="flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-neutral-900 dark:text-white" + /> + +
- {/* Operation Status */} -
-

Conversion Status

- - {operation && ( -
- {operation} + {steps.length > 0 && ( +
+
+ + +
- )} - - {message && ( -
- {message} +
+ Speed: + +
+ Step {currentStep + 1} of {steps.length} +
- )} - - {prefix && currentStep === steps.length - 1 && ( -
-
Prefix Result:
-
{prefix}
+
+
- )} -
+
+ )} +
- {/* Visualizations */} -
- {/* Stack Visualization */} -
-

Stack

-
-
- {stack.length > 0 ? '↑ Top' : ''} -
-
+ {/* Status panel */} +
+

Conversion Status

+ {operation && ( +
+ {operation} +
+ )} + {message && ( +
+ {message} +
+ )} + {prefix && currentStep === steps.length - 1 && ( + +
Prefix Result:
+
{prefix}
+
+ )} +
+ + {/* Visualisations */} +
+ {/* Stack */} +
+

Stack

+
+
{stack.length > 0 ? "↑ Top" : ""}
+
+ {stack.length === 0 ? ( -
- Stack is empty -
+
Stack is empty
) : (
- {stack.map((item, index) => ( -
- {item} - {index === stack.length - 1 && ( -
- (Top) -
- )} -
+ {stack.map((item, i) => ( + ))}
)} -
-
- {stack.length > 0 ? '↓ Bottom' : ''} -
+
+
{stack.length > 0 ? "↓ Bottom" : ""}
+
- {/* Output Visualization */} -
-

Output

-
-
+ {/* Output */} +
+

Output

+
+
+ {output.length === 0 ? ( -
- Output will appear here -
+
Output will appear here
) : ( - output.map((item, index) => ( -
- {item} -
- )) + output.map((c, i) => ) )} -
+
- - {/* Step-by-step Table */} - {steps.length > 0 && ( -
-

Conversion Steps

-
- - - - - - - - - - - {steps.map((step, index) => ( - jumpToStep(index)} - > - - - - - - ))} - -
StepActionCharacterDescription
{index + 1}{step.action}{step.char || '-'}{step.description}
-
-
- )}
- { /* quiz block here */} -

- Test Your Knowledge before moving forward! -

- - - - -
-
- -
-
+ {/* Step table */} + {steps.length > 0 && ( + +

Conversion Steps

+
+ + + + + + + + + + + {steps.map((step, idx) => ( + jumpToStep(idx)} + className={`cursor-pointer ${ + currentStep === idx ? "bg-blue-50 dark:bg-neutral-950" : "hover:bg-gray-50 dark:hover:bg-neutral-950" + }`} + whileHover={{ scale: 1.01 }} + whileTap={{ scale: 0.98 }} + > + + + + + + ))} + +
StepActionCharacterDescription
{idx + 1}{step.action}{step.char || "-"}{step.description}
+
+
+ )} +
+ ); }; diff --git a/app/visualizer/stack/polish/prefix/codeBlock.jsx b/app/visualizer/stack/polish/prefix/codeBlock.jsx index 6d099d9..0c03e46 100755 --- a/app/visualizer/stack/polish/prefix/codeBlock.jsx +++ b/app/visualizer/stack/polish/prefix/codeBlock.jsx @@ -213,10 +213,10 @@ int main() { initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.3 }} - className="bg-white dark:bg-gray-800 rounded-xl shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 transition-colors duration-300" + className="bg-white dark:bg-neutral-950 rounded-xl shadow-lg overflow-hidden border border-gray-200 dark:border-gray-700 transition-colors duration-300" > {/* Header */} -
+

diff --git a/app/visualizer/stack/polish/prefix/content.jsx b/app/visualizer/stack/polish/prefix/content.jsx index 8fc1ace..2635aa1 100755 --- a/app/visualizer/stack/polish/prefix/content.jsx +++ b/app/visualizer/stack/polish/prefix/content.jsx @@ -1,4 +1,28 @@ -const InfixToPrefixContent = () => { +"use client"; +import { useEffect, useState } from "react"; + +const content = () => { + const [theme, setTheme] = useState("light"); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + const updateTheme = () => { + const savedTheme = localStorage.getItem("theme") || "light"; + setTheme(savedTheme); + }; + + updateTheme(); + setMounted(true); + + window.addEventListener("storage", updateTheme); + window.addEventListener("themeChange", updateTheme); + + return () => { + window.removeEventListener("storage", updateTheme); + window.removeEventListener("themeChange", updateTheme); + }; + }, []); + const paragraph = [ `Prefix notation (also called Polish Notation) is a way of writing expressions where the operator comes before the operands.`, `For example, the infix expression 3 + 4 becomes + 3 4 in prefix. It removes the need for parentheses by using operator order directly.`, @@ -20,8 +44,37 @@ const InfixToPrefixContent = () => { ]; return ( -
-
+
+
+
+ {mounted && ( + + )} +
+
+ + Daily DSA Challenge by{" "} + + Hello World + + +
+
+
{/* What is Prefix Notation? */}

@@ -78,62 +131,62 @@ const InfixToPrefixContent = () => { Operator Precedence Table

- +
- - - - - - - - - - - - - - - @@ -145,8 +198,37 @@ const InfixToPrefixContent = () => { + + {/* Mobile iframe at bottom */} +
+ {mounted && ( + + )} +
+ + Daily DSA Challenge by{" "} + + Hello World + + +
+
); }; -export default InfixToPrefixContent; \ No newline at end of file +export default content; \ No newline at end of file diff --git a/app/visualizer/stack/polish/prefix/page.jsx b/app/visualizer/stack/polish/prefix/page.jsx index 67d85d2..9b1d4d6 100755 --- a/app/visualizer/stack/polish/prefix/page.jsx +++ b/app/visualizer/stack/polish/prefix/page.jsx @@ -2,7 +2,14 @@ import Animation from "@/app/visualizer/stack/polish/prefix/animation"; import Navbar from "@/app/components/navbarinner"; import Breadcrumbs from "@/app/components/ui/Breadcrumbs"; import ArticleActions from "@/app/components/ui/ArticleActions"; -import Content from '@/app/visualizer/stack/polish/prefix/content'; +import Content from "@/app/visualizer/stack/polish/prefix/content"; +import Quiz from "@/app/visualizer/stack/polish/postfix/quiz"; +import Code from "@/app/visualizer/stack/polish/prefix/codeBlock"; +import ModuleCard from "@/app/components/ui/ModuleCard"; +import { MODULE_MAPS } from "@/lib/modulesMap"; +import Footer from "@/app/components/footer"; +import ExploreOther from "@/app/components/ui/exploreOther"; +import BackToTopButton from "@/app/components/ui/backtotop"; export const metadata = { title: @@ -31,7 +38,7 @@ export const metadata = { url: "/og/stack/prefix.png", width: 1200, height: 630, - alt: "Stack infix to postfix", + alt: "Stack infix to prefix", }, ], }, @@ -74,7 +81,39 @@ export default function Page() {
+ +
+

+ Test Your Knowledge before moving forward! +

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
); } diff --git a/lib/activity.js b/lib/activity.js index c25c2eb..879442f 100755 --- a/lib/activity.js +++ b/lib/activity.js @@ -16,4 +16,4 @@ const trackActivity = async (userId, type = "site_visit") => { } }; -export default { trackActivity }; \ No newline at end of file +export { trackActivity }; \ No newline at end of file diff --git a/lib/modulesMap.js b/lib/modulesMap.js index 5cfc5eb..b591d82 100755 --- a/lib/modulesMap.js +++ b/lib/modulesMap.js @@ -11,4 +11,5 @@ export const MODULE_MAPS = { isEmpty : "05ecbddd-e3d4-4fa1-aa45-71accac97d79", isFull : "54301ec9-0586-48f0-a6db-18a41adeb856", postfix : "ca3daf8d-23f8-4ade-adfd-4bd0a88d3da2", + prefix : "a2971df4-5e48-4320-bc91-3de3242cac48", } \ No newline at end of file diff --git a/public/og/stack/prefix.png b/public/og/stack/prefix.png new file mode 100755 index 0000000..ac491fc Binary files /dev/null and b/public/og/stack/prefix.png differ
+ Operator + Meaning + Precedence
+ ( ) + Parentheses + Highest
+ ^ % + Exponentiation / Modulus + 2
+ * / + Multiplication / Division + 3
+ + - + Addition / Subtraction + 4 (Lowest)