UNPKG

svg-term

Version:

Share terminal sessions via SVG and CSS

40 lines 2.09 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const React = __importStar(require("react")); const styled_1 = __importDefault(require("@emotion/styled")); const Cursor_1 = require("./Cursor"); const Word_1 = require("./Word"); exports.Registry = props => { return (React.createElement("defs", null, props.items.map(item => { switch (item.type) { case "line": return React.createElement(LineSymbol, Object.assign({ key: item.id, theme: props.theme }, item)); default: throw new TypeError(`Unknown Registry item of type ${item.type}`); } }), props.hasFrames && [ React.createElement("symbol", { id: "a", key: "a" }, React.createElement(StyledBackground, { height: props.frameHeight, width: props.frameWidth, x: "0", y: "0" })), props.hasCursors && (React.createElement("symbol", { id: "b", key: "b" }, React.createElement(Cursor_1.Cursor, { height: props.theme.fontSize * props.theme.lineHeight, fill: props.theme.cursor, width: props.theme.fontSize * 0.66 }))) ])); }; const LineSymbol = props => { return (React.createElement("symbol", { id: String(props.id) }, props.words.map((word, index) => (React.createElement(Word_1.Word, { bg: word.attr.bg, bold: word.attr.bold, fg: word.attr.fg, inverse: word.attr.inverse, key: index, theme: props.theme, underline: word.attr.underline, x: word.x, y: props.theme.fontSize }, word.children))))); }; const StyledBackground = styled_1.default.rect ` fill: transparent; `; //# sourceMappingURL=Registry.js.map