rune
Version:
CLI to upload your games to Rune
17 lines (16 loc) • 636 B
JavaScript
import { Text } from "ink";
import React, { useState, useEffect } from "react";
export function DisappearingHint({ text, delay = 4000, }) {
const [hintOpacity, setHintOpacity] = useState(1);
useEffect(() => {
const handle = setTimeout(() => setHintOpacity(0.5), delay / 2);
const handle2 = setTimeout(() => setHintOpacity(0), delay);
return () => {
clearTimeout(handle);
clearTimeout(handle2);
};
}, [delay]);
if (hintOpacity === 0)
return null;
return (React.createElement(Text, { color: "yellow", italic: true, dimColor: hintOpacity < 1 }, text));
}