feat: add colour scheme

This commit is contained in:
ktyl 2024-07-12 00:39:41 +01:00
parent 3e95c716df
commit b4475813dc
2 changed files with 69 additions and 19 deletions

19
main.js
View File

@ -71,18 +71,22 @@ class SentMessage {
let progressBar = thisMessage.getElementsByClassName("progress")[0]; let progressBar = thisMessage.getElementsByClassName("progress")[0];
if (amount < 0.5) { if (amount < 0.5) {
this.updateStatus("in flight"); const color = "var(--light-red)";
progressBar.style.backgroundColor = "red"; this.updateStatus("in flight", color);
progressBar.style.backgroundColor = color;
amount *= 2; amount *= 2;
} }
else if (amount < 1) { else if (amount < 1) {
this.updateStatus("completing round trip"); const color = "var(--robin-egg-blue)";
progressBar.style.backgroundColor = "blue"; this.updateStatus("completing round trip", color);
progressBar.style.backgroundColor = color;
amount -= 0.5; amount -= 0.5;
amount *= 2; amount *= 2;
} }
else { else {
this.updateStatus("delivered"); const color = "var(--eggshell)";
this.updateStatus("delivered", color);
progressBar.style.backgroundColor = color;
clearInterval(this.updateBarIntervalId); clearInterval(this.updateBarIntervalId);
amount = 0; amount = 0;
this.onDelivered(); this.onDelivered();
@ -92,10 +96,11 @@ class SentMessage {
progressBar.style.width = percentage; progressBar.style.width = percentage;
} }
updateStatus(newStatus) { updateStatus(newStatus, color) {
let thisMessage = getMessageElement(this.idx); let thisMessage = getMessageElement(this.idx);
let statusElement = thisMessage.getElementsByClassName("message-status")[0]; let statusElement = thisMessage.getElementsByClassName("message-status")[0];
statusElement.innerHTML = newStatus; statusElement.innerHTML = newStatus;
statusElement.style.color = color;
} }
} }
@ -135,7 +140,7 @@ function getMessageHtml(text, isOurs) {
let message = `<li><div class="message"> let message = `<li><div class="message">
<span class="message-content rounded-rectangle ${owner}"> <span class="message-content rounded-rectangle ${owner}">
${progressBar} ${progressBar}
${text} <span class="message-text">${text}</span>
</span></div>${statusText}</li>`; </span></div>${statusText}</li>`;
return message; return message;

View File

@ -1,3 +1,11 @@
:root {
--dark-purple: #271f30;
--light-red: #ff686b;
--eggshell: #dfe2cf;
--ucla-blue: #4d7298;
--robin-egg-blue: #66ced6;
}
html { html {
font-family: sans-serif; font-family: sans-serif;
} }
@ -5,6 +13,8 @@ html {
body { body {
margin-left: 0; margin-left: 0;
margin-right: 0; margin-right: 0;
background-color: var(--dark-purple);
} }
#page { #page {
@ -14,19 +24,23 @@ body {
h1 { h1 {
margin-left: 0.5em; margin-left: 0.5em;
display: inline; display: inline;
color: var(--eggshell);
} }
.delay { .delay {
display: inline; display: inline;
color: var(--robin-egg-blue);
} }
.rounded-rectangle { .rounded-rectangle {
border-width: 2px; border-width: 2px;
border: black; border: black;
border-style: solid; border-style: none;
border-radius: 1em; border-radius: 1em;
padding: 7px; padding: .6em .8em;
} }
.message-content { .message-content {
@ -35,16 +49,26 @@ h1 {
} }
.message-content.theirs { .message-content.theirs {
background-color: yellow; background-color: var(--ucla-blue);
left: 0; left: 0;
} }
.theirs .message-text {
color: var(--eggshell);
}
.message-content.ours { .message-content.ours {
background-color: pink; background-color: var(--eggshell);
right: 0; right: 0;
margin-bottom: 0.5em; margin-bottom: 0.5em;
} }
.ours .message-text {
color: var(--dark-purple);
}
ul { ul {
margin: 1em; margin: 1em;
margin-bottom: 4em; margin-bottom: 4em;
@ -72,6 +96,8 @@ li {
} }
#typing-indicator { #typing-indicator {
color: var(--eggshell);
margin: 0; margin: 0;
margin-left: 1em; margin-left: 1em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
@ -81,31 +107,50 @@ li {
} }
#textbox input { #textbox input {
color: var(--dark-purple);
background-color: var(--eggshell);
margin: 0.5em; margin: 0.5em;
left: 1em; left: 1em;
width: 85%; width: 80%;
font-size: 1em; font-size: 1em;
z-index: 1; z-index: 1;
} }
button { button {
background-color: var(--dark-purple);
color: var(--eggshell);
margin: 0.5em; margin: 0.5em;
padding: 0; padding: 0;
width: 10%; width: 15%;
position: absolute; position: absolute;
right: 0; right: 0;
font-size: 1em; font-size: 1em;
} }
button:hover {
color: var(--dark-purple);
background-color: var(--eggshell);
}
@media only screen and (min-width: 768px) {
button {
width: 10%;
}
#textbox input {
width: 85%;
}
}
.progress-bar { .progress-bar {
width: 100%; width: 100%;
height: 100%; height: 100%;
opacity: 80%;
max-width: 400px; max-width: 400px;
background-color: #e0e0e0; border-radius: 1em;
border-radius: 10px;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
@ -115,14 +160,14 @@ button {
} }
.progress { .progress {
opacity: 80%; opacity: 50%;
width: 0; width: 0;
height: 100%; height: 100%;
background-color: #ff5c35;
} }
.message-status { .message-status {
margin-top: 1em; color: var(--robin-egg-blue);
position: absolute; position: absolute;
top: 2.3em; top: 2.3em;
right: 1em; right: 1em;