11/// <reference types="w3c-web-usb" />
2- import { useCallback , useEffect , useMemo , useRef , useState , type ChangeEvent , type DragEvent } from "react" ;
2+ import { useCallback , useEffect , useMemo , useRef , useState , type ChangeEvent , type DragEvent , type ReactNode } from "react" ;
33import {
44 CH55xBootloader ,
55 FakeBootloader ,
@@ -1226,7 +1226,7 @@ export default function KeypadFlasherApp() {
12261226 const warnNoBootEntry = Boolean ( selectedLayout && bootloaderOnBootCount === 0 && bootloaderChordCount === 0 ) ;
12271227 const warnSingleChord = Boolean ( selectedLayout && bootloaderChordCount === 1 ) ;
12281228
1229- const statusBanner = ( ( ) => {
1229+ const statusBanner : { tone : "info" | "success" | "warn" | "error" ; title : string ; body ?: ReactNode ; showSpinner ?: boolean } | null = ( ( ) => {
12301230 switch ( status . state ) {
12311231 case "requesting" :
12321232 return { tone : "info" as const , title : "Requesting device…" , body : "Approve the WebUSB prompt to continue." } ;
@@ -1235,7 +1235,7 @@ export default function KeypadFlasherApp() {
12351235 case "connectedUnknown" :
12361236 return { tone : "warn" as const , title : "Device not recognized" , body : "Use debug firmware or pick a supported layout." } ;
12371237 case "compiling" :
1238- return { tone : "info" as const , title : "Compiling firmware…" , body : status . detail ? `Building ${ status . detail } .` : undefined } ;
1238+ return { tone : "info" as const , title : "Compiling firmware…" , body : status . detail ? `Building ${ status . detail } .` : undefined , showSpinner : true } ;
12391239 case "unsupported" :
12401240 return { tone : "warn" as const , title : "Unknown device" , body : status . detail } ;
12411241 case "flashing" :
@@ -1259,10 +1259,12 @@ export default function KeypadFlasherApp() {
12591259 case "error" :
12601260 return { tone : "error" as const , title : "Error" , body : status . detail } ;
12611261 default :
1262- return null ;
1262+ return null ;
12631263 }
12641264 } ) ( ) ;
12651265
1266+ const statusProgress = progress . total > 0 ? progress : null ;
1267+
12661268 return (
12671269 < div className = "app-shell" >
12681270 < div className = "container" >
@@ -1353,14 +1355,13 @@ export default function KeypadFlasherApp() {
13531355 ) }
13541356
13551357 { statusBanner && (
1356- < StatusBanner tone = { statusBanner . tone } title = { statusBanner . title } body = { statusBanner . body } />
1357- ) }
1358-
1359- { progress . total > 0 && (
1360- < div className = "progress" >
1361- < div className = "progress-bar" style = { { width : `${ Math . round ( ( progress . current / progress . total ) * 100 ) } %` } } />
1362- < div className = "muted small mt-1" > { progress . phase } { progress . current } / { progress . total } </ div >
1363- </ div >
1358+ < StatusBanner
1359+ tone = { statusBanner . tone }
1360+ title = { statusBanner . title }
1361+ body = { statusBanner . body }
1362+ showSpinner = { statusBanner . showSpinner }
1363+ progress = { statusProgress }
1364+ />
13641365 ) }
13651366 </ div >
13661367
0 commit comments