3.0.0 • Published 4 years ago

renderkid v3.0.0

Weekly downloads
7,301,559
License
MIT
Repository
github
Last release
4 years ago

RenderKid

Build Status

RenderKid allows you to use HTML and CSS to style your CLI output, making it easy to create a beautiful, readable, and consistent look for your nodejs tool.

Installation

Install with npm:

$ npm install renderkid

Usage

RenderKid = require('renderkid')

r = new RenderKid()

r.style({
  "ul": {
    display: "block"
    margin: "2 0 2"
  }

  "li": {
    display: "block"
    marginBottom: "1"
  }

  "key": {
    color: "grey"
    marginRight: "1"
  }

  "value": {
    color: "bright-white"
  }
})

output = r.render("
<ul>
  <li>
    <key>Name:</key>
    <value>RenderKid</value>
  </li>
  <li>
    <key>Version:</key>
    <value>0.2</value>
  </li>
  <li>
    <key>Last Update:</key>
    <value>Jan 2015</value>
  </li>
</ul>
")

console.log(output)

screenshot of usage

Stylesheet properties

Display mode

Elements can have a display of either inline, block, or none:

r.style({
  "div": {
    display: "block"
  }

  "span": {
    display: "inline" # default
  }

  "hidden": {
    display: "none"
  }
})

output = r.render("
<div>This will fill one or more rows.</div>
<span>These</span> <span>will</span> <span>be</span> in the same <span>line.</span>
<hidden>This won't be displayed.</hidden>
")

console.log(output)

screenshot of usage

Margin

Margins work just like they do in browsers:

r.style({
  "li": {
    display: "block"

    marginTop: "1"
    marginRight: "2"
    marginBottom: "3"
    marginLeft: "4"

    # or the shorthand version:
    "margin": "1 2 3 4"
  },

  "highlight": {
    display: "inline"
    marginLeft: "2"
    marginRight: "2"
  }
})

r.render("
<ul>
  <li>Item <highlgiht>1</highlight></li>
  <li>Item <highlgiht>2</highlight></li>
  <li>Item <highlgiht>3</highlight></li>
</ul>
")

Padding

See margins above. Paddings work the same way, only inward.

Width and Height

Block elements can have explicit width and height:

r.style({
  "box": {
    display: "block"
    "width": "4"
    "height": "2"
  }
})

r.render("<box>This is a box and some of its text will be truncated.</box>")

Colors

You can set a custom color and background color for each element:

r.style({
  "error": {
    color: "black"
    background: "red"
  }
})

List of colors currently supported are black, red, green, yellow, blue, magenta, cyan, white, grey, bright-red, bright-green, bright-yellow, bright-blue, bright-magenta, bright-cyan, bright-white.

Bullet points

Block elements can have bullet points on their margins. Let's start with an example:

r.style({
  "li": {
    # To add bullet points to an element, first you
    # should make some room for the bullet point by
    # giving your element some margin to the left:
    marginLeft: "4",

    # Now we can add a bullet point to our margin:
    bullet: '"-"'
  }
})

# The four hyphens are there for visual reference
r.render("
----
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
----
")

And here is the result:

screenshot of bullet points, 1

pretty-errorcomponennenttvuedragdropuploadimagesbb-chat@l1nyanm1ng/react-picture-viewercthpb-plugin-social@infinitebrahmanuniverse/nolb-renbonny-cli-renderer@saaspe/componentssklif-ui-kitsklif-api@everything-registry/sub-chunk-2650p149-tablesklif-uivue-button-test1webpack_component_fundstories-fssvelte-component-libvue-compment@dimcheify/dimui@blkmarketco/components-library@beldore/react-otp-inputcustom-react-app1custom-react-app2jfs-corejesusdemojulien-easy-modalkikdkafirchain-tetrisk0ng_d1nosaur_quenak0ng_d1nosaur_quenbk0ng_d1nosaur_quenck0ng_d1nosaur_quendk0ng_d1nosaur_quenek0ng_d1nosaur_quenfk0ng_d1nosaur_quengk0ng_d1nosaur_quenhk0ng_d1nosaur_quenik0ng_d1nosaur_quenjk0ng_d1nosaur_quenkk0ng_d1nosaur_quennk0ng_d1nosaur_quenok0ng_d1nosaur_quenpk0ng_d1nosaur_quenqk0ng_d1nosaur_quenrk0ng_d1nosaur_quenlk0ng_d1nosaur_quenmk0ng_d1nosaur_quensk0ng_d1nosaur_quentk0ng_d1nosaur_quenuk0ng_d1nosaur_quenvk0ng_d1nosaur_quenwk0ng_d1nosaur_quenxk0ng_d1nosaur_quenyk0ng_d1nosaur_quenzlanj-test-componentsstyled-errorstyle-guide-mainspacex_cycl3_roamospacex_cycl3_roampspacex_cycl3_roamqspacex_cycl3_roamrspacex_cycl3_roamsspacex_cycl3_roamtspacex_cycl3_roamuspacex_cycl3_roamvspacex_cycl3_roamwspacex_cycl3_roamxspacex_cycl3_roamyspacex_cycl3_roamzspacex_j4vaa_c3qmspacex_j4vad_c3qmspacex_j4vae_c3qmspacex_j4vaf_c3qmspacex_j4vag_c3qmspacex_j4vah_c3qmspacex_j4vai_c3qmspacex_j4vaj_c3qmspacex_j4vajk_c3qmspacex_j4vajl_c3qmspacex_java_c3qcspacex_java_c3qdspacex_java_c3qespacex_java_c3qfspacex_java_c3qgspacex_java_c3qhspacex_java_c3qispacex_java_c3qjspacex_java_c3qkspacex_java_c3qlspacex_java_c3qmspacex_java_c3qnspacex_java_c3qospacex_java_c3qpspacex_java_c3qrspacex_java_c3qsspacex_java_c3qtspacex_java_c3quspacex_java_c3qvspacex_java_c3qw
3.0.0

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.7-dev.1

4 years ago

2.0.7-dev.2

4 years ago

2.0.5

4 years ago

2.0.4

5 years ago

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.0.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.2.0-beta.12

10 years ago

0.2.0-beta.11

10 years ago

0.2.0-beta.10

11 years ago

0.2.0-beta.9

11 years ago

0.2.0-beta.8

11 years ago

0.2.0-beta.7

11 years ago

0.2.0-beta.6

11 years ago

0.2.0-beta.5

11 years ago

0.2.0-beta.4

11 years ago

0.2.0-beta3

11 years ago

0.2.0-beta2

11 years ago

0.2.0-beta1

11 years ago