7 Commits

Author SHA1 Message Date
99a70c662f progress bar 2021-06-01 10:38:41 +02:00
49afc7fccd bug with updater 2021-05-31 18:58:23 +02:00
f1c0ab6dbb restore focus to orignal window 2021-05-28 21:05:12 +02:00
53c16e7063 version bump 2021-05-28 20:56:43 +02:00
2606214e53 tray icon 2021-05-28 20:56:35 +02:00
f5ecebb61a fix settings open 2021-05-28 20:54:56 +02:00
3129030d00 releasing docs 2021-05-15 17:17:44 +02:00
12 changed files with 833 additions and 1681 deletions

View File

@@ -2,9 +2,6 @@ name: Main
on:
workflow_dispatch:
push:
tags:
- "v*.*.*"
jobs:
build:

View File

@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.0] - 2021-06-01
### Added
- Progress bar
## [1.1.2] - 2021-05-31
### Fixed
- Bug with update window when banner is currently open
## [1.1.1] - 2021-05-28
### Added
- Restore focus to previous window when closing banner
- Responsive image
### Fixed
- Settings page not opening
## [1.1.0] - 2021-05-15
### Added

View File

@@ -35,4 +35,4 @@ Alternatively you can run `yarn build` and the `yarn electron-builder -m` for `m
1. Bump version in `package.json`
2. Update `CHANGELOG.md`
3. Create a draft release with the new version. (e.g. tag with `v1.2.3`).
4. Push to `main` and github workflow will build and upload assets to the draft matching the version of `package.json` and draft.
4. Start the publish action and the ci will build and upload assets to the draft matching the version of `package.json` and draft.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -11,7 +11,7 @@
"repository": {
"url": "https://github.com/cupcakearmy/unpixel"
},
"version": "1.1.0",
"version": "1.2.0",
"main": "./dist/back/index.js",
"scripts": {
"start": "electron .",
@@ -62,7 +62,7 @@
"electron": "^12.0.0",
"electron-builder": "^22.10.5",
"npm-run-all": "^4.1.5",
"parcel": "next",
"parcel": "^2.0.0-beta.3.1",
"postcss": "^8.2.10",
"typescript": "^4.2.3"
}

View File

@@ -1,6 +1,6 @@
import { join } from 'path'
import os from 'os'
import { BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron'
import { app, BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron'
import dayjs from 'dayjs'
import logger from 'electron-log'
import ms from 'ms'
@@ -64,6 +64,9 @@ export default class Banner {
static close() {
if (this.window) {
Settings.save('lastRun', Date.now())
this.window.minimize()
this.window.hide()
if (process.platform === 'darwin') app.hide()
this.window.close()
this.window = null
}

View File

@@ -64,7 +64,7 @@ export default class Settings {
static open() {
if (this.win) return
Settings.win = new BrowserWindow({
this.win = new BrowserWindow({
width: 400,
height: 630,
center: true,
@@ -74,20 +74,21 @@ export default class Settings {
contextIsolation: false,
},
})
this.win.on('closed', () => (this.win = null))
const entry = join(__dirname, '../front/settings/index.html')
Settings.win.loadFile(entry)
Settings.win.setMenu(null)
this.win.loadFile(entry)
this.win.setMenu(null)
if (DEV) {
Settings.win.setSize(800, 485)
Settings.win.setResizable(true)
Settings.win.webContents.openDevTools()
this.win.setSize(800, 485)
this.win.setResizable(true)
this.win.webContents.openDevTools()
}
}
static getStatus(): [boolean, number] {
const paused: number = Settings.load('paused')
const paused: number = this.load('paused')
const now = Date.now()
if (paused > now) {
return [true, paused - now]

View File

@@ -61,11 +61,10 @@ export default class TrayUtility {
static init() {
if (!this.tray) {
const file = path.join(__dirname, '../../assets/tray.png')
const icon = nativeImage.createFromPath(file).resize({
width: 24,
height: 24,
})
this.tray = new Tray(icon)
const resized = nativeImage.createFromPath(file).resize({ width: 24, height: 24 })
resized.setTemplateImage(true)
resized.isMacTemplateImage = true
this.tray = new Tray(resized)
this.build()
}
}

View File

@@ -4,6 +4,7 @@ import logger from 'electron-log'
import { dialog, shell } from 'electron'
import pkg from '../../package.json'
import Banner from './banner'
const current = semver.coerce(pkg.version)
const url = 'https://api.github.com/repos/cupcakearmy/unpixel/tags'
@@ -25,7 +26,9 @@ export default class Updater {
if (!current) throw new Error('Could not determine current version')
if (semver.lt(current, latest)) {
logger.info('New version available')
Banner.close()
dialog
// @ts-ignore
.showMessageBox(null, {
title: 'Update available',
message: 'A newer version is available, please download.',
@@ -35,7 +38,6 @@ export default class Updater {
.then(({ response }) => {
if (response === 0) {
shell.openExternal('https://github.com/cupcakearmy/unpixel/releases')
process.exit(0)
}
})
} else {

View File

@@ -19,11 +19,6 @@ main {
align-items: center;
}
h1 {
border-bottom: 0.5em solid currentColor;
padding-bottom: 0.15em;
}
.countdown {
font-size: min(8rem, 25vh);
}
@@ -58,3 +53,16 @@ button {
button:hover {
background-color: #2c2cce;
}
.progress {
width: 100%;
height: 3rem;
border: 0.125rem solid currentColor;
}
.progress > div {
background-color: currentColor;
height: 100%;
width: 100%;
transition: width ease-out 250ms;
}

View File

@@ -30,6 +30,8 @@ const Banner: React.FC = () => {
const [done, setDone] = useState(false)
const [auto, setAuto] = useState(false)
const [progress, setProgress] = useState(100)
const [max, setMax] = useState(0)
const [countdown, setCountdown] = useState<null | number>(null)
const handler = useCallback(
@@ -57,16 +59,26 @@ const Banner: React.FC = () => {
}
}, [countdown])
useEffect(() => {
if (countdown !== null) {
setProgress((countdown / max) * 100)
}
}, [countdown, max])
useEffect(() => {
const autoClose = ipcRenderer.sendSync('load', { key: 'autoClose' })
setAuto(autoClose)
const time = ipcRenderer.sendSync('load', { key: 'duration' })
setCountdown(time)
setMax(time)
}, [])
return (
<div>
<h1 className="ma0 mb4">Look Away</h1>
<h1 className="ma0 mb3">Look Away</h1>
<div className="progress mb4">
<div style={{ width: progress.toFixed(2) + '%' }} />
</div>
<div className="code countdown">{countdown}</div>
<div className="tile message">
Look at least <b>6 meters</b> away. <br />

2417
yarn.lock

File diff suppressed because it is too large Load Diff