Skip to content

Commit

Permalink
Created a script to visualise the loading progress with emojis 🧪
Browse files Browse the repository at this point in the history
  • Loading branch information
01taylop committed Jun 19, 2024
1 parent bbc96ff commit 2bfafaa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
27 changes: 27 additions & 0 deletions scripts/visualise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import readline from 'readline'

import { getProgressConfig } from '../src/config.js'

const visualise = () => {
const [startChar, endChar, progressLength] = getProgressConfig(new Date('2025-01-01'))

const display = count => {
const complete = startChar.repeat(count)
const incomplete = endChar.repeat(progressLength - count)
const percent = (count / progressLength * 100).toFixed()

readline.clearLine(process.stdout, 0)
readline.cursorTo(process.stdout, 0)
process.stdout.write(`${complete}${incomplete} | ${percent}% Testing...`)

if (count < progressLength) {
setTimeout(() => {
display(count += 1)
}, 100)
}
}

display(0)
}

visualise()
21 changes: 10 additions & 11 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import chalk from 'chalk'

const dateConfigurations = {
'01-01': ['🎉', '⬜️'], // New Year's Day
'01-29-2025': ['🐍', '⬜️'], // Chinese New Year 2025
'01-01_01-05': ['🎉', '🪩'], // New Year's Day
'01-29-2025': ['🐍', '🧧'], // Chinese New Year 2025
'02-14': ['🌹', '🥀'], // Valentine's Day
'03-04-2025': ['🥞', '🍽️'], // Pancake Day 2025
'03-14': ['🥧', '🍽️'], // Pi Day
'03-17': ['🍀', '⬜️'], // St Patrick's Day
'04-01': ['🃏', '️'], // April Fool's Day
'04-01': ['🃏', '🕳️'], // April Fool's Day
'04-10-2025_04-20-2025': ['🐣', '🥚'], // Easter 2025
'04-22': ['🌎', '⬜️'], // Earth Day
'05-04': ['⭐️', '⬜️'], // Star Wars Day
'05-20': ['🐝', '⬜️'], // World Bee Day
'05-04': ['⭐️', '🌌'], // Star Wars Day
'05-20': ['🐝', '🌸'], // World Bee Day
'05-30': ['🥔', '⬜️'], // International Day of Potato
'06-03': ['🚲', '⬜️'], // World Bicycle Day
'06-05': ['🌳', '⬜️'], // World Environment Day
'06-08': ['🌊', '⬜️'], // World Oceans Day
'06-19_06-23': ['☀️', '☁️'], // Summer Solstice (21st June)
'07-04': ['🎆', '⬜️'], // Independence Day (US)
'07-04': ['🎆', '⬛️'], // Independence Day (US)
'07-01-2024_07-14-2024': ['🎾', '⬛️'], // Wimbledon 2024 (UK)
'07-20': ['🌝', '🌚'], // International Moon Day
'07-01-2024_07-14-2024': ['🎾', '⬜️'], // Wimbledon 2024 (UK)
'09-05': ['💖', '🤍'], // International Charity Day
'09-21': ['☮️', '️'], // International Day of Peace
'10-01': ['☕️', '⬜️'], // International Coffee Day
'09-21': ['☮️', '️'], // International Day of Peace
'10-01': ['☕️', '🕘'], // International Coffee Day
'10-24_10-31': ['🎃', '🦇'], // Halloween
'11-28-2024': ['🦃', '🍂'], // Thanksgiving (US)
'12-01_12-31': ['⛄️', '🧊'], // Winter (Northern Hemisphere)
}

const getProgressConfig = () => {
const currentDate = new Date()
const getProgressConfig = (currentDate = new Date()) => {
const today = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()).getTime()

const matchingConfig = Object.entries(dateConfigurations).find(([dateRange]) => {
Expand Down
23 changes: 12 additions & 11 deletions tests/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@ jest.mock('chalk', () => ({
describe('getProgressConfig', () => {

test.each([
['2000-01-01', ['🎉', '⬜️', 20]],
['2000-01-02', ['\u2588', ' ', 40]],
['2025-01-29', ['🐍', '⬜️', 20]],
['2000-01-01', ['🎉', '🪩', 20]],
['2000-01-05', ['🎉', '🪩', 20]],
['2000-01-06', ['\u2588', ' ', 40]],
['2025-01-29', ['🐍', '🧧', 20]],
['2000-02-14', ['🌹', '🥀', 20]],
['2025-03-04', ['🥞', '🍽️', 20]],
['2000-03-14', ['🥧', '🍽️', 20]],
['2000-03-17', ['🍀', '⬜️', 20]],
['2000-04-01', ['🃏', '️', 20]],
['2000-04-01', ['🃏', '🕳️', 20]],
['2025-04-10', ['🐣', '🥚', 20]],
['2025-04-20', ['🐣', '🥚', 20]],
['2000-04-22', ['🌎', '⬜️', 20]],
['2000-05-04', ['⭐️', '⬜️', 20]],
['2000-05-20', ['🐝', '⬜️', 20]],
['2000-05-04', ['⭐️', '🌌', 20]],
['2000-05-20', ['🐝', '🌸', 20]],
['2000-05-30', ['🥔', '⬜️', 20]],
['2000-06-03', ['🚲', '⬜️', 20]],
['2000-06-05', ['🌳', '⬜️', 20]],
['2000-06-08', ['🌊', '⬜️', 20]],
['2000-06-19', ['☀️', '☁️', 20]],
['2000-06-23', ['☀️', '☁️', 20]],
['2000-07-04', ['🎆', '⬜️', 20]],
['2000-07-04', ['🎆', '⬛️', 20]],
['2024-07-01', ['🎾', '⬛️', 20]],
['2024-07-14', ['🎾', '⬛️', 20]],
['2000-07-20', ['🌝', '🌚', 20]],
['2024-07-01', ['🎾', '⬜️', 20]],
['2024-07-14', ['🎾', '⬜️', 20]],
['2000-09-05', ['💖', '🤍', 20]],
['2000-09-21', ['☮️', '️', 20]],
['2000-10-01', ['☕️', '⬜️', 20]],
['2000-09-21', ['☮️', '️', 20]],
['2000-10-01', ['☕️', '🕘', 20]],
['2000-10-24', ['🎃', '🦇', 20]],
['2000-10-31', ['🎃', '🦇', 20]],
['2024-11-28', ['🦃', '🍂', 20]],
Expand Down

0 comments on commit 2bfafaa

Please sign in to comment.