Skip to content

Commit

Permalink
Merge pull request #206 from supr1yo/BackgroundColorChanger
Browse files Browse the repository at this point in the history
[KWoC] Feature: Display color code
  • Loading branch information
shrey141102 committed Jan 5, 2024
2 parents 2fa3147 + 0d47193 commit 15900c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
12 changes: 8 additions & 4 deletions BackgroundColorChanger/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# BackgroundColorChanger
<div style="text-align:center">
<img src='./Screenshot.png' width='500px'>

</div>
<br>
This application is a very simple implementation of javascript. We can change the background colors using this.

# Features
## Features

Change the background color of the webpage by selecting a color from a predefined list.

# Installation
## Installation

No need for any installation just open the html application in your browser.

# Getting started
## Getting started

1. Download index.html, style.css and script.js.
2. Open the "index.html" file in your web browser.
3. Start changing colors from the given palette.

# Usage
## Usage
You will see this option for changing the background color:

Color Options: Click on the color swatches to change the background color to the selected color.
Expand Down
Binary file added BackgroundColorChanger/Screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions BackgroundColorChanger/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<body>
<h1>Background Color Changer</h1>
<p id="hexcode"></p>
<div id="colorbox"></div>

<script src="script.js"></script>
Expand Down
5 changes: 5 additions & 0 deletions BackgroundColorChanger/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ function bgchange(color) {
var colorarray = ["#e58e26", "#f9b4ab", "#B1FB17", "#78e08f", "#fd79a8"];
var colorbox = document.getElementById("colorbox");

let hexcode = document.getElementById('hexcode');

colorarray.forEach(function (color, index) {
let span = document.createElement("span");
span.style.backgroundColor = color;
span.addEventListener("click", function () {
bgchange(index);

// Display the color code
hexcode.innerHTML = colorarray[index].toUpperCase();
});
colorbox.appendChild(span);
});
8 changes: 7 additions & 1 deletion BackgroundColorChanger/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ body {

h1 {
color: #6203e0;
margin-bottom: 2rem;
margin-bottom: 1rem;
}

p {
font-family: monospace;
padding: 5px;
font-size: large;
}

#colorbox {
Expand Down

0 comments on commit 15900c9

Please sign in to comment.