mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 13:59:54 +00:00
This adds the list view to the media assets sidepanel, while also adding the active jobs to be displayed right now. The design for this is actually changing, which is why it is in draft right now. There are technical limitations of the virtual grid that doesn't make it easy for both the active jobs and generated assets to exist on the same container. Currently WIP right now. Part of the QPO v2 iteration, figma design can be found [here](https://www.figma.com/design/LVilZgHGk5RwWOkVN6yCEK/Queue-Progress-Modal?node-id=3330-37286&m=dev). This will be implemented in a series of stacked PRs that can be reviewed and merged individually. main <-- #7737, #7743, #7745 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7737-QPOv2-Add-list-view-to-assets-sidepanel-2d26d73d365081858e22c48902bd56e2) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
type ProgressPercent = number | undefined
|
|
|
|
const progressBarContainerClass = 'absolute inset-0'
|
|
const progressBarBaseClass =
|
|
'pointer-events-none absolute inset-y-0 left-0 h-full transition-[width]'
|
|
const progressBarPrimaryClass = `${progressBarBaseClass} bg-interface-panel-job-progress-primary`
|
|
const progressBarSecondaryClass = `${progressBarBaseClass} bg-interface-panel-job-progress-secondary`
|
|
|
|
function clampPercent(value: number) {
|
|
return Math.min(100, Math.max(0, value))
|
|
}
|
|
|
|
function normalizeProgressPercent(value: ProgressPercent) {
|
|
if (value === undefined || !Number.isFinite(value)) return undefined
|
|
|
|
return clampPercent(value)
|
|
}
|
|
|
|
function hasProgressPercent(value: ProgressPercent) {
|
|
return normalizeProgressPercent(value) !== undefined
|
|
}
|
|
|
|
function hasAnyProgressPercent(
|
|
totalPercent: ProgressPercent,
|
|
currentPercent: ProgressPercent
|
|
) {
|
|
return hasProgressPercent(totalPercent) || hasProgressPercent(currentPercent)
|
|
}
|
|
|
|
function progressPercentStyle(value: ProgressPercent) {
|
|
const normalized = normalizeProgressPercent(value)
|
|
|
|
if (normalized === undefined) return undefined
|
|
|
|
return { width: `${normalized}%` }
|
|
}
|
|
|
|
export function useProgressBarBackground() {
|
|
return {
|
|
progressBarContainerClass,
|
|
progressBarPrimaryClass,
|
|
progressBarSecondaryClass,
|
|
hasProgressPercent,
|
|
hasAnyProgressPercent,
|
|
progressPercentStyle
|
|
}
|
|
}
|