1.1.1 • Published 2 years ago

react-shell-color v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-shell-color

Javascript parse ANSI escape code and render in React, Recode with typescript

style

Install

npm install --save react-shell-color

Component

Common parameters

import React from 'react';
import ReactShellColor from 'react-shell-color';

export default () => <ReactShellColor text="\x1b[30m black\n\x1b[m\x1b[31m red\nend" />;

React Hooks

import { useShellColor } from 'react-shell-color';

export default function ReactShellColor(props: { text: string }) {
  const { tags, shellColor } = useShellColor(props.text);
  return <>{tags}</>;
}

Shell Color Usage For DOM

import {SGRStyle} from "react-shell-color";

sc.on('snippet', function (tag: React.Node, text: string, style: SGRStyle) {
  cosnt domTag = document.createElement('span');
  domTag.style = Object.assign(style, domTag.style);
  domTag.innerText = text;
  document.body.appendChild(domTag)
})

Other Usage:

ChangeLog

  • 1.1.0 performance optimize
  • 1.0.0 init project
1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago