Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color Me Javascript Challenge #479

Merged
merged 5 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions apps/javascript/src/challenges/color-me/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="styles.css" />
<script src="../../helpers/header.js" type="module"></script>
<script src="index.js" type="module"></script>
</head>
<body>
<div class="container">
<h1>3x3 Grid Color Me</h1>

<div class="grid-container" id="grid"></div>

<form class="button-container" id="colorForm">
<input type="number" id="inputBox" min="1" max="9" placeholder="Enter" required />
<button type="submit" id="colorButton">Color Me</button>
</form>
</div>
</body>
</html>
24 changes: 24 additions & 0 deletions apps/javascript/src/challenges/color-me/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const gridContainer = document.getElementById('grid');
const inputBox = document.getElementById('inputBox');
for (let i = 1; i <= 9; i++) {
const button = document.createElement('div');
button.className = 'grid-item';
button.textContent = i;
button.dataset.value = i;
gridContainer.appendChild(button);
}

document.getElementById('colorForm').addEventListener('submit', (event) => {
event.preventDefault();

const inputValue = parseInt(inputBox.value, 10);
document.querySelectorAll('.grid-item').forEach((button) => {
if (parseInt(button.dataset.value, 10) === inputValue) {
button.classList.add('active');
} else {
button.classList.remove('active');
}
});

inputBox.value = '';
});
76 changes: 76 additions & 0 deletions apps/javascript/src/challenges/color-me/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
.container {
text-align: center;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
width: 360px;
}

h1 {
margin-bottom: 20px;
color: #333;
}

.grid-container {
display: grid;
grid-template-columns: repeat(3, 100px);
grid-gap: 10px;
justify-content: center;
margin-bottom: 20px;
}

.grid-item {
width: 100px;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #ddd;
border-radius: 50%;
font-size: 24px;
cursor: pointer;
background-color: #f0f0f0;
transition:
background-color 0.3s ease,
transform 0.2s ease;
}

.grid-item:hover {
background-color: #e0e0e0;
transform: scale(1.1);
}

.button-container {
display: flex;
justify-content: center;
gap: 10px;
}

#inputBox {
padding: 10px;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 4px;
width: 80px;
}

#colorButton {
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
}

#colorButton:hover {
background-color: #0056b3;
}

.active {
background-color: green;
color: white;
}
4 changes: 4 additions & 0 deletions shared/data/content/contributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export const contributors = new Map<string, IContributor>([
'DeePaK-HeeRaKaRi',
{ name: 'Deepak Heerakari', pic: 'https://avatars.githubusercontent.com/u/63955160' },
],
[
'X0rD3v1L',
{ name: 'Benarjee Sambangi', pic: 'https://avatars.githubusercontent.com/u/46685302' },
],
[
'sadanandpai',
{ name: 'Sadanand Pai', pic: 'https://avatars.githubusercontent.com/u/12962887' },
Expand Down
10 changes: 10 additions & 0 deletions shared/data/content/js-challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ const challenges: Map<string, IChallenge> = new Map([
tags: [ETag.interview],
},
],
[
'color-me',
{
title: 'Color Me',
link: 'color-me/',
difficulty: EDifficulty.Easy,
developer: 'X0rD3v1L',
tags: [ETag.interview],
},
],
[
'bmi-calculator',
{
Expand Down