├── .gitignore ├── README.md ├── app ├── do.js ├── index.html └── style.css ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Is Mu-An asleep? 2 | 3 | Mu-An lives many timezones away and sometimes I talk to her and she doesn't 4 | answer and it's because she's asleep. Now you too can know when she's asleep. 5 | 6 | Also I really wanted to make an Electron app. 7 | 8 | ![2016-08-25 15_23_47](https://cloud.githubusercontent.com/assets/1369170/17993110/e9e1817c-6b01-11e6-944c-3844528e872c.gif) 9 | 10 | Yes, the text animates. Because I found it on [codepen](http://codepen.io/ClaireLarsen/pen/XmVyVX) that's why. 11 | 12 | Or alternatively, 13 | 14 | screen shot 2016-08-25 at 8 24 10 pm 15 | 16 | ## Running this locally 17 | 18 | ``` 19 | $ git clone https://github.com/notwaldorf/is-mu-an-asleep 20 | $ cd is-mu-an-asleep 21 | $ npm install 22 | $ npm run app 23 | ``` 24 | 25 | ## 😴🕖 26 | 27 | -------------------------------------------------------------------------------- /app/do.js: -------------------------------------------------------------------------------- 1 | var moment = require('moment-timezone'); 2 | var ipc = require('electron').ipcRenderer; 3 | 4 | ipc.on('show', function (event, message) { 5 | doItGetTheTimeDoItNow(); 6 | }) 7 | 8 | var minutesOfDay = function(m) { 9 | return m.minutes() + m.hours() * 60; 10 | } 11 | 12 | function doItGetTheTimeDoItNow() { 13 | var now = moment().tz('Asia/Taipei'); 14 | var minutes = minutesOfDay(now); 15 | 16 | // Awake at 9:00 am. 17 | var awake = 9 * 60; 18 | 19 | // Asleep at 11:00 pm. 20 | var asleep = 23 * 60; 21 | 22 | var isAsleep = minutes < awake || minutes > asleep; 23 | document.body.className = isAsleep ? 'dark' : 'light'; 24 | document.getElementById('time').innerText = now.format('hh:mm a'); 25 | document.getElementById('emoji').innerText = isAsleep ? '😴' : '🎉'; 26 | document.getElementById('answer').innerHTML = isAsleep ? 'YES' : 'NO'; 27 | } 28 | -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Is Mu-An asleep?

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
(because it's 6:00AM in Taipei) 22 |
23 | 24 |
25 | 26 | 27 | -------------------------------------------------------------------------------- /app/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 10px 0 0 0; 4 | font-family: sans-serif; 5 | text-align: center; 6 | text-transform: uppercase; 7 | letter-spacing: 0.2em; 8 | font-weight: 300; 9 | } 10 | 11 | body.light { 12 | background-color: white; 13 | color: #4d4e53; 14 | } 15 | 16 | body.dark { 17 | background-color: #1a1a1a; 18 | color: #fefefe; 19 | } 20 | 21 | .why { 22 | letter-spacing: 1px; 23 | font-size: 13px; 24 | } 25 | 26 | .title { 27 | font-size: 26px; 28 | outline: none; 29 | border: none; 30 | text-align: center; 31 | font-weight: 400; 32 | } 33 | 34 | svg { 35 | display: block; 36 | font: 10.5em 'Helvetica'; 37 | margin: 0 auto; 38 | height: 100px; 39 | width: 400px; 40 | 41 | } 42 | 43 | .text-copy { 44 | fill: none; 45 | stroke: white; 46 | stroke-dasharray: 6% 29%; 47 | stroke-width: 7px; 48 | stroke-dashoffset: 0%; 49 | animation: stroke-offset 3.5s infinite linear; 50 | } 51 | 52 | .text-copy:nth-child(1){ 53 | stroke: #F8726D; 54 | animation-delay: -1; 55 | } 56 | 57 | .text-copy:nth-child(2){ 58 | stroke: #6FABCE; 59 | animation-delay: -2s; 60 | } 61 | 62 | .text-copy:nth-child(3){ 63 | stroke: #ECD968; 64 | animation-delay: -3s; 65 | } 66 | 67 | .text-copy:nth-child(4){ 68 | stroke: #AECE5C; 69 | animation-delay: -4s; 70 | } 71 | 72 | .text-copy:nth-child(5){ 73 | stroke: #F5A36D; 74 | animation-delay: -5s; 75 | } 76 | 77 | @keyframes stroke-offset{ 78 | 100% {stroke-dashoffset: -35%;} 79 | } 80 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var menubar = require('menubar') 2 | var ipc = require('electron').ipcMain 3 | var mb = menubar({ dir: __dirname + '/app', width: 400, height: 200, preloadWindow: true, 'window-position': 'topRight' }) 4 | 5 | mb.on('show', function () { 6 | mb.window.webContents.send('show'); 7 | }) 8 | 9 | mb.app.on('activate', function () { 10 | mb.showWindow(); 11 | }) 12 | 13 | // When you receive the abort message, close the app 14 | ipc.on('abort', function () { 15 | mb.hideWindow(); 16 | }) 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "halp", 3 | "version": "0.0.1", 4 | "description": "I don't know what i'm doing", 5 | "main": "index.js", 6 | "dependencies": { 7 | "menubar": "^3.0.0", 8 | "moment-timezone": "^0.5.5" 9 | }, 10 | "devDependencies": { 11 | "electron-prebuilt": "^0.36.0" 12 | }, 13 | "scripts": { 14 | "app": "electron ." 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/notwaldorf/is-mu-an-asleep.git" 19 | }, 20 | "author": "Monica Dinculescu ", 21 | "license": "MIT" 22 | } 23 | --------------------------------------------------------------------------------