• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Stylish console.log for node

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

More Repositories

1

pretty-error

See node.js errors with less clutter
CoffeeScript
1,522
star
2

Griddify

A tiny Photoshop panel to make guides and grids
CoffeeScript
487
star
3

shapely

A simple runtime type checker for javascript supporting records and tagged unions
JavaScript
40
star
4

photoshopjs-core

(work in progress)
CoffeeScript
21
star
5

pretty-monitor

Clutter-less monitor for unhandled when.js rejections
CoffeeScript
20
star
6

photoshopjs-panel

(work in progress)
CoffeeScript
8
star
7

timing-function

Easing functions and bezier curves for animation
CoffeeScript
8
star
8

mocha-pretty-spec-reporter

Mocha's spec reporter without the messy stack traces
JavaScript
6
star
9

dom-converter

CoffeeScript
6
star
10

Foxie

(work in progress)
CoffeeScript
5
star
11

Yatta

Little tool I use to introduce creative coding to first-time programmers.
JavaScript
5
star
12

utila

notareplacementforundersocre
CoffeeScript
5
star
13

theatrejs-data-server

The node module that saves animation data for theatrejs
JavaScript
4
star
14

theatre-demo-orb

Created with CodeSandbox
JavaScript
3
star
15

FastTouchAndDomExperiments

Experiments to get fast touch interactions and light dom manipulations in less capable environments, mostly mobile.
JavaScript
3
star
16

photoshopjs-com

(work in progress)
CoffeeScript
2
star
17

theatre-example-bouncing-box

Basic animation practice in Theatre.js
TypeScript
2
star
18

css-color

(work in progress)
CoffeeScript
2
star
19

css-filter

(work in progress)
CoffeeScript
2
star
20

dee

(work in progress)
CoffeeScript
2
star
21

gila

Experimental thin OOP wrapper for WebGL
CoffeeScript
2
star
22

kilid

(work in progress)
CoffeeScript
2
star
23

minimal-theatre-state-server

TypeScript
2
star
24

audio-driven-time-control

(work in progress)
CoffeeScript
2
star
25

moosh

(work in progress)
CoffeeScript
2
star
26

raf-timing

Timing api for high-perf animations (Expetimental)
CoffeeScript
2
star
27

pantomime

(work in progress)
CoffeeScript
1
star
28

timeflow-pg

(experimental playground for a TimeFlow Stage)
CoffeeScript
1
star
29

compose-classes

A small utility function to make react components that use css modules to have extensible styles.
TypeScript
1
star
30

glsl-playground

(work in progress)
CoffeeScript
1
star
31

options-to-index

(work in progress)
CoffeeScript
1
star
32

group-act

(work in progress)
CoffeeScript
1
star
33

esterakt

(work in progress)
CoffeeScript
1
star
34

vscode-jump-to-counterpart

Jump between .css/.js files with a keyboard shortcut, or define your own pairs of counterparts.
TypeScript
1
star
35

theatrejs-bezierpacs

(work in progress)
CoffeeScript
1
star
36

tiny-filmmaking-studio

(work in progress)
CoffeeScript
1
star
37

black-sugar

(work in progress)
CoffeeScript
1
star
38

yatta-gl

Yatta in WebGL
CoffeeScript
1
star