@caocong/react-hexviewer-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.10 • Public • Published

React Hex Viewer Ts

A component is a minor reworking and rethinking of a component react-hexviewer (thanks tperson) in the typescript

Screenshot

Example

import React from 'react';
import {HexViewer} from 'react-hex-viewer-ts';
// data is Buffer | number[] | base64 | hex
React.render(
    <HexViewer>{data}</HexViewer>, 
    document.body);

The component has props interface HexViewerProps.

export interface HexViewerProps {
  /** number of bytes per row */
  rowLength?: number;
  /** number of bytes between a visible split */
  setLength?: number;
  /** Buffer | number[] | string as base64 or raw hex */
  children: string | Buffer | number[];
  /** sign that the data is hex */
  hex?: boolean;
  /** sign that the data is base64 */
  base64?: boolean;
  /** Component that will be displayed if there is no data */
  noData?: ReactNode;
  /** Component that will be displayed if data parsing is unsuccessful */
  errorData?: ReactNode;
}

Styling

In your projects, you can import less or scss styling from a package

Less

@import '../node_modules/react-hexviewer-ts/less/variables.less'; // for some reason ~react-hexviewer-ts does't work properly
@hex-color: rgb(189, 189, 189); // you can redefine variables from variables.less
@import '~react-hexviewer-ts/less/hex-viewer.less';

Sass

$hex-color: rgb(189, 189, 189); // you can redefine variables from variables.scss
@import '~react-hexviewer-ts/scss/hex-viewer.scss';

Storybook demo

Demo link

Comments are welcome

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.101latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.101

Package Sidebar

Install

npm i @caocong/react-hexviewer-ts

Weekly Downloads

1

Version

0.1.10

License

MIT

Unpacked Size

24.6 kB

Total Files

24

Last publish

Collaborators

  • caocong