feat: more spinners

This commit is contained in:
Nate 2025-07-13 18:52:35 -07:00
parent 7eefce2de3
commit dccb31106a

View file

@ -1,6 +1,37 @@
import { Text } from "ink"; import { Text } from "ink";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
const SPINNER_BARS = "▁▂▃▄▅▆▇█▇▆▅▄▃▁";
const SPINNER_BLOCKS = "▉▊▋▌▍▎▏▎▍▌▋▊▉";
const SPINNER_CORNERS = "▖▘▝▗";
const SPINNER_CLASSIC = "-/|\\-/|";
const SPINNER_BOX = "┤┘┴└├┌┬┐";
const SPINNER_DOUBLE_BARS = [
"▁▁",
"▁▂",
"▁▃",
"▁▄",
"▁▅",
"▁▆",
"▁▇",
"▁█",
"▂▇",
"▃▆",
"▄▅",
"▅▄",
"▆▃",
"▇▂",
"█▁",
"▇▁",
"▆▁",
"▅▁",
"▄▁",
"▃▁",
"▂▁",
];
const SPINNER: string | string[] = SPINNER_CORNERS;
interface LoadingAnimationProps { interface LoadingAnimationProps {
visible?: boolean; visible?: boolean;
color?: string; color?: string;
@ -8,10 +39,11 @@ interface LoadingAnimationProps {
const LoadingAnimation: React.FC<LoadingAnimationProps> = ({ const LoadingAnimation: React.FC<LoadingAnimationProps> = ({
visible = true, visible = true,
color = "gray", color = "blue",
}) => { }) => {
const [currentIndex, setCurrentIndex] = useState(0); const [currentIndex, setCurrentIndex] = useState(0);
const animationChars = ["-", "/", "|", "\\", "-", "/"]; const animationChars =
typeof SPINNER === "string" ? (SPINNER as string).split("") : SPINNER;
useEffect(() => { useEffect(() => {
if (!visible) return; if (!visible) return;