progress bar

This commit is contained in:
cupcakearmy 2021-06-01 10:38:41 +02:00
parent 49afc7fccd
commit 99a70c662f
No known key found for this signature in database
GPG Key ID: D28129AE5654D9D9
5 changed files with 33 additions and 8 deletions

View File

@ -5,6 +5,12 @@ 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

View File

@ -11,7 +11,7 @@
"repository": {
"url": "https://github.com/cupcakearmy/unpixel"
},
"version": "1.1.2",
"version": "1.2.0",
"main": "./dist/back/index.js",
"scripts": {
"start": "electron .",

View File

@ -38,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 />