mirror of
https://github.com/cupcakearmy/unpixel.git
synced 2024-12-21 23:56:28 +00:00
progress bar
This commit is contained in:
parent
49afc7fccd
commit
99a70c662f
@ -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
|
||||
|
@ -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 .",
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 />
|
||||
|
Loading…
Reference in New Issue
Block a user