Files
calendar/packages/app-store-cli/src/components/Message.tsx
T
d4c5a906b5 App Store Templates (#5289)
* Start by moving what we have to _templates

* WIP

* WIP

* Add create/edit/delete template commands

* Type fixes cli

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: zomars <zomars@me.com>
2023-01-18 15:30:25 -07:00

30 lines
875 B
TypeScript

import { Text } from "ink";
import React, { useEffect, useState } from "react";
export function Message({
message,
}: {
message: { text: string; type?: "info" | "error" | "success"; showInProgressIndicator?: boolean };
}) {
const color = message.type === "success" ? "green" : message.type === "error" ? "red" : "white";
const [progressText, setProgressText] = useState("...");
useEffect(() => {
if (message.showInProgressIndicator) {
const interval = setInterval(() => {
setProgressText((progressText) => {
return progressText.length > 3 ? "" : progressText + ".";
});
}, 1000);
return () => {
clearInterval(interval);
};
}
}, [message.showInProgressIndicator]);
return (
<Text color={color}>
{message.text}
{message.showInProgressIndicator && progressText}
</Text>
);
}