| 1 | import Spinner from "../../gui/Spinner"; |
| 2 | |
| 3 | export interface GeneratingCodeLoaderProps { |
| 4 | showLineCount: boolean; |
| 5 | codeBlockContent: string; |
| 6 | isPending: boolean; |
| 7 | } |
| 8 | |
| 9 | export function GeneratingCodeLoader({ |
| 10 | showLineCount, |
| 11 | codeBlockContent, |
| 12 | isPending, |
| 13 | }: GeneratingCodeLoaderProps) { |
| 14 | const numLinesCodeBlock = codeBlockContent.split("\n").length; |
| 15 | const linesGeneratedText = |
| 16 | numLinesCodeBlock === 1 |
| 17 | ? `1 line generated` |
| 18 | : `${numLinesCodeBlock} lines ${isPending ? "pending" : "generated"}`; |
| 19 | |
| 20 | return ( |
| 21 | <span className="text-lightgray inline-flex items-center gap-2"> |
| 22 | {showLineCount ? linesGeneratedText : "Generating"} |
| 23 | {!isPending && <Spinner />} |
| 24 | </span> |
| 25 | ); |
| 26 | } |