JSFiddle - React, Tailwind, and code Playground
by subrina
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<script src="https://fonts.googleapis.com/css?family=Playfair+Display:700,900"></script>
<div class="container">
<!--header photo-->
<div class="row">
<div class="col-4 logo">
<img class="img-fluid" src="img/logo.png" alt="">
</div>
<div class="col-8">
<img class="img-fluid" src="img/pic.jpg" alt="">
</div>
</div>
<!--search bar-->
<div class="row justify-content-center">
<div class="col-10 search-bar">
<div class="bar-wrapper">
<input id="input" type="text" placeholder=" invite someone">
<button type="submit" id="submitBtn">submit</button>
</div>
</div>
</div>
<!--invitee-->
<div class="row">
<div class="col-lg-12 invitee">
<h1>Invitée</h1>
<p>
<input type="checkbox">Hind those who haven't responded</p>
</div>
</div>
<!--items-->
<div class="row justify-content-center" id="guestsList">
<!-- <div class="col-5 item">
<h2>Xavier contreras</h2>
<h3>confirmed<input type="checkbox"></h3>
<button class="edit">edit</button>
<button class="remove">remove</button>
</div> -->
</div>
</div>
SCSS
// fonts
$font-family:'Playfair Display', serif;
$letter-spacing-s:0.6px;
//color
$blue:#79ced5;
$darkBlue:#383d43;
$darkGrey:#424242;
$lightGrey:#cccccc;
$grey:#474747;
$red:#ba4243;
$white:#fff;
//color function name
$button:$blue;
$button-hover:darken($blue,20%);
$button-main:$darkGrey;
$text-color:$grey;
$bg-color:$darkBlue;
$padding:5%;
%inputSize{
height:20px;
width:20px;
}
%item{
border:1px solid $blue;
border-top:8px solid $blue;
padding:30px 20px;
max-width: 225px;
margin-bottom: 20px;
margin-right: 20px;
h2,
h3{
font-family: $font-family;
color:$text-color;
letter-spacing: $letter-spacing-s;
font-weight: 700;
text-transform: capitalize;
}
h2{
font-size: 20px;
}
input{
margin-bottom: 10px;
width:100%;
border:1px solid $blue;
}
h3{
font-size: 18px;
margin-bottom: 20px;
color:$blue;
display: flex;
align-items:center;
input{
border:1px solid $lightGrey;
margin-left: $padding;
@extend %inputSize;
}
}
button{
background-color: $blue;
border:none;
outline:none;
border-radius:4px;
padding:10px 20px;
color:white;
margin-bottom: 10px;
&:hover{
cursor: pointer;
background-color: darken($blue,20%);
}
}
.edit,
.save{
margin-right: $padding;
}
}
*{
box-sizing:border-box;
}
body{
font-family: $font-family;
background-color: $bg-color;
}
//font setting
h1,
h2,
h3,
p{
font-family:$font-family;
color:$text-color;
}
h1{
font-weight: 900;
}
h2,
h3,
p{
font-weight: 700;
}
.container{
margin-top: 10%;
padding-bottom:50px;
border-radius:8px;
background-color: $white;
-webkit-box-shadow: 1px 1px 12px 0px rgba(0,0,0,0.8);
-moz-box-shadow: 1px 1px 12px 0px rgba(0,0,0,0.8);
box-shadow: 1px 1px 12px 0px rgba(0,0,0,0.8);
//header images
.row{
.col-8{
padding: 0;
margin:0;
img{
display: block;
width:100%;
border-top-right-radius:8px;
}
...
JavaScript
const input = document.getElementById("input");
const submitBtn = document.getElementById("submitBtn");
const list = document.getElementById("guestsList");
submitBtn.addEventListener("click", () => {
const item = document.createElement("div");
item.className = "col-5";
item.className += " item";
const h2 = document.createElement("h2");
h2.textContent = input.value;
const h3 = document.createElement("h3");
h3.textContent = "comfirmed";
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
item.appendChild(h2);
h3.appendChild(checkbox);
item.appendChild(h3);
const editBtn = document.createElement("button");
editBtn.className = "edit";
editBtn.textContent = "edit";
const removeBtn = document.createElement("button");
removeBtn.className = "remove";
removeBtn.textContent = "remove";
item.appendChild(editBtn);
item.appendChild(removeBtn);
list.appendChild(item);
input.value = "";
})
//check box true and false
list.addEventListener("change", (e) => {
const checkbox = e.target;
const checked = checkbox.checked;
const list = checkbox.parentNode.parentNode;
if (checked) {
list.className = "col-5";
list.className += " item-choose";
} else {
list.className = "col-5";
list.className += " item";
}
})
//remove, edit, save btn function
list.addEventListener("click", (e) => {
let button = e.target;
let item = button.parentNode;
//remove btn
if (button.textContent === "remove") {
list.removeChild(item);
//edit btn
} else if (button.textContent === "edit") {
const input = document.createElement('input');
button.textContent = "save";
let h2 = item.firstElementChild;
item.insertBefore(input, h2);
input.value = h2.textContent;
item.removeChild(h2);
} else if (button.textContent === "save") {
button.textContent = "edit";
const input = item.firstElementChild;
const h2 = document.createElement("h2");
...