Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pomodoro/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CodePen - Pomodoro Timer</title>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css'><link rel="stylesheet" href="./style.css">

Expand Down
103 changes: 75 additions & 28 deletions pomodoro/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import React from "https://cdn.skypack.dev/react@17.0.1";
import ReactDOM from "https://cdn.skypack.dev/react-dom@17.0.1";

// Notion Background Theme Detection
(function(){
function setBodyBackground(){
try{
const isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
document.body.style.background = isDark ? '#191919' : '#ffffff';
} catch(e) {
document.body.style.background = '#ffffff';
}
}
if(window.matchMedia){
window.matchMedia('(prefers-color-scheme: dark)').addListener(setBodyBackground);
}
setBodyBackground();
})();

// Theme options: "default", "alternative", "lofi-night"
const selectedTheme = "lofi-night";

if (selectedTheme && selectedTheme !== "default") {
document.body.dataset.theme = selectedTheme;
} else {
document.body.removeAttribute("data-theme");
}

const SESSION = "Session";
const BREAK = "Break";
const SESSIONLEN = 25;
Expand Down Expand Up @@ -240,44 +265,66 @@ class SetTimerLength extends React.Component {


class Timer extends React.Component {
constructor(props) {
super(props);
this.buttonRefStartStop = React.createRef();
this.buttonRefReset = React.createRef();
constructor(props) {
super(props);
this.buttonRefStartStop = React.createRef();
this.buttonRefReset = React.createRef();
this.buttonRefTheme = React.createRef();
}

toggleTheme() {
const themes = ["default", "alternative", "lofi-night"];
const currentTheme = document.body.dataset.theme || "default";
const currentIndex = themes.indexOf(currentTheme);
const nextIndex = (currentIndex + 1) % themes.length;
const nextTheme = themes[nextIndex];

if (nextTheme === "default") {
document.body.removeAttribute("data-theme");
} else {
document.body.dataset.theme = nextTheme;
}
}

render() {
return /*#__PURE__*/(
React.createElement("div", null, /*#__PURE__*/
React.createElement("div", { id: "time-left" }, this.props.timeLeft), /*#__PURE__*/
React.createElement("div", { id: "display-controls" }, /*#__PURE__*/
React.createElement("div", { id: "timer-label" }, this.props.timerType), /*#__PURE__*/
React.createElement("div", { id: "timer-ssr" }, /*#__PURE__*/
React.createElement("button", {
ref: this.buttonRefStartStop,
id: "start-stop",
onClick: () => {
this.props.toggleStartStopTimer();
this.buttonRefStartStop.current.blur();
} }, /*#__PURE__*/
render() {
return /*#__PURE__*/(
React.createElement("div", null, /*#__PURE__*/
React.createElement("div", { id: "time-left" }, this.props.timeLeft), /*#__PURE__*/
React.createElement("div", { id: "display-controls" }, /*#__PURE__*/
React.createElement("button", {
ref: this.buttonRefStartStop,
id: "start-stop",
onClick: () => {
this.props.toggleStartStopTimer();
this.buttonRefStartStop.current.blur();
} }, /*#__PURE__*/

React.createElement("i", { className: this.props.stopStartTimer, "aria-hidden": "true" })), /*#__PURE__*/
React.createElement("i", { className: this.props.stopStartTimer, "aria-hidden": "true" })), /*#__PURE__*/

React.createElement("button", {
ref: this.buttonRefReset,
id: "reset",
onClick: () => {
this.props.resetTimer();
this.buttonRefReset.current.blur();
} }, /*#__PURE__*/
React.createElement("button", {
ref: this.buttonRefReset,
id: "reset",
onClick: () => {
this.props.resetTimer();
this.buttonRefReset.current.blur();
} }, /*#__PURE__*/

React.createElement("i", { className: "fa fa-refresh", "aria-hidden": "true" }))))));
React.createElement("i", { className: "fa fa-refresh", "aria-hidden": "true" })), /*#__PURE__*/

React.createElement("button", {
ref: this.buttonRefTheme,
id: "theme-toggle",
onClick: () => {
this.toggleTheme();
this.buttonRefTheme.current.blur();
} }, /*#__PURE__*/

React.createElement("i", { className: "fa fa-paint-brush", "aria-hidden": "true" })))));



}}

}}


ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById("root"));
154 changes: 129 additions & 25 deletions pomodoro/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,126 @@

/* General */

:root {
--text-color: #111111;
--card-bg: rgb(240, 240, 190);
--panel-bg: rgb(150, 180, 175);
--panel-shadow: rgb(121, 145, 141);
--accent: rgb(234, 178, 156);
--accent-shadow: rgb(194, 91, 44);
--card-shadow: sienna;
}

body[data-theme="alternative"] {
--text-color: #e8e6e3;
--card-bg: #2b2b2b;
--panel-bg: #3a3f44;
--panel-shadow: #1f2326;
--accent: #d98c5f;
--accent-shadow: #a8683b;
--card-shadow: #5a3a22;
}

/* Lo-Fi Night Theme - Inspired by cozy night cityscape */
body[data-theme="lofi-night"] {
--text-color: #e0fbfc;
--card-bg: #1b263b;
--panel-bg: #0d1b2a;
--panel-shadow: #051923;
--accent: #ff6b6b;
--accent-shadow: #c1121f;
--card-shadow: #0a1628;
}

body {
font-family: 'Roboto Mono', monospace;
// background-color: #c2e6e8;
background: transparent;
color: var(--text-color);
margin: 0;
padding: 0;
}

#root {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 0;
margin: 0;
box-sizing: border-box;
}

button,
button:active {
background-color: rgb(234,178,156);
background-color: var(--accent);
border: none;
width: 42px;
height: 40px;
border-radius: 100%;
text-align: center;
box-shadow: 0.2em 0.2em rgb(194, 91, 44);
-webkit-box-shadow: 0.2em 0.2em rgb(194, 91, 44);
-moz-box-shadow: 0.2em 0.2em rgb(194, 91, 44);
box-shadow: 0.2em 0.2em var(--accent-shadow);
-webkit-box-shadow: 0.2em 0.2em var(--accent-shadow);
-moz-box-shadow: 0.2em 0.2em var(--accent-shadow);
cursor: pointer;
}

button:focus {
translate: 0.2em 0.2em;
box-shadow: 0.2em 0.2em rgb(194, 91, 44) inset;
-webkit-box-shadow: 0.2em 0.2em rgb(194, 91, 44) inset;
-moz-box-shadow: 0.2em 0.2em rgb(194, 91, 44) inset;
box-shadow: 0.2em 0.2em var(--accent-shadow) inset;
-webkit-box-shadow: 0.2em 0.2em var(--accent-shadow) inset;
-moz-box-shadow: 0.2em 0.2em var(--accent-shadow) inset;
}

/* Clock Body */

.clock-container {
background-color: rgb(240, 240, 190);
background-color: var(--card-bg);
width: 350px;
max-width: 100%;
border-radius: 20px;
padding: 30px;
box-shadow: 10px 10px sienna;
box-shadow: 10px 10px var(--card-shadow);
box-sizing: border-box;
}

/* Display + Stop/Start/Reset Controls */

#time-left {
font-size: 70px;
text-align: center;
background-color: rgb(150,180,175);
background-color: var(--panel-bg);
padding: 20px;
border-radius: 20px;
box-shadow: 3px 3px rgb(121, 145, 141) inset;
box-shadow: 3px 3px var(--panel-shadow) inset;
}

#display-controls {
margin: 10px 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
justify-content: center;
gap: 15px;
}

#timer-label {
font-size: 25px;
text-align: center;
padding-top: 2px;
background-color: rgb(150,180,175);
background-color: var(--panel-bg);
border-radius: 10px;
height: 40px;
flex: 2;
box-shadow: 3px 3px rgb(121, 145, 141) inset;
box-shadow: 3px 3px var(--panel-shadow) inset;
}

#timer-ssr {
flex: 1;
margin-left: 30px;
display: flex;
justify-content: space-between;
flex-start: end;
justify-content: flex-end;
align-items: center;
gap: 15px;
}

/* Timer Length Controls */
Expand All @@ -87,32 +130,93 @@ button:focus {
margin-top: 20px;
display: flex;
flex-direction: row;
gap: 6px;
}

.inc-dec-btn-container {
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: center;
width: 140px;
height:60px;
align-items: center;
gap: 12px;
width: 100%;
height: 60px;
}

.break-container,
.session-container {
display: flex;
flex-direction: column;
justify-content: space-between;
text-align: center;
/* display: inline-block; */
border: 2px solid rgb(234,178,156);
border: 2px solid var(--accent);
padding: 10px;
border-radius: 10px;
width: 48%;
width: calc(50% - 3px);
box-sizing: border-box;
min-height: 140px;
}

#break-label,
#session-label {
min-height: 2.6em;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 4px;
}

.timer-length {
font-size: 2em;
margin-bottom: 10px;
}

/* Responsive Design */
@media screen and (max-width: 420px) {
.clock-container {
width: 100%;
padding: 20px;
box-shadow: none;
}

#time-left {
font-size: 50px;
padding: 15px;
}

#timer-label {
font-size: 20px;
}

#timer-ssr {
margin-left: 15px;
}

.length-container {
flex-direction: column;
gap: 10px;
}

.break-container,
.session-container {
width: 100%;
margin-right: 0;
}

.break-container {
margin-right: 0;
margin-bottom: 10px;
}
}

.break-container,
.inc-arrow {
margin-right: 12px;
@media screen and (max-width: 320px) {
#time-left {
font-size: 40px;
padding: 10px;
}

.clock-container {
padding: 15px;
}
}
Loading