Skip to content

Commit

Permalink
feat: add styling
Browse files Browse the repository at this point in the history
  • Loading branch information
khajornritdacha committed Dec 5, 2023
1 parent 6a266ce commit f3aae30
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 18 deletions.
65 changes: 47 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,51 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<title>Group Randomizer</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<form id="file-form">
<input type="file" id="input-file" />
<input type="submit" value="Upload" />
</form>
<section class="container">
<div class="heading-container">
<h2 class="heading">Group Randomizer</h2>
</div>
<label for="input-file" class="drop-container" id="dropcontainer">
<span class="drop-title">Drop files here</span>
or
<input type="file" id="input-file" required />
</label>
<button class="random-btn" id="random-btn">Random Group</button>
</section>
<script>
const dropContainer = document.getElementById("dropcontainer");
const fileInput = document.getElementById("input-file");

dropContainer.addEventListener(
"dragover",
(e) => {
// prevent default to allow drop
e.preventDefault();
},
false
);

dropContainer.addEventListener("dragenter", () => {
dropContainer.classList.add("drag-active");
});

dropContainer.addEventListener("dragleave", () => {
dropContainer.classList.remove("drag-active");
});

dropContainer.addEventListener("drop", (e) => {
e.preventDefault();
dropContainer.classList.remove("drag-active");
fileInput.files = e.dataTransfer.files;
});
</script>
<script type="module">
import * as xlsx from "./xlsx.mjs";

// TODO: add only one sex day
const GROUP = 13;
const DAY = 6;
let member = 0;
Expand Down Expand Up @@ -44,9 +78,7 @@
},
];

async function processForm(e) {
if (e.preventDefault) e.preventDefault();

async function processForm() {
console.log("File uploaded");

const file_form = document.getElementById("input-file");
Expand Down Expand Up @@ -103,7 +135,7 @@
}

/**
*
* Create new xlsx worksheet for group assign
* @param {xlsx.WorkBook} wb
*/
function create_group_assign_sheet(wb) {
Expand Down Expand Up @@ -255,8 +287,6 @@
total_error += error_for_day;
}
const R = Math.sqrt(total_error / 10000);
mx = Math.max(R, mx);
mn = Math.min(R, mn);
return R;
}

Expand Down Expand Up @@ -448,12 +478,11 @@
});
}

const form = document.getElementById("file-form");
if (form.attachEvent) {
form.AttachEvent("submit", processForm);
} else {
form.addEventListener("submit", processForm);
}
const randomBtn = document.getElementById("random-btn");
randomBtn.addEventListener("click", () => {
console.log(fileInput.files[0]);
processForm();
});
</script>
</body>
</html>
143 changes: 143 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&family=Rubik+Bubbles&display=swap");

body {
font-family: "Poppins", sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
}

.container {
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 5%;
width: 100vw;
height: 100vh;
overflow: hidden;
background: rgba(152, 140, 241, 0.5);
}

.heading-container {
font-family: "Rubik Bubbles", sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.heading {
color: #455eb5;
font-size: 4rem;
font-weight: bold;
}

.drop-container {
position: relative;
display: flex;
gap: 10px;
flex-direction: column;
justify-content: center;
align-items: center;
height: 200px;
padding: 20px;
border-radius: 10px;
border: 2px dashed #555;
color: #444;
cursor: pointer;
background-color: #fff;
transition: background 0.2s ease-in-out, border 0.2s ease-in-out;
}

.drop-container:hover,
.drop-container.drag-active {
background: #eee;
border-color: #111;
}

.drop-container:hover .drop-title,
.drop-container.drag-active .drop-title {
color: #222;
}

.drop-title {
color: #444;
font-size: 20px;
font-weight: bold;
text-align: center;
transition: color 0.2s ease-in-out;
}

input[type="file"] {
width: 350px;
max-width: 100%;
color: #444;
padding: 5px;
background: #ffffff;
border-radius: 10px;
font-family: inherit;
border: 1px solid #555;
}

input[type="file"]::file-selector-button {
margin-right: 20px;
border: none;
background: #455eb5;
padding: 10px 20px;
border-radius: 10px;
color: #fff;
cursor: pointer;
font-family: inherit;
transition: background 0.2s ease-in-out;
}

input[type="file"]::file-selector-button:hover {
background: #0d45a5;
}

/* CSS */
.random-btn {
background-image: linear-gradient(
92.88deg,
#455eb5 9.16%,
#5643cc 43.89%,
#673fd7 64.72%
);
border-radius: 8px;
border-style: none;
box-sizing: border-box;
color: #ffffff;
cursor: pointer;
flex-shrink: 0;
font-family: inherit;
font-size: 16px;
font-weight: 500;
height: 4rem;
text-align: center;
text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px;
transition: all 0.5s;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
padding: 0 2.6rem;
}

.random-btn:hover {
box-shadow: rgba(80, 63, 205, 0.5) 0 1px 30px;
transition-duration: 0.1s;
}

.random-btn:active {
transform: scale(0.95);
}

@media (max-width: 768px) {
.heading {
font-size: 1rem;
}
.random-btn {
padding: 0 1.6rem;
}
}

0 comments on commit f3aae30

Please sign in to comment.