wip(ui): add a Terminal component

This commit is contained in:
Brian McGee
2025-05-26 16:32:44 +01:00
parent b6190b2760
commit 7859c87af8
7 changed files with 1521 additions and 1 deletions

View File

@@ -15,10 +15,16 @@ let
url = "https://github.com/Omnibus-Type/Archivo/raw/b5d63988ce19d044d3e10362de730af00526b672/fonts/webfonts/ArchivoSemiCondensed-SemiBold.woff2"; url = "https://github.com/Omnibus-Type/Archivo/raw/b5d63988ce19d044d3e10362de730af00526b672/fonts/webfonts/ArchivoSemiCondensed-SemiBold.woff2";
hash = "sha256-fOE+b+UeTRoj+sDdUWR1pPCZVn0ABy6FEDDmXrOA4LY="; hash = "sha256-fOE+b+UeTRoj+sDdUWR1pPCZVn0ABy6FEDDmXrOA4LY=";
}; };
vt323 = fetchurl {
url = "https://github.com/google/fonts/raw/c781e48f571fe26740a9814c0461064628cbd175/ofl/vt323/VT323-Regular.ttf";
hash = "sha256-z03nUa2njOrAM9vhamh3QpOZlbd7wqBSrheklXlYWU0=";
};
in in
runCommand "" { } '' runCommand "" { } ''
mkdir -p $out mkdir -p $out
cp ${archivoRegular} $out/ArchivoSemiCondensed-Regular.woff2 cp ${archivoRegular} $out/ArchivoSemiCondensed-Regular.woff2
cp ${archivoMedium} $out/ArchivoSemiCondensed-Medium.woff2 cp ${archivoMedium} $out/ArchivoSemiCondensed-Medium.woff2
cp ${archivoSemiBold} $out/ArchivoSemiCondensed-SemiBold.woff2 cp ${archivoSemiBold} $out/ArchivoSemiCondensed-SemiBold.woff2
cp ${vt323} $out/VT323-Regular.ttf
'' ''

View File

@@ -0,0 +1,10 @@
textarea {
@apply flex w-full;
@apply border rounded-md p-2;
@apply text-xs;
color: var(--clr-fg-inv-3);
background-color: var(--clr-bg-inv-5);
font-family: "VT323", monospace;
}

View File

@@ -0,0 +1,19 @@
import type { Meta, StoryObj } from "@kachurun/storybook-solid";
import Terminal, { TerminalProps } from "./Terminal";
import sample from "./sample";
const meta: Meta<TerminalProps> = {
title: "Components/Terminal",
component: Terminal,
};
export default meta;
type Story = StoryObj<TerminalProps>;
export const Default: Story = {
args: {
lines: sample.split("\n"),
},
};

View File

@@ -0,0 +1,28 @@
import { Component, createEffect } from "solid-js";
import "./Terminal.css";
import { Typography } from "@/src/components/Typography";
export interface TerminalProps {
lines: string[];
rows?: number;
}
const Terminal: Component<TerminalProps> = ({ lines, rows = 20 }) => {
let ref: HTMLTextAreaElement | undefined;
createEffect(() => {
// always scroll to the end of the output when it changes
if (ref) {
ref.scrollTop = ref.scrollHeight;
}
});
const value = lines.join("\n");
return (
<textarea ref={ref} readOnly={true} rows={rows} value={value}></textarea>
);
};
export default Terminal;

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@ import "./css/typography.css";
export type Hierarchy = "body" | "title" | "headline" | "label"; export type Hierarchy = "body" | "title" | "headline" | "label";
type Color = "primary" | "secondary" | "tertiary"; type Color = "primary" | "secondary" | "tertiary";
type Weight = "normal" | "medium" | "bold"; type Weight = "normal" | "medium" | "bold";
type Tag = "span" | "p" | "h1" | "h2" | "h3" | "h4" | "div"; type Tag = "span" | "p" | "h1" | "h2" | "h3" | "h4" | "div" | "textarea";
const colorMap: Record<Color, string> = { const colorMap: Record<Color, string> = {
primary: cx("fnt-clr-primary"), primary: cx("fnt-clr-primary"),

View File

@@ -24,6 +24,12 @@
src: url(../.fonts/ArchivoSemiCondensed-SemiBold.woff2) format("woff2"); src: url(../.fonts/ArchivoSemiCondensed-SemiBold.woff2) format("woff2");
} }
@font-face {
font-family: "VT323";
font-weight: normal;
src: url("../.fonts/VT323-Regular.ttf") format("ttf");
}
@keyframes slide { @keyframes slide {
to { to {
background-position: 200% 0; background-position: 200% 0;