import * as React from "react"; import styled from "@emotion/styled"; import { Cursor } from "./Cursor.js"; import { Word } from "./Word.js"; import { Attributes } from "load-asciicast"; import { RGBTuple } from "./default-theme.js"; export interface RegistryWord { attr: Attributes; x: number; children: string; offset: number; } export interface RegistryItem { type: "line" | string; id: string | number; words: RegistryWord[]; } export interface RegistryProps { items: RegistryItem[]; theme: { fontSize: number; lineHeight: number; cursor: RGBTuple; }; hasFrames: boolean; frameHeight: number; frameWidth: number; hasCursors: boolean; } export const Registry: React.FunctionComponent = props => { return ( {props.items.map(item => { switch (item.type) { case "line": return ; default: throw new TypeError(`Unknown Registry item of type ${item.type}`); } })} {props.hasFrames && [ , props.hasCursors && ( ) ]} ); }; export interface LineWordProps { attr: { inverse?: boolean; bg?: boolean; bold?: boolean; underline?: boolean; fg?: number | string; }; children: string; x: number; // y: number; // theme: { // lineHeight: number; // }; } export interface LineSymbolProps { id: string | number; words: LineWordProps[]; theme: { fontSize: number; lineHeight: number; }; } const LineSymbol: React.FunctionComponent = props => { return ( {props.words.map((word, index) => ( {word.children} ))} ); }; const StyledBackground = styled.rect` fill: transparent; `;