Skip to content

Commit ed80c98

Browse files
committed
Fix : Naming Error
1 parent cd7d470 commit ed80c98

File tree

7 files changed

+84
-48
lines changed

7 files changed

+84
-48
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ A beautiful, interactive color palette generator that creates stunning color com
2727
- **Tablet Ready**: Responsive design for all screen sizes
2828
- **Fast Loading**: Lightweight and optimized for performance
2929

30-
## 🚀 Live Demo
31-
32-
[View Live Demo](https://your-demo-link-here.com) *(Add your deployed link here)*
33-
3430
## 📁 Project Structure
3531

3632
```
37-
29-Color-Pallete-Generator/
33+
29-Color-palette-Generator/
3834
├── index.html # Main HTML structure
3935
├── style.css # Styling and responsive design
4036
├── script.js # JavaScript functionality
@@ -64,7 +60,7 @@ To understand and work with this project, you should have:
6460
### 1. Clone the Repository
6561
```bash
6662
git clone https://github.com/ashishgit10/25-Javascript-Projects-for-beginner.git
67-
cd 25-Javascript-Projects-for-beginner/29-Color-Pallete-Generator
63+
cd 25-Javascript-Projects-for-beginner/29-Color-palette-Generator
6864
```
6965

7066
### 2. Run the Application
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const generateBtn = document.getElementById("generate-btn");
2+
const colorBoxes = [
3+
document.getElementById("color1"),
4+
document.getElementById("color2"),
5+
document.getElementById("color3"),
6+
document.getElementById("color4"),
7+
];
8+
9+
// Function to generate a random hex color
10+
function getRandomColor() {
11+
const letters = '0123456789ABCDEF';
12+
let color = '#';
13+
for (let i = 0; i < 6; i++) {
14+
color += letters[Math.floor(Math.random() * 16)];
15+
}
16+
return color;
17+
}
18+
19+
// Generate a palette and update the UI
20+
function generatePalette() {
21+
colorBoxes.forEach(box => {
22+
const color = getRandomColor();
23+
box.style.background = color;
24+
box.textContent = color;
25+
});
26+
27+
// Optional: Change background gradient dynamically
28+
document.body.style.background = `linear-gradient(135deg, ${getRandomColor()}, ${getRandomColor()})`;
29+
}
30+
31+
// Event listener
32+
generateBtn.addEventListener("click", generatePalette);
33+
34+
// Copy color on click
35+
colorBoxes.forEach(box => {
36+
box.addEventListener("click", () => {
37+
if (navigator.clipboard && navigator.clipboard.writeText) {
38+
navigator.clipboard.writeText(box.textContent)
39+
.then(() => {
40+
alert(`Copied ${box.textContent} to clipboard!`);
41+
})
42+
.catch((err) => {
43+
// Fallback to execCommand if available
44+
fallbackCopyTextToClipboard(box.textContent);
45+
});
46+
} else {
47+
// Fallback for unsupported browsers
48+
fallbackCopyTextToClipboard(box.textContent);
49+
}
50+
});
51+
});
52+
// Fallback function for copying text
53+
function fallbackCopyTextToClipboard(text) {
54+
const textArea = document.createElement("textarea");
55+
textArea.value = text;
56+
// Avoid scrolling to bottom
57+
textArea.style.position = "fixed";
58+
textArea.style.top = "0";
59+
textArea.style.left = "0";
60+
textArea.style.width = "2em";
61+
textArea.style.height = "2em";
62+
textArea.style.padding = "0";
63+
textArea.style.border = "none";
64+
textArea.style.outline = "none";
65+
textArea.style.boxShadow = "none";
66+
textArea.style.background = "transparent";
67+
document.body.appendChild(textArea);
68+
textArea.select();
69+
try {
70+
const successful = document.execCommand('copy');
71+
if (successful) {
72+
alert(`Copied ${text} to clipboard!`);
73+
} else {
74+
alert('Failed to copy to clipboard.');
75+
}
76+
} catch (err) {
77+
alert('Failed to copy to clipboard.');
78+
}
79+
document.body.removeChild(textArea);
80+
}

29-Color-Pallete-Generator/script.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ This project is a simple web-based E-commerce Website. The HTML file sets up th
288288

289289
<hr>
290290

291-
### 29. Color Pallete Generator
291+
### 29. Color palette Generator
292292

293293
A beautiful, interactive color palette generator that creates stunning color combinations with a single click. Built with vanilla HTML, CSS, and JavaScript, this tool helps designers, developers, and artists discover harmonious color schemes for their creative projects.
294294

295295

296-
[Live Preview](https://zpratikpathak.github.io/25-Javascript-Projects-for-beginner/29-Color-Pallete-Generator) | [Source Code](https://github.com/zpratikpathak/25-Javascript-Projects-for-beginner)
296+
[Live Preview](https://zpratikpathak.github.io/25-Javascript-Projects-for-beginner/29-Color-palette-Generator) | [Source Code](https://github.com/zpratikpathak/25-Javascript-Projects-for-beginner)
297297

298298
Want to add your Javascript Project? Feel free to contribute, open a Pull Request [Contribute](https://github.com/zpratikpathak/25-Javascript-Projects-for-beginner)
299299

0 commit comments

Comments
 (0)