6.2.0 • Published 4 months ago

minitel-react v6.2.0

Weekly downloads
-
License
Hippocratic-2.1
Repository
github
Last release
4 months 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
refRefObjectThe ref which should store the underlying document. The relevant classes are in minitel-standalone (docs to be written)
textAlignstringThe way text should be aligned (start, middle, or end)
flexGrowboolean or numberThe flexGrow factor to be applied (refer to CSS flex-grow). true is interpreted as 1
visiblebooleanIf false, the element will only be displayed as a grid of its fillChars

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

<yjoin>

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) |

<xjoin>

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) | |multiline |boolean |Whether or not the input should be multiline | |onChange |function(value) |A function to be called whenever the input is changed | |onScroll |function([dy, dx]) |A function to be called whenever the input is scolled |

<para>

Will show text

<scroll>

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

Attributes

AttributeTypeDescription
overflowXstringHorizontal overflow behavior: refer to description under the table
overflowYstringVertical overflow behavior: refer to description under the table
autofocusfalseWhether autofocus is enabled for the scrollable area.
disabledbooleanWhether this element is unfocusable
scrollbarColornumberThe color code for the scrollbar.
scrollbarBackColornumberThe color code for the scrollbar background.
blinkPeriodnumberThe blinking period for the scrollbar (in milliseconds).
onScrollfunction([dy, dx])A function to be called whenever the scroll is scolled

noscrollbar will hide the scrollbar auto will hide the scrollbar except when the scrollable area exists (I.E. content does not fit) 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
6.1.0

4 months ago

6.1.2

4 months ago

6.1.1

4 months ago

6.2.0

4 months ago

6.0.0

4 months ago

5.3.2

10 months ago

5.3.1

10 months ago

5.3.0

10 months ago

5.4.2

9 months ago

5.4.1

10 months ago

5.4.0

10 months ago

5.0.3

10 months ago

5.0.2

10 months ago

5.0.1

10 months ago

5.0.0

10 months ago

5.1.7

10 months ago

5.1.6

10 months ago

5.1.5

10 months ago

5.1.4

10 months ago

5.1.3

10 months ago

5.1.2

10 months ago

5.1.1

10 months ago

5.1.0

10 months ago

4.2.0

11 months ago

5.2.1

10 months ago

5.2.0

10 months ago

3.14.11

1 year ago

3.14.12

1 year ago

3.14.13

1 year ago

3.14.14

1 year ago

3.14.15

1 year ago

3.14.10

1 year ago

3.9.3

1 year ago

3.13.1

1 year ago

3.9.2

1 year ago

3.9.1

1 year ago

3.9.0

1 year ago

3.10.1

1 year ago

3.10.0

1 year ago

3.10.3

1 year ago

3.12.0

1 year ago

3.10.2

1 year ago

4.0.5

12 months ago

4.0.4

12 months ago

4.0.6

12 months ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

1 year ago

4.0.2

1 year ago

3.14.9

1 year ago

3.14.1

1 year ago

3.14.0

1 year ago

3.14.3

1 year ago

3.14.2

1 year ago

3.14.5

1 year ago

3.14.4

1 year ago

3.14.7

1 year ago

3.14.6

1 year ago

3.11.0

1 year ago

4.1.0

12 months ago

4.1.2

12 months ago

4.1.1

12 months ago

3.8.0

1 year ago

3.8.1

1 year ago

3.7.0

1 year ago

3.5.3

1 year ago

3.6.1

1 year ago

3.5.2

1 year ago

3.6.0

1 year ago

3.5.1

1 year ago

3.5.0

1 year ago

3.4.8-beta0

1 year ago

3.4.7

1 year ago

3.4.6

1 year ago

3.4.5

1 year ago

3.4.0

1 year ago

3.3.1

1 year ago

3.4.4

1 year ago

3.4.3

1 year ago

3.4.2

1 year ago

3.3.3

1 year ago

3.4.1

1 year ago

3.3.2

1 year ago

2.0.0

1 year ago

3.1.3

1 year ago

3.0.4

1 year ago

3.3.0

1 year ago

3.2.1

1 year ago

3.1.2

1 year ago

3.0.3

1 year ago

3.2.0

1 year ago

3.1.1

1 year ago

3.0.2

1 year ago

3.1.0

1 year ago

3.0.1

1 year ago

3.2.4

1 year ago

3.2.3

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.2.3

1 year ago

1.3.1

1 year ago

1.2.2

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago