diff --git a/assets/less/main.less b/assets/less/main.less deleted file mode 100644 index e69de29..0000000 diff --git a/assets/less/public.less b/assets/less/public.less new file mode 100644 index 0000000..bc30409 --- /dev/null +++ b/assets/less/public.less @@ -0,0 +1,12 @@ +h1 { + text-align: center; +} +.timer { + display: flex; + flex-direction: column; + align-items: center; + > .time { + font-size: 4em; + font-weight: bold; + } +} diff --git a/client/components/Layout.jsx b/client/components/Layout.jsx index 4387010..bdb88f0 100644 --- a/client/components/Layout.jsx +++ b/client/components/Layout.jsx @@ -6,7 +6,8 @@ export default () => (

Pomodoro Time!

- + +
); diff --git a/client/components/Timer.jsx b/client/components/Timer.jsx index 3a31efd..17d798f 100644 --- a/client/components/Timer.jsx +++ b/client/components/Timer.jsx @@ -1,18 +1,16 @@ import { h, Component } from 'preact'; -import { bindAll } from 'lowline'; +import { startCase, bindAll } from 'lowline'; import timeFilter from '../util/time-filter'; -const length = 25 * 60 * 1000; - export default class Timer extends Component { - constructor() { - super(); + constructor(props) { + super(props); this.state = { - time: length, - totalTime: length, + time: props.time, + totalTime: props.time, startTime: undefined, }; @@ -28,7 +26,7 @@ export default class Timer extends Component { startTime: Date.now(), }); - this.interval = setInterval(this.updateTimer.bind(this), 10); + this.interval = setInterval(this.updateTimer, 10); } pause() { @@ -39,8 +37,8 @@ export default class Timer extends Component { clearInterval(this.interval); this.setState({ - time: length, - totalTime: length, + time: this.props.time, + totalTime: this.props.time, startTime: undefined, }); } @@ -67,6 +65,8 @@ export default class Timer extends Component { const data = { startTime: this.state.startTime, endTime: new Date(), + type: this.props.type, + length: this.props.time, }; document.title = 'Pling!'; @@ -74,9 +74,11 @@ export default class Timer extends Component { if (Notification.permission !== 'granted') { Notification.requestPermission(); } else { - const notification = new Notification('Pomodoro complete!', { + const title = this.props.type === 'pomodoro' ? 'Pomodoro Complete!' : 'Break is over!'; + const body = this.props.type === 'pomodoro' ? 'Time for a break!' : 'Get back to work!'; + const notification = new Notification(title, { icon: 'https://www.planetnatural.com/wp-content/uploads/2014/03/tomato-supplies.jpg', - body: 'Time for a break!', + body, }); } @@ -96,14 +98,15 @@ export default class Timer extends Component { render(props, state) { return ( -
+
+

{startCase(props.type)}

+
{timeFilter(state.time || 0)}
- - +
-
+ ); } } diff --git a/server/services/pomodoros/model.js b/server/services/pomodoros/model.js index a09adc5..e3625d5 100644 --- a/server/services/pomodoros/model.js +++ b/server/services/pomodoros/model.js @@ -11,6 +11,14 @@ const PomodoroSchema = new mongoose.Schema({ type: Date, required: true, }, + type: { + type: String, + required: true, + }, + length: { + type: Number, + required: true, + }, name: String, location: String, user: {