1.0.3 • Published 4 years ago

boks v1.0.3

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
4 years ago

boks

Build Status Coverage Status codecov npm npm NPM GitHub repo size

Border or boxes that can be used to wrap text.

Similar to cli-boxes but includes:

  • Abitilty to have different top, bottom, left and right borders.
  • Ability to have intersections +.
  • Attempt to discover intersection and corner types based on provided values.

Install

npm install boks

Usage

const boks = require('boks');

console.log(boks.templates.single);
/*
┌─┬─┐
│ │ │
├─┼─┤
│ │ │
└─┴─┘
*/
// OR

const options = {
	horizontal: borders.HorizontalLines.line,
	vertical: borders.VerticalLines.double,
};

console.log(boks.getBorder(options));
/*
 ╓─╥─╖
 ║ ║ ║
 ╟─╫─╢
 ║ ║ ║
 ╙─╨─╜
*/

Exposed functions

  • getBorder: build the borders from an options object (or an array of options objects).
  • fixMultiple: Fix missing borders based on an array of option object.
  • fixBorders: Fix missing borders based on a options object.
  • fixCorners: Only fix the missing corner values of an outside border.
  • fixIntersections: fix Intersection values (+) based on values of surrounding border types.

Standard templates available

  • empty: no borders;
  • single: single lined borders;
  • round: single lined with rounded corner borders;
  • double: double lined borders;
  • singleDouble: single horizontal lines, double vertical lines;
  • doubleSingle: double horizontal lines, single vertical lines;
  • boldSingle: bold horizontal lines, single vertical lines;
  • singleBold: single horizontal lines, bold vertical lines;

Options

Options are passed as an object and can have the following properties:

propertytypedescription
horizontalborders.HorizontalLinesThe value to use for all horizontal lines.
Verticalborders.VerticalLinesThe value to use for all vertical lines.
topLeftborders.TopLeftBorder | borders.Verticallines | borders.HorizontalLines | borders.LeftIntersect | falseThe value of the topleft corner. If false, no corner will be added or discovered.
topRightborders.TopRightBorder | borders.Verticallines | borders.HorizontalLines | borders.RightIntersect | falseThe value of the topRight corner. If false, no corner will be added or discovered.
bottomLeftborders.BottomLeftBorder | borders.Verticallines | borders.HorizontalLines | borders.LeftIntersect | falseThe value of the bottomLeft corner. If false, no corner will be added or discovered.
bottomRightborders.BottomRightBorder | borders.Verticallines | borders.HorizontalLines | borders.RightIntersect | falseThe valui of the bottom Right corner. If false, no corner will be added or discovered.
topIntersectborders.TopIntersect | borders.Verticallines | borders.HorizontalLines | borders.IntersectThe value of the top Intersection part (i.e. between 2 columns top).
bottomintersectborders.BottomIntersect | borders.Verticallines | borders.HorizontalLines | borders.IntersectThe value of the bottom Intersection part (i.e. between 2 columns bottom).
leftIntersectborders.LeftIntersect | borders.HorizontalLines | borders.VerticalLinesThe value of the left border of the right column.
rightIntersectborders.RightIntersect | borders.HorizontalLines | borders.VerticalLinesThe value of the right border of the left column.
intersectborders.Intersect | borders.VerticalLines | borders.HorizontalLinesThe value of the column intersections (+).
extendFromBorderTypesThe base to extend the border value from.
strictbooleanIf set to true, will not inherit from any but will strictly use explicitly set values. (i.e. will not use 'extendFrom' but only values entered above).
buildTableBordersbooleanIf true and used with strict option the table will outomatically be built. Values to build from will be horizontal and vertical and may include: top right, bottom and left values if provided.
keepBorderSpacebooleanIf true and if no Horizontal or Vertical Lines has been selected a space will be included as border spacing.

Please note

Not all border types have corresponding intersection types and the best solution is sought.

Contributions

Any contributions are welcome.

Patches

  • 1.0.1
    • update the node version from >=8.5.0 to >=10.0.0.