Skip to content

End result from practical week 3 #136

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
83 changes: 70 additions & 13 deletions dom_manipulation/button.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,73 @@
<!DOCTYPE html>
<html>
<head><title>JavaScript Button Example</title></head>

<body>
<button id='squeeze'>Squeeze me</button>

<script>
let button = document.getElementById("squeeze");
function shout(){
alert("... and I squeak");
}
button.addEventListener("click", shout);
</script>
</body>
<head>
<title>JavaScript Button Example</title>
</head>

<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
background: rgb(242, 227, 255);
background: linear-gradient(139deg, rgba(242, 227, 255, 1) 25%, rgba(148, 147, 253, 1) 66%, rgba(69, 196, 252, 1) 100%);

width: 100vw;
height: 100vh;

display: grid;
place-items: center;
}

button {
width: 500px;
height: 600px;

background-color: rgb(16, 159, 255);
color: white;

outline: none;
border: 2px solid rgb(188, 188, 220);
border-radius: 50px;

cursor: pointer;

font-size: 60px;

transition: 0.5s ease;
}

button:hover {
width: 50%;
}

.squished {
font-size: x-small;
width: 10% !important;
height: 10% !important;
}
</style>

<body>
<button id="squeeze">Squeeze me</button>

<script>
let button = document.getElementById("squeeze");

function squeeze() {
if (!button.classList.contains("squished")) {
button.classList.add("squished");
button.textContent = "Help Me!!";
} else {
button.classList.remove("squished");
button.textContent = "Squeeze Me";
}
}

button.addEventListener("click", squeeze);
</script>
</body>
</html>
Binary file added html_css/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions html_css/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const input = document.getElementById("input-box");
const shoppingList = document.getElementById("ul");
const shoppingListButton = document.getElementById("but1");
const recipe = document.getElementById("ol");
const recipeButton = document.getElementById("but2");

shoppingListButton.addEventListener("click", function () {
if (!input.value == "") {
let li = document.createElement("li");
let text = document.createTextNode(input.value);

li.appendChild(text);
li.classList.add("list-item");
shoppingList.appendChild(li);

input.value = "";

eventListners();
}
});

recipeButton.addEventListener("click", function () {
if (!input.value == "") {
const li = document.createElement("li");
const text = document.createTextNode(input.value);

li.appendChild(text);
li.classList.add("list-item");
recipe.appendChild(li);

input.value = "";

eventListners();
}
});

function eventListners() {
listItems = document.querySelectorAll(".list-item");
listItems.forEach((e) => {
e.addEventListener("click", function () {
e.remove();
});
});
}
224 changes: 224 additions & 0 deletions html_css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
/* Variable Declaration */
:root {
--body-height: 75vh;
--body-width: 80vw;
}

/* General Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
background-color: rgba(0, 0, 0, 0.15);
width: 100vw;
height: auto;
display: flex;
flex-direction: column;
align-items: center;
}

/* Header Styles */

header {
display: grid;
place-items: center;
width: 100%;
height: calc(100vh - 10vh - var(--body-height));
color: white;
font-family: "Ubuntu", sans-serif;
font-size: 2.5rem;
}

#title {
animation: 1s ease-out 0s 1 fade-in;
}

@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

/* Input Box Styling */

.insert-new-item {
width: 100vw;
height: 10vh;
display: flex;
justify-content: center;
align-items: center;
}

form {
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}

input {
padding-left: 20px;
padding-right: 20px;
font-family: "Roboto", sans-serif;
font-size: 1.15rem;
color: rgb(49, 49, 49);
width: 35vw;
height: 60px;
background-color: rgba(75, 88, 95, 0.6);
border: 3px solid rgb(98, 98, 98);
border-radius: 50px;
transition: 0.5s ease;
}

input:focus {
border: 5px solid rgb(98, 98, 98);
background-color: rgba(96, 108, 114, 0.6);
outline: none;
}

.buttons {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
}

button {
font-size: 17px;
color: #3a3a3a;
width: 30%;
outline: 3px solid rgb(98, 98, 98);
border-radius: 10px;
padding: 10px 20px 10px 20px;
background-color: rgba(75, 88, 95, 0.6);
border: none;
transition: 0.5s ease;
}

button:hover {
outline: 5px solid rgb(98, 98, 98);
background-color: rgba(96, 108, 114, 0.6);
}

/* Card Setup Styles */

.cards {
font-family: "Roboto", sans-serif;
width: 80vw;
height: var(--body-height);
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}

@keyframes fade-in-move {
0% {
opacity: 0;
transform: translateX(5%);
}
100% {
opacity: 1;
transform: translateX(0);
}
}

#card1 {
animation: 1s ease-out 0s 1 fade-in-move;
}

#card2 {
animation: 1s ease-out 0.2s 1 fade-in-move;
}

#card3 {
animation: 1s ease-out 0.4s 1 fade-in-move;
}

.card {
padding: 20px;
border-radius: 10px;
outline: 2px solid rgba(71, 71, 71, 0.45);
height: 60vh;
background-color: rgba(75, 88, 95, 0.6);
width: calc(var(--body-width) / 3 - 2.5vw);
transition: 0.5s ease;
}

.card:hover {
outline: 4px solid rgba(71, 71, 71, 0.45);
}

.heading {
font-size: 2rem;
color: white;
padding-bottom: 5%;
}

p {
padding-bottom: 5%;
}

ul,
ol,
dl,
p {
color: rgb(193, 193, 193);
font-size: 1.1rem;
}

li,
p {
line-height: 1.5;
}

li,
.item {
transition: 0.2s;
}

li:hover,
.item:hover {
color: white;
cursor: default;
}

/* Description list styles */

dd,
dt {
line-height: 1.5;
}

dt {
font-weight: bold;
}

/* Media Queries for Smaller devices */
@media (max-width: 1050px) {
button {
width: 45%;
}
input {
width: 60vw;
}
main {
padding-top: 5vh;
}
.cards {
width: 80vw;
height: auto;
flex-direction: column !important;
}
.card {
margin-top: 3vh;
width: 100%;
height: auto;
}
}
Loading