mirror of
https://github.com/hex248/ob248.com.git
synced 2026-02-07 18:23:04 +00:00
32 lines
658 B
TypeScript
32 lines
658 B
TypeScript
import { createCliRenderer } from "@opentui/core";
|
|
import { createRoot, useKeyboard, useTerminalDimensions } from "@opentui/react";
|
|
|
|
function App() {
|
|
const { width, height } = useTerminalDimensions();
|
|
|
|
useKeyboard((key) => {
|
|
if (
|
|
key.name === "q" ||
|
|
key.name === "escape" ||
|
|
(key.ctrl && key.name === "c")
|
|
) {
|
|
process.exit(0);
|
|
}
|
|
});
|
|
|
|
const text = "ob248.com";
|
|
const x = Math.floor((width - text.length) / 2);
|
|
const y = Math.floor(height / 2);
|
|
|
|
return (
|
|
<box width={width} height={height}>
|
|
<text x={x} y={y}>
|
|
{text}
|
|
</text>
|
|
</box>
|
|
);
|
|
}
|
|
|
|
const renderer = await createCliRenderer();
|
|
createRoot(renderer).render(<App />);
|