This is a submission for the DevCycle Feature Flag Challenge: Feature Flag Funhouse
What I Built
π¨ Background Color Changer π¨
The Background Color Changer is a simple and interactive project that allows users to change the background color of a web page by clicking on color boxes. With this functionality, users can easily personalize the look of a page, making it more engaging and visually appealing.
Demo
You can see a preview of the Background Color Changer in action below:
Hereβs how it works:
The web page displays a selection of color boxes.
Click on any box, and the background color will instantly change to match the selected box.
My Code
π The project has a simple file structure:
index.html: Defines the structure of the web page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta" content=
"width=device-width, initial-scale=1.0">
<title>Background changer using JavaScript</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Background Changer</h1>
<div id="colorbox"></div>
<script src="script.js"></script>
</body>
</html>
style.css: Adds style to the web page and enhances its visual appeal.
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
h1 {
color: #6203e0;
margin-bottom: 2rem;
}
#colorbox {
width: 30%;
display: flex;
align-items: center;
justify-content: space-around;
padding: 1rem;
background-color: #fff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 4px;
}
#colorbox span {
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
cursor: pointer;
}
Script.js: Implements the functionality using JavaScript.
function bgchange(color) {
let colorarray = ["#e58e26", "#f9b4ab", "#B1FB17", "#78e08f", "#fd79a8"];
document.body.style.background = colorarray[color];
}
var colorarray = ["#e58e26", "#f9b4ab", "#B1FB17", "#78e08f", "#fd79a8"];
var colorbox = document.getElementById("colorbox");
colorarray.forEach(function (color, index) {
let span = document.createElement("span");
span.style.backgroundColor = color;
span.addEventListener("click", function () {
bgchange(index);
});
colorbox.appendChild(span);
});
My DevCycle Experience
π This project was built as part of the DevCycle Feature Flag Challenge: Feature Flag Funhouse! I used a straightforward approach with HTML, CSS, and JavaScript to achieve the desired result.
This approach kept the code modular and easy to manage.
Additional Prize Categories
π‘ This project could qualify for additional prize categories such as:
Best Design: The aesthetic appeal of the color boxes and transitions.
Best Beginner-Friendly Project: Simple and easy to understand for anyone learning web development.
Thank you for reading! π I hope this inspires you to try the project and explore how colors can transform web pages. πβ¨
Top comments (0)