From 153b7763ea7072aa04dce6090b141c6062777bba Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Tue, 25 Jun 2019 13:39:05 -0500 Subject: [PATCH] SQUAHME: Circleci test 1 --- Untitled-1 | 2 + docker-compose.yml | 2 +- frontend/toast/{toast.tsx => create_toast.ts} | 107 +++--------------- frontend/toast/toast.ts | 54 +++++++++ 4 files changed, 74 insertions(+), 91 deletions(-) create mode 100644 Untitled-1 rename frontend/toast/{toast.tsx => create_toast.ts} (66%) create mode 100644 frontend/toast/toast.ts diff --git a/Untitled-1 b/Untitled-1 new file mode 100644 index 000000000..98aa49635 --- /dev/null +++ b/Untitled-1 @@ -0,0 +1,2 @@ +postgres 10 d29f10c3b706 3 days ago 230MB +postgres 10.9 d29f10c3b706 3 days ago 230MB diff --git a/docker-compose.yml b/docker-compose.yml index 8ed853422..d5c7ddec9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: db: env_file: ".env" - image: postgres:10 + image: postgres:10.9 volumes: ["./docker_volumes/db:/var/lib/postgresql/data"] web: diff --git a/frontend/toast/toast.tsx b/frontend/toast/create_toast.ts similarity index 66% rename from frontend/toast/toast.tsx rename to frontend/toast/create_toast.ts index 57840960f..9a5e34628 100644 --- a/frontend/toast/toast.tsx +++ b/frontend/toast/create_toast.ts @@ -21,15 +21,16 @@ const createToast = (message: string, title: string, color: string) => { throw new Error("toast-container is null."); } else { - /** - * Amount of time before each element is removed. - */ - let timer = 7; - - /** - * Declare if the user's mouse is hovering over the message. - */ - let isHovered = false; + const state = { + /** + * Amount of time before each element is removed. + */ + timer: 7, + /** + * Declare if the user's mouse is hovering over the message. + */ + isHovered: false, + }; /** * Create elements. @@ -85,7 +86,7 @@ const createToast = (message: string, title: string, color: string) => { for (let i = 0; i < children.length; i++) { (children[i] as HTMLElement).style.animationPlayState = "paused"; } - isHovered = true; + state.isHovered = true; }); /** @@ -96,7 +97,7 @@ const createToast = (message: string, title: string, color: string) => { for (let i = 0; i < children.length; i++) { (children[i] as HTMLElement).style.animationPlayState = "running"; } - isHovered = false; + state.isHovered = false; }); /** @@ -114,15 +115,15 @@ const createToast = (message: string, title: string, color: string) => { * Start timer. */ const interval = setInterval(() => { - if (timer <= 7) { + if (state.timer <= 7) { toastEl.classList.add("active"); } - if (!isHovered && timer <= .800) { + if (!state.isHovered && state.timer <= 0.800) { toastEl.classList.add("poof"); } - if (!isHovered) { - timer -= 0.100; - if (timer <= 0) { + if (!state.isHovered) { + state.timer -= 0.100; + if (state.timer <= 0) { clearInterval(interval); if (toastEl && toastEl.parentNode === tc) { if (!tc) { @@ -138,77 +139,3 @@ const createToast = (message: string, title: string, color: string) => { }, 100); } }; - -/** - * Yellow message with "Warning" as the default title. - */ -export const warning = ( - message: string, - title = "Warning", - color = "yellow" -) => { - if (messageQueue.indexOf(message) > -1) { - console.warn(message); - } else { - createToast(message, title, color); - messageQueue.push(message); - } -}; - -/** - * Red message with "Error" as the default title. - */ -export const error = ( - message: string, - title = "Error", - color = "red" -) => { - if (messageQueue.indexOf(message) > -1) { - console.error(message); - } else { - createToast(message, title, color); - messageQueue.push(message); - } -}; - -/** - * Green message with "Success" as the default title. - */ -export const success = ( - message: string, - title = "Success", - color = "green" -) => { - createToast(message, title, color); -}; - -/** - * Red message with "FYI" as the default title. - */ -export const info = ( - message: string, - title = "FYI", - color = "blue" -) => { - createToast(message, title, color); -}; - -/** - * Blue message with "Did you know?" as the default title. - */ -export const fun = ( - message: string, - title = "Did you know?", - color = "dark-blue" -) => { - createToast(message, title, color); -}; - -/** - * Adds a hidden container div for holding toast messages. - */ -export const init = () => { - const toastContainer = document.createElement("div"); - toastContainer.classList.add("toast-container"); - document.body.appendChild(toastContainer); -}; diff --git a/frontend/toast/toast.ts b/frontend/toast/toast.ts new file mode 100644 index 000000000..7f4f18276 --- /dev/null +++ b/frontend/toast/toast.ts @@ -0,0 +1,54 @@ +/** + * Yellow message with "Warning" as the default title. + */ +export const warning = + (message: string, title = "Warning", color = "yellow") => { + if (messageQueue.indexOf(message) > -1) { + console.warn(message); + } else { + createToast(message, title, color); + messageQueue.push(message); + } + }; + +/** + * Red message with "Error" as the default title. + */ +export const error = (message: string, title = "Error", color = "red") => { + if (messageQueue.indexOf(message) > -1) { + console.error(message); + } else { + createToast(message, title, color); + messageQueue.push(message); + } +}; + +/** + * Green message with "Success" as the default title. + */ +export const success = + (message: string, title = "Success", color = "green") => + createToast(message, title, color); + +/** + * Red message with "FYI" as the default title. + */ +export const info = + (message: string, title = "FYI", color = "blue") => + createToast(message, title, color); + +/** + * Blue message with "Did you know?" as the default title. + */ +export const fun = + (message: string, title = "Did you know?", color = "dark-blue") => + createToast(message, title, color); + +/** + * Adds a hidden container div for holding toast messages. + */ +export const init = () => { + const toastContainer = document.createElement("div"); + toastContainer.classList.add("toast-container"); + document.body.appendChild(toastContainer); +};