Files
windmill/frontend/src/lib/components/progressBar/model.ts
Ádám Kovács 61156a97b0 feat(frontend): Update progress bar (#770)
* feat(frontend): Update progress bar component

* feat(frontend): Add progress to flow run (WIP)

* feat(frontend): Add progress to flow run (WIP 2)

* fix(frontend): Fix loop progress loading

* fix(frontend): Rethink progress bar

* fix(frontend): Remove comment

* feat(front): Add error state and instant loading

* fix(frontend): Fix disappearing progress bits

* feat(frontend): Add progress to run page

* fix(frontend): Fix parallel progress loading issue

* progress bar + up to fix

Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2022-10-28 10:33:28 +02:00

46 lines
1.1 KiB
TypeScript

import { tweened } from 'svelte/motion'
import { cubicOut } from 'svelte/easing'
export interface ProgressStateStoreValue {
length: number
index: number
finished: boolean
error: boolean
}
export type StepKind = 'general' | 'loop'
type Step<T extends StepKind> = {
type: T
isDone: boolean
}
export type GeneralStep = Step<'general'>
export type LoopStep = Step<'loop'> & { index: number; length: number }
export type ProgressStep = GeneralStep | LoopStep
export function isLoopStep(step: ProgressStep | undefined): step is LoopStep {
return step?.type === 'loop'
}
type State<T extends StepKind> = {
type: T
isDone: boolean
isDoneChanged: boolean
}
export type GeneralState = State<'general'>
export type LoopState = LoopStep & { index: number; indexChanged: boolean }
export type ProgressState = GeneralState | LoopState
export function isLoopState(state: ProgressState | undefined): state is LoopState {
return state?.type === 'loop'
}
export function getTween(initialValue = 0, duration = 200) {
return tweened(initialValue, {
duration,
easing: cubicOut
})
}