3.4.8-beta0 • Published 9 days ago

minitel-react v3.4.8-beta0

Weekly downloads
-
License
Hippocratic-2.1
Repository
github
Last release
9 days ago

Minitel React

A (somewhat experimental! also somewhat opiniated) package to render react into a minitel!

Experimental until v4.2.0, thanks for understanding!

npm.io

Principle

This package interacts with a stream which is supposed to be relayed to the Minitel. The duplex stream could come from, for instance, a serial handler.

Example

import { SerialPort } from 'serialport';
import { render, Minitel } from 'minitel-react';

const serialport = new SerialPort({ path: '/dev/ttyUSB0', baudRate: 1200, parity: 'even' });

function App() {
    return (
        <yjoin widthAlign="middle" heightAlign="middle">
            <para invert>
                Hello world!
            </para>
        </yjoin>
    );
}

render(<App/>, new Minitel(serialport));

Also: an example with websockets, miedit minitel (You may need to clone miedit into miedit/ first), inside the dist/examples folder

Reference

CharAttributes

AttributeTypeDefaultDescription
fgnumber7The foreground color to be used
bgnumber0The background color to be used
underlinebooleanfalseWhether to underline or not
sizeCodenumber0The size code to be used
noBlinkbooleantrueWhether to not blink or to blink
invertbooleantrueWhether to invert or not
doubleWidthbooleantrueWhether to use double width or not
doubleHeightbooleantrueWhether to use double height or not

On colors

Color codeColorBrightness
0Black0%
1Red50%
2Green70%
3Yellow90%
4Blue40%
5Magenta60%
6Cyan80%
7White100%

MinitelObjectAttributes

AttributeTypeDescription
All from CharAttributesCharAttributes[k]The properties to pass to the underlying characters. doubleWidth, doubleHeight won't apply for fillChars
fillCharstringThe character to fill holes with (can be useful for transparency)
widthnumberThe desired width of the element
heightnumberThe desired height of the element
wrapstringThe behaviour of text overflowing
textAlignstringThe way text should be aligned (start, middle, or end)
flexGrowboolean or stringThe flexGrow factor to be applied (refer to CSS flex-grow)

new Minitel

Argument (in order)TypeDescription
streamDuplexThe duplex stream to communicate with the minitel
settingsSettingsThe setings to configure the minitel instance with

On Settings

ArgumentTypeDescription
statusBarbooleanWhether to consider the first line of the render as the status bar
localEchobooleanWhether to keep local echo (écho local) enabled

<vjoin>

Will vertically join all children |Attribute |Type |Description | |---------------------|----------------------|-----------------------------------------------------------------| |gap |number or string |The amount of gap to be had. Can be a number or space-{between,around,evenly} (refer to flexbox's justify-center)| |widthAlign |string |The way to align along the x axis (start, middle, end or stretch)| |heightAlign |string |The way to align along the y axis (start, middle or end) |

<hjoin>

Will horizontally join all children |Attribute |Type |Description | |---------------------|----------------------|-----------------------------------------------------------------| |gap |number or string |The amount of gap to be had. Can be a number or space-{between,around,evenly} (refer to flex's justify-center)| |heightAlign |string |The way to align along the y axis (start, middle, end or stretch)| |widthAlign |string |The way to align along the x axis (start, middle or end) |

<input>

Will be an input |Attribute |Type |Description | |---------------------|----------------------|-----------------------------------------------------------------| |autofocus |boolean |Whether or not to autofocus on the input | |type |string |The type of input (for now, text or password) |

<para>

Will show text

<scroll>

Will allow scrolling (the element needs to be focused to be scrolled upon)

Attributes

AttributeTypeDescription
overflowX'scroll' \| 'pad' \| 'auto' \| 'hidden'Horizontal overflow behavior: 'scroll' for scrollbar, 'pad' for padding, 'auto' for automatic, 'hidden' for hidden overflow.
overflowY'scroll' \| 'pad' \| 'auto' \| 'hidden'Vertical overflow behavior: 'scroll' for scrollbar, 'pad' for padding, 'auto' for automatic, 'hidden' for hidden overflow.
autofocusfalseWhether autofocus is enabled for the scrollable area.
scrollbarColornumberThe color code for the scrollbar.
scrollbarBackColornumberThe color code for the scrollbar background.
blinkPeriodnumberThe blinking period for the scrollbar (in milliseconds).

auto will hide the scrollbar when possible scroll and pad only differ in the case that the children already fit in the imposed area: scroll will show the scrollbar anyway, while pad will leave this space empty

<cont>

Will hold one child.

Attributes

AttributeTypeDescription
widthAlignAlignThe alignment of child elements along the horizontal axis (start, middle, end, or stretch).
heightAlignAlignThe alignment of child elements along the vertical axis (start, middle, end, or stretch).

<zjoin>

Will allow stacking of one element onto another. The character \x09 will order zjoin to show the character underneath.

Attributes

AttributeTypeDescription
widthAlignAlignThe alignment of child elements along the horizontal axis (start, middle, end, or stretch).
heightAlignAlignThe alignment of child elements along the vertical axis (start, middle, end, or stretch).
inheritTransparencybooleanWhether child elements should have fillChar set to \x09 by default
3.4.8-beta0

9 days ago

3.4.7

24 days ago

3.4.6

24 days ago

3.4.5

25 days ago

3.4.0

25 days ago

3.3.1

25 days ago

3.4.4

25 days ago

3.4.3

25 days ago

3.4.2

25 days ago

3.3.3

25 days ago

3.4.1

25 days ago

3.3.2

25 days ago

2.0.0

28 days ago

3.1.3

27 days ago

3.0.4

27 days ago

3.3.0

26 days ago

3.2.1

27 days ago

3.1.2

27 days ago

3.0.3

27 days ago

3.2.0

27 days ago

3.1.1

27 days ago

3.0.2

27 days ago

3.1.0

27 days ago

3.0.1

27 days ago

3.2.4

27 days ago

3.2.3

27 days ago

3.0.5

27 days ago

3.0.0

27 days ago

1.2.0

29 days ago

1.1.1

29 days ago

1.1.0

29 days ago

1.2.3

29 days ago

1.3.1

29 days ago

1.2.2

29 days ago

1.3.0

29 days ago

1.2.1

29 days ago

1.1.2

29 days ago

1.0.2

1 month ago

1.0.1

1 month ago

1.0.0

1 month ago