-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved progress bar and refactored html code to use React * Prettier didn't like these * Console logs → log.info
- Loading branch information
Showing
7 changed files
with
104 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; | ||
margin: auto; | ||
max-width: 38rem; | ||
padding: 2rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import ProgressOverlay from './screens/ProgressOverlay'; | ||
import log from 'electron-log/renderer'; | ||
|
||
const bodyStyle: React.CSSProperties = { | ||
fontFamily: 'Arial, sans-serif', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
height: '100vh', | ||
margin: '0', | ||
backgroundColor: '#f0f0f0', | ||
}; | ||
|
||
// Main entry point for the front end renderer. | ||
// Currently this serves as the overlay to show progress as the comfy backend is coming online. | ||
// after coming online the main.ts will replace the renderer with comfy's internal index.html | ||
function Home(): React.ReactElement { | ||
return ( | ||
<div style={bodyStyle}> | ||
<ProgressOverlay /> | ||
</div> | ||
); | ||
} | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React, { useEffect } from 'react'; | ||
import { ELECTRON_BRIDGE_API } from 'src/constants'; | ||
import log from 'electron-log/renderer'; | ||
|
||
const loadingTextStyle: React.CSSProperties = { | ||
marginBottom: '20px', | ||
textAlign: 'center', | ||
}; | ||
|
||
const progressBarStyle: React.CSSProperties = { | ||
width: '300px', | ||
height: '20px', | ||
backgroundColor: '#e0e0e0', | ||
borderRadius: '10px', | ||
overflow: 'hidden', | ||
}; | ||
|
||
const progressStyle: React.CSSProperties = { | ||
width: '0%', | ||
height: '100%', | ||
backgroundColor: '#09f', | ||
transition: 'width 0.5s ease', | ||
}; | ||
|
||
interface ProgressUpdate { | ||
percentage: number; | ||
status: string; | ||
} | ||
|
||
//Overlay that shows the progress bar | ||
function ProgressOverlay(): React.ReactElement { | ||
function updateProgress({ percentage, status }: ProgressUpdate) { | ||
const progressBar = document.getElementById('progress') as HTMLElement; | ||
const loadingText = document.getElementById('loading-text') as HTMLElement; | ||
log.info(`Updating progress: ${percentage}%, ${status}`); | ||
progressBar.style.width = `${percentage}%`; | ||
loadingText.textContent = status; | ||
|
||
if (percentage === 100) { | ||
loadingText.textContent = 'ComfyUI is ready!'; | ||
} | ||
} | ||
|
||
// Updates when internal items change | ||
useEffect(() => { | ||
if (ELECTRON_BRIDGE_API in window) { | ||
log.info(`${ELECTRON_BRIDGE_API} found, setting up listeners`); | ||
(window as any).electronAPI.onProgressUpdate((update: ProgressUpdate) => { | ||
log.info('Received loading progress', update); | ||
updateProgress(update); | ||
}); | ||
} else { | ||
log.error(`${ELECTRON_BRIDGE_API} not found in window object`); | ||
} | ||
}); | ||
return ( | ||
<> | ||
<div style={loadingTextStyle} id="loading-text"> | ||
Initializing... | ||
</div> | ||
<div style={progressBarStyle} id="progress-bar"> | ||
<div style={progressStyle} id="progress"></div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default ProgressOverlay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters