| 1 | import { Box, Text } from "ink"; |
| 2 | import React from "react"; |
| 3 | |
| 4 | import { LoadingAnimation } from "../LoadingAnimation.js"; |
| 5 | import { Timer } from "../Timer.js"; |
| 6 | |
| 7 | interface ActionStatusProps { |
| 8 | visible: boolean; |
| 9 | startTime: number; |
| 10 | message: string; |
| 11 | showSpinner?: boolean; |
| 12 | color?: string; |
| 13 | loadingColor?: string; |
| 14 | } |
| 15 | |
| 16 | const ActionStatus: React.FC<ActionStatusProps> = ({ |
| 17 | visible, |
| 18 | startTime, |
| 19 | message, |
| 20 | showSpinner = false, |
| 21 | color = "dim", |
| 22 | loadingColor = "green", |
| 23 | }) => { |
| 24 | if (!visible) return null; |
| 25 | |
| 26 | return ( |
| 27 | <Box paddingX={1} flexDirection="row" gap={1}> |
| 28 | {showSpinner && <LoadingAnimation color={loadingColor} visible={true} />} |
| 29 | <Text color={color}>{message}</Text> |
| 30 | <Text color="dim">(</Text> |
| 31 | <Timer startTime={startTime} /> |
| 32 | <Text color="dim">• esc to interrupt )</Text> |
| 33 | </Box> |
| 34 | ); |
| 35 | }; |
| 36 | |
| 37 | export { ActionStatus }; |