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

Demo #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Demo #475

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: 83 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">

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

<body>
<div class="container">
<h1>YAY! It's BOGO</h1>
<!-- 1 Unit Option -->
<div class="option">
<label>
<input type="radio" name="units" value="1" checked>
<span>1 Unit</span>
<span class="discount">10% Off</span>
<span class="price">$10.00 USD</span>
<span class="original-price">$24.00 USD</span>
</label>
</div>

<!-- 2 Unit Option -->
<div class="option most-popular">
<label>
<input type="radio" name="units" value="2">
<span>2 Unit</span>
<span class="discount">20% Off</span>
<span class="price">$18.00 USD</span>
<span class="original-price">$24.00 USD</span>
<div class="size-colour">
<div>
<span>#1</span>
<select>
<option>S</option>
<option>M</option>
<option>L</option>
</select>
<select>
<option>Black</option>
<option>Red</option>
<option>White</option>
</select>
</div>
<div>
<span>#2</span>
<select>
<option>S</option>
<option>M</option>
<option>L</option>
</select>
<select>
<option>Colour</option>
<option>Red</option>
<option>White</option>
</select>
</div>
</div>
</label>
</div>

<!-- 3 Unit Option -->
<div class="option">
<label>
<input type="radio" name="units" value="3">
<span>3 Unit</span>
<span class="discount">30% Off</span>
<span class="price">$24.00 USD</span>
<span class="original-price">$24.00 USD</span>
</label>
</div>

<!-- Footer Section -->
<div class="footer">
<p>Free Delivery</p>
<p>Total: <span id="total-price">$18.00 USD</span></p>
</div>
<button class="add-to-cart">+ Add to Cart</button>
</div>
</body>
</html>
20 changes: 20 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document.addEventListener("DOMContentLoaded", function () {
const radioButtons = document.querySelectorAll('input[name="units"]');
const totalPrice = document.getElementById("total-price");

radioButtons.forEach((radio) => {
radio.addEventListener("change", function () {
switch (radio.value) {
case "1":
totalPrice.textContent = "$10.00 USD";
break;
case "2":
totalPrice.textContent = "$18.00 USD";
break;
case "3":
totalPrice.textContent = "$24.00 USD";
break;
}
});
});
});
130 changes: 130 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
color: #333;
}

.container {
width: 90%;
max-width: 500px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
color: #ff6680;
margin-bottom: 20px;
}

/* Option Styles */
.option {
border: 1px solid #ddd;
padding: 15px;
margin-bottom: 10px;
border-radius: 8px;
position: relative;
}

.option label {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
}

.option input[type="radio"] {
margin-right: 10px;
}

.discount {
background-color: #ff6680;
color: white;
padding: 2px 6px;
font-size: 12px;
border-radius: 5px;
}

.price {
font-weight: bold;
color: #333;
}

.original-price {
text-decoration: line-through;
color: #aaa;
font-size: 12px;
}

.most-popular {
border: 2px solid #ff6680;
background-color: #fff8fa;
}

.most-popular::before {
content: "MOST POPULAR";
position: absolute;
top: -10px;
left: 10px;
background-color: #ff6680;
color: white;
padding: 2px 8px;
font-size: 10px;
border-radius: 5px;
}

/* Size and Colour Selectors */
.size-colour {
margin-top: 10px;
}

.size-colour div {
display: flex;
align-items: center;
margin-top: 5px;
}

.size-colour span {
margin-right: 10px;
}

select {
margin-right: 10px;
padding: 4px;
font-size: 12px;
}

/* Footer Section */
.footer {
display: flex;
justify-content: space-between;
margin-top: 20px;
font-weight: bold;
color: #ff6680;
}

.add-to-cart {
width: 100%;
padding: 10px;
background-color: #ff6680;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
margin-top: 10px;
}

.add-to-cart:hover {
background-color: #e05570;
}