Skip to content

Commit f6cbd77

Browse files
committed
Fixed all errors
1 parent 2b72b60 commit f6cbd77

12 files changed

Lines changed: 850 additions & 29 deletions

File tree

docs/02-shadowing.mdx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ description: "Learn how variable shadowing works in JavaScript, the difference b
55
keywords: [javascript shadowing, lexical scope, illegal shadowing, var vs let, javascript tutorial]
66
---
77

8-
<!--
98
import JSEditor from "@site/src/components/js-live-code-editor";
10-
-->
11-
129
import firstExample from "!!raw-loader!./_scripts/02-shadow-01.js";
1310
import secondExample from "!!raw-loader!./_scripts/02-shadow-02.js";
1411
import thirdExample from "!!raw-loader!./_scripts/02-shadow-03.js";
@@ -21,11 +18,9 @@ When this happens, the inner variable "shadows" the outer one, making the outer
2118

2219
In the example below, notice how the `city` inside the function is independent of the `city` defined at the top level.
2320

24-
<!--
2521
<JSEditor title="Example: Lexical Shadowing" run={false}>
2622
{firstExample}
2723
</JSEditor>
28-
-->
2924

3025
> **What's happening?** > The `city` parameter on **Line 3** shadows the `city` variable on **Line 1**. Any changes made to `city` inside the function (Line 4) stay inside the function's "bubble."
3126
@@ -37,23 +32,19 @@ While shadowing is a common pattern, JavaScript has strict rules about how diffe
3732

3833
You cannot shadow a `let` or `const` variable using `var` within the same block or a nested block. This is because `var` is function-scoped and tries to "hoist" itself to the top, which conflicts with the block-scoped `let`.
3934

40-
<!--
4135
<JSEditor title="Error: Illegal Shadowing Attempt">
4236
{secondExample}
4337
</JSEditor>
44-
-->
4538

4639
*The `var` at line 4 is trying to **'cross the boundary'** of the `let` declaration, which results in a SyntaxError.*
4740

4841
### 2. Valid Shadowing (Function Boundaries)
4942

5043
Shadowing becomes valid again if there is a **function boundary** separating the declarations. Since functions create a completely new execution context, the conflict is resolved.
5144

52-
<!--
5345
<JSEditor title="Valid: Shadowing via Function Boundary">
5446
{thirdExample}
5547
</JSEditor>
56-
-->
5748

5849
## Best Practices
5950

docs/03-varible-declaration.mdx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ description: "A deep dive into JavaScript variable scopes (Global, Function, Blo
55
keywords: [javascript variables, hoisting, var let const differences, functional scope, block scope, js execution context]
66
---
77

8-
<!--
98
import JSEditor from "@site/src/components/js-live-code-editor";
10-
-->
119
import firstExample from "!!raw-loader!./_scripts/03-variable-declaration-01.js";
1210
import secondExample from "!!raw-loader!./_scripts/03-variable-declaration-02.js";
1311
import thirdExample from "!!raw-loader!./_scripts/03-variable-declaration-03.js";
@@ -25,21 +23,18 @@ Before ES6, `var` was the only way to declare variables. It behaves differently
2523
* **Global Scope:** When declared outside a function, it attaches to the `window` object (in browsers).
2624
* **Function Scope:** When declared inside a `function`, it is trapped there and cannot be accessed from outside.
2725

28-
<!--
2926
<JSEditor title="Visualizing Function Scope" url="scopes">
3027
{firstExample}
3128
</JSEditor>
32-
-->
3329

3430
### Re-declaration & Updates
3531

3632
One of the "quirks" of `var` is that it allows you to re-declare the same variable name without an error. In large codebases, this often leads to accidental bugs.
3733

38-
<!--
34+
3935
<JSEditor title="The 'Silent' Re-declaration">
4036
{secondExample}
4137
</JSEditor>
42-
-->
4338

4439
:::tip Technical Insight
4540
A repeated `var` declaration in the same scope is effectively a **do-nothing operation**. The JS engine sees the first one and ignores subsequent declarations of the same name.
@@ -69,11 +64,9 @@ age = 25; // 3. Assignment happens here
6964

7065
Functions are the "VIPs" of hoisting. They are moved to the top **before** variable declarations.
7166

72-
<!--
7367
<JSEditor title="Challenge: Function vs. Var Hoisting">
7468
{fourthExample}
7569
</JSEditor>
76-
-->
7770

7871
## 3. The Modern Way: `let` & `const`
7972

@@ -90,11 +83,9 @@ While `var` is function-scoped, `let` and `const` are **block-scoped** `{ }`. Th
9083

9184
Test your understanding of the execution context with these common interview scenarios.
9285

93-
<!--
9486
<JSEditor title="Puzzle: The Hoisting Order">
9587
{fifthExample}
9688
</JSEditor>
97-
-->
9889

9990
:::info Deep Dive
10091
For a deeper understanding of these mechanics, I highly recommend checking out:

docusaurus.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const config: Config = {
1010
favicon: "img/js.svg",
1111

1212
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
13-
future: {
14-
v4: true, // Improve compatibility with the upcoming Docusaurus v4
15-
},
13+
// future: {
14+
// v4: true, // Improve compatibility with the upcoming Docusaurus v4
15+
// },
1616

1717
// Set the production url of your site here
1818
url: "https://javascript-mastery.github.io",

src/components/Projects.tsx

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import { useState } from 'react';
2+
import { motion } from 'framer-motion';
3+
import { ExternalLink, CheckCircle2 } from 'lucide-react';
4+
import { projects } from '../data/projectsData';
5+
// import { useProgress } from '../contexts/ProgressContext';
6+
import { cn } from '../lib/utils';
7+
import { Difficulty } from '../types';
8+
9+
const difficultyColors: Record<Difficulty, string> = {
10+
Easy: 'bg-green-500/20 text-green-500 border-green-500/30',
11+
Medium: 'bg-blue-500/20 text-blue-500 border-blue-500/30',
12+
Hard: 'bg-purple-500/20 text-purple-500 border-purple-500/30',
13+
};
14+
15+
export function Projects() {
16+
const [filter, setFilter] = useState<Difficulty | 'All'>('All');
17+
// const { progress, toggleProject } = useProgress();
18+
19+
const filteredProjects = filter === 'All'
20+
? projects
21+
: projects.filter((p) => p.difficulty === filter);
22+
23+
// const completedCount = projects.filter((p) =>
24+
// progress.completedProjects.includes(p.id)
25+
// ).length;
26+
27+
return (
28+
<div className="min-h-screen py-16">
29+
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
30+
<motion.div
31+
initial={{ opacity: 0, y: 20 }}
32+
animate={{ opacity: 1, y: 0 }}
33+
transition={{ duration: 0.6 }}
34+
className="text-center mb-12"
35+
>
36+
<h1 className="text-5xl md:text-6xl font-bold mb-4">
37+
Project <span className="text-gradient">Hub</span>
38+
</h1>
39+
<p className="text-xl text-[var(--text-secondary)] max-w-3xl mx-auto mb-8">
40+
Practice your skills with real-world projects. Each project is designed to
41+
reinforce what you've learned.
42+
</p>
43+
44+
<div className="inline-flex items-center gap-3 px-6 py-3 bg-[var(--bg-surface)] rounded-lg border border-white/10">
45+
<CheckCircle2 className="w-5 h-5 text-[var(--accent)]" />
46+
<span className="font-medium">
47+
{/* {completedCount} of {projects.length} Projects Completed */}
48+
</span>
49+
</div>
50+
</motion.div>
51+
52+
<motion.div
53+
initial={{ opacity: 0, y: 20 }}
54+
animate={{ opacity: 1, y: 0 }}
55+
transition={{ duration: 0.6, delay: 0.1 }}
56+
className="flex flex-wrap justify-center gap-3 mb-12"
57+
>
58+
{(['All', 'Easy', 'Medium', 'Hard'] as const).map((level) => (
59+
<button
60+
key={level}
61+
onClick={() => setFilter(level)}
62+
className={cn(
63+
'px-6 py-3 rounded-lg font-medium transition-all',
64+
filter === level
65+
? 'bg-[var(--accent)] text-black'
66+
: 'bg-[var(--bg-surface)] border border-white/10 hover:border-white/20'
67+
)}
68+
>
69+
{level}
70+
</button>
71+
))}
72+
</motion.div>
73+
74+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
75+
{filteredProjects.map((project, index) => {
76+
// const isCompleted = progress.completedProjects.includes(project.id);
77+
78+
return (
79+
<motion.div
80+
key={project.id}
81+
initial={{ opacity: 0, y: 20 }}
82+
animate={{ opacity: 1, y: 0 }}
83+
transition={{ duration: 0.4, delay: index * 0.05 }}
84+
whileHover={{ y: -8 }}
85+
// className={cn(
86+
// 'group relative p-6 rounded-2xl border transition-all',
87+
// isCompleted
88+
// // ? 'bg-[var(--accent)]/5 border-[var(--accent)]/30'
89+
// : 'bg-[var(--bg-surface)] border-white/10 hover:border-white/20'
90+
// )}
91+
className='group relative p-6 rounded-2xl border transition-all'
92+
93+
>
94+
<div className="flex items-start justify-between mb-4">
95+
<span
96+
className={cn(
97+
'px-3 py-1 rounded-full text-xs font-semibold border',
98+
difficultyColors[project.difficulty]
99+
)}
100+
>
101+
{project.difficulty}
102+
</span>
103+
104+
<button
105+
onClick={() => toggleProject(project.id)}
106+
className="transition-transform hover:scale-110"
107+
// aria-label={`Mark ${project.title} as ${isCompleted ? 'incomplete' : 'complete'}`}
108+
aria-label={`Mark ${project.title} as 'Comming Soon...'`}
109+
>
110+
<CheckCircle2
111+
// className={cn(
112+
// 'w-6 h-6 transition-colors',
113+
// isCompleted
114+
// // ? 'text-[var(--accent)] fill-[var(--accent)]'
115+
// : 'text-[var(--text-secondary)]'
116+
// )}
117+
className='w-6 h-6 transition-colors'
118+
/>
119+
</button>
120+
</div>
121+
122+
<h3 className="text-xl font-bold mb-2 group-hover:text-[var(--accent)] transition-colors">
123+
{project.title}
124+
</h3>
125+
126+
<p className="text-[var(--text-secondary)] text-sm mb-4 leading-relaxed">
127+
{project.description}
128+
</p>
129+
130+
<div className="flex flex-wrap gap-2 mb-4">
131+
{project.tags.map((tag) => (
132+
<span
133+
key={tag}
134+
className="px-2 py-1 rounded bg-white/5 text-xs text-[var(--text-secondary)]"
135+
>
136+
{tag}
137+
</span>
138+
))}
139+
</div>
140+
141+
<a
142+
href={project.repoUrl}
143+
target="_blank"
144+
rel="noopener noreferrer"
145+
className="inline-flex items-center gap-2 text-[var(--accent)] font-medium hover:gap-3 transition-all"
146+
>
147+
View Repository
148+
<ExternalLink className="w-4 h-4" />
149+
</a>
150+
</motion.div>
151+
);
152+
})}
153+
</div>
154+
155+
{filteredProjects.length === 0 && (
156+
<motion.div
157+
initial={{ opacity: 0 }}
158+
animate={{ opacity: 1 }}
159+
className="text-center py-20"
160+
>
161+
<p className="text-[var(--text-secondary)] text-lg">
162+
No projects found for this difficulty level.
163+
</p>
164+
</motion.div>
165+
)}
166+
</div>
167+
</div>
168+
);
169+
}

0 commit comments

Comments
 (0)