feat: more spinners
This commit is contained in:
parent
7eefce2de3
commit
dccb31106a
1 changed files with 34 additions and 2 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue