2025-04-22 12:31:39 -05:00
|
|
|
import { engineStreamActor } from '@src/lib/singletons'
|
2025-04-07 07:08:31 -04:00
|
|
|
import { EngineStreamState } from '@src/machines/engineStreamMachine'
|
|
|
|
import { useSelector } from '@xstate/react'
|
|
|
|
|
|
|
|
import { faPause, faPlay, faSpinner } from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
2025-04-01 23:54:26 -07:00
|
|
|
|
2024-09-04 08:35:40 -04:00
|
|
|
export const ModelStateIndicator = () => {
|
2025-04-07 07:08:31 -04:00
|
|
|
const engineStreamState = useSelector(engineStreamActor, (state) => state)
|
2024-09-04 08:35:40 -04:00
|
|
|
|
|
|
|
let className = 'w-6 h-6 '
|
2025-04-07 07:08:31 -04:00
|
|
|
let icon = <div className={className}></div>
|
2024-09-04 08:35:40 -04:00
|
|
|
let dataTestId = 'model-state-indicator'
|
|
|
|
|
2025-04-07 07:08:31 -04:00
|
|
|
if (engineStreamState.value === EngineStreamState.Paused) {
|
|
|
|
className += 'text-secondary'
|
|
|
|
icon = (
|
|
|
|
<FontAwesomeIcon
|
|
|
|
data-testid={dataTestId + '-paused'}
|
|
|
|
icon={faPause}
|
|
|
|
width="20"
|
|
|
|
height="20"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
} else if (engineStreamState.value === EngineStreamState.Playing) {
|
|
|
|
className += 'text-secondary'
|
2024-09-04 08:35:40 -04:00
|
|
|
icon = (
|
2025-04-07 07:08:31 -04:00
|
|
|
<FontAwesomeIcon
|
|
|
|
data-testid={dataTestId + '-playing'}
|
|
|
|
icon={faPlay}
|
|
|
|
width="20"
|
|
|
|
height="20"
|
2024-09-04 08:35:40 -04:00
|
|
|
/>
|
|
|
|
)
|
2025-04-07 07:08:31 -04:00
|
|
|
} else {
|
|
|
|
className += 'text-secondary'
|
2024-09-04 08:35:40 -04:00
|
|
|
icon = (
|
2025-04-07 07:08:31 -04:00
|
|
|
<FontAwesomeIcon
|
|
|
|
data-testid={dataTestId + '-resuming'}
|
|
|
|
icon={faSpinner}
|
|
|
|
width="20"
|
|
|
|
height="20"
|
2024-09-04 08:35:40 -04:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={className} data-testid="model-state-indicator">
|
|
|
|
{icon}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|