wip(ui): add a Terminal component
This commit is contained in:
@@ -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
|
||||||
''
|
''
|
||||||
|
|||||||
10
pkgs/clan-app/ui/src/components/Terminal/Terminal.css
Normal file
10
pkgs/clan-app/ui/src/components/Terminal/Terminal.css
Normal 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;
|
||||||
|
}
|
||||||
@@ -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"),
|
||||||
|
},
|
||||||
|
};
|
||||||
28
pkgs/clan-app/ui/src/components/Terminal/Terminal.tsx
Normal file
28
pkgs/clan-app/ui/src/components/Terminal/Terminal.tsx
Normal 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;
|
||||||
1451
pkgs/clan-app/ui/src/components/Terminal/sample.ts
Normal file
1451
pkgs/clan-app/ui/src/components/Terminal/sample.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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"),
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user