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

ColorChanger project #1140

Merged
merged 2 commits into from
Jun 11, 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
39 changes: 39 additions & 0 deletions ColorChanger-MiniApp/kiselova/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Generator</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="random-element">
<h1>Color Changer</h1>
<h2>CLICK ANY ONE OF THESE ELEMENTS</h2>
<div class="color-pallets-div">
<div class="pallet" data-color="red"></div>
<div class="pallet" data-color="green"></div>
<div class="pallet" data-color="purple"></div>
<div class="pallet" data-color="blue"></div>
</div>
</div>

<div class="container">
<div class="wrapper">
R<input type="range" min="0" max="255" value="0" id="red" oninput="colors()">
</div>
<div class="wrapper">
G<input type="range" min="0" max="255" value="0" id="green" oninput="colors()">
</div>
<div class="wrapper">
B<input type="range" min="0" max="255" value="0" id="blue" oninput="colors()">
</div>
<span id="output">rgb(0, 0, 0)</span>

<script src="script.js"></script>

</body>

</html>
19 changes: 19 additions & 0 deletions ColorChanger-MiniApp/kiselova/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function colors() {
var red = document.getElementById("red").value;
var green = document.getElementById("green").value;
var blue = document.getElementById("blue").value;
document.body.style.backgroundColor =
"rgb(" + red + "," + green + "," + blue + ")";
document.getElementById("output").innerHTML =
"rgb(" + red + "," + green + "," + blue + ")";
}

function myFunction() {
document.getElementById("myDIV").style.backgroundColor = "lightblue";
}

document.querySelectorAll(".pallet").forEach((pallet) => {
pallet.addEventListener("click", () => {
document.body.style.backgroundColor = pallet.getAttribute("data-color");
});
});
105 changes: 105 additions & 0 deletions ColorChanger-MiniApp/kiselova/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
*,
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: #142b37;
}

.random-element {
width: 60%;
border: 4px solid black;
margin: 2em auto;
padding: 1em;
border-radius: 10px;
background-color: white;
}

h1 {
font-size: 100px;
margin-bottom: 0.2em;
}

h1,
h2 {
text-align: center;
}

h2 {
font-weight: 500;
}

.color-pallets-div {
display: flex;
align-items: center;
gap: 1em;
justify-content: center;
margin-top: 1.5em;
}

.pallet {
cursor: pointer;
width: 55px;
height: 55px;
border-radius: 7px;
background-color: blue;
}

[data-color="red"] {
background-color: red;
}

[data-color="green"] {
background-color: green;
}

[data-color="purple"] {
background-color: purple;
}

.container {
background-color: #ffffff;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
width: 60%;
padding: 20px 0;
box-shadow: 20px 20px 30px rgba(0, 0, 0, 0.2);
font-family: "Work Sans", sans-serif;
font-size: 20px;
font-weight: 500;
color: #142b37;
border-radius: 5px;
display: grid;
justify-items: center;
margin-top: 6em;
}

.wrapper {
width: 100%;
text-align: center;
}

input[type="range"] {
display: inline-block;
width: 80%;
margin-left: 10px;
margin-top: 25px;
}

span {
display: inline-block;
text-align: center;
margin: 20px 0;
background-color: #0075ff;
color: #ffffff;
padding: 10px 30px;
font-size: 18px;
letter-spacing: 0.5px;
border-radius: 2px;
}
Loading