Comparing version 0.2.1 to 0.3.0
@@ -11,5 +11,3 @@ 'use strict'; | ||
const h = require('./lib/h'); | ||
const Newline = require('./lib/components/newline'); | ||
const Indent = require('./lib/components/indent'); | ||
const Group = require('./lib/components/group'); | ||
const Text = require('./lib/components/text'); | ||
@@ -20,5 +18,3 @@ | ||
exports.h = h; | ||
exports.Newline = Newline; | ||
exports.Indent = Indent; | ||
exports.Group = Group; | ||
exports.Text = Text; | ||
@@ -95,2 +91,3 @@ | ||
stdin.on('keypress', onKeyPress); | ||
stdout.on('resize', update); | ||
@@ -122,2 +119,3 @@ const consoleMethods = ['dir', 'log', 'info', 'warn', 'error']; | ||
stdin.pause(); | ||
stdout.removeListener('resize', update); | ||
@@ -124,0 +122,0 @@ isUnmounted = true; |
'use strict'; | ||
const arrify = require('arrify'); | ||
const chalk = require('chalk'); | ||
const StringComponent = require('../string-component'); | ||
const styles = [ | ||
'bold', | ||
'dim', | ||
'italic', | ||
'underline', | ||
'inverse', | ||
'strikethrough', | ||
'black', | ||
'red', | ||
'green', | ||
'yellow', | ||
'blue', | ||
'magenta', | ||
'cyan', | ||
'white', | ||
'gray', | ||
'bgBlack', | ||
'bgRed', | ||
'bgGreen', | ||
'bgYellow', | ||
'bgBlue', | ||
'bgMagenta', | ||
'bgCyan', | ||
'bgWhite' | ||
const methods = [ | ||
'hex', | ||
'hsl', | ||
'hsv', | ||
'hwb', | ||
'rgb', | ||
'keyword', | ||
'bgHex', | ||
'bgHsl', | ||
'bgHsv', | ||
'bgHwb', | ||
'bgRgb', | ||
'bgKeyword' | ||
]; | ||
@@ -34,5 +24,9 @@ | ||
renderString(children) { | ||
Object.keys(this.props).forEach(style => { | ||
if (this.props[style] === true && styles.includes(style)) { | ||
children = chalk[style](children); | ||
Object.keys(this.props).forEach(method => { | ||
if (this.props[method]) { | ||
if (methods.includes(method)) { | ||
children = chalk[method].apply(chalk, arrify(this.props[method]))(children); | ||
} else if (typeof chalk[method] === 'function') { | ||
children = chalk[method](children); | ||
} | ||
} | ||
@@ -39,0 +33,0 @@ }); |
'use strict'; | ||
const PropTypes = require('prop-types'); | ||
const flatten = require('lodash.flattendeep'); | ||
const arrify = require('arrify'); | ||
const Newline = require('./components/newline'); | ||
const Group = require('./components/group'); | ||
const Div = require('./components/div'); | ||
const Span = require('./components/span'); | ||
const Br = require('./components/br'); | ||
const transformProps = require('./transform-props'); | ||
@@ -29,5 +31,5 @@ const VNode = require('./vnode'); | ||
switch (name) { | ||
case 'div': return Group; | ||
case 'span': return Group; | ||
case 'br': return Newline; | ||
case 'div': return Div; | ||
case 'span': return Span; | ||
case 'br': return Br; | ||
default: return null; | ||
@@ -65,3 +67,3 @@ } | ||
set children(nextChildren) { | ||
this.vnode.children = arrify(nextChildren); | ||
this.vnode.children = flatten(arrify(nextChildren)); | ||
@@ -68,0 +70,0 @@ return nextChildren; |
{ | ||
"name": "ink", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "React for CLI", | ||
@@ -46,3 +46,4 @@ "license": "MIT", | ||
"devDependencies": { | ||
"ava": "^0.20.0", | ||
"ansi-styles": "^3.1.0", | ||
"ava": "^0.21.0", | ||
"babel-plugin-transform-react-jsx": "^6.24.1", | ||
@@ -49,0 +50,0 @@ "babel-register": "^6.24.1", |
@@ -68,2 +68,3 @@ <h1 align="center"> | ||
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Configurable component for rendering progress bars. | ||
- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner. | ||
@@ -463,3 +464,4 @@ | ||
Surprise, surprise, our favorite `<div>` and `<span>` can be used in Ink components! | ||
They contain zero functionality, but are useful for grouping elements, since JSX doesn't allow multiple elements without a parent. | ||
They are useful for grouping elements, since JSX doesn't allow multiple elements without a parent. | ||
The only difference between `<div>` and `<span>` is that `<div>` inserts a newline after children. | ||
@@ -466,0 +468,0 @@ This won't work: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28213
20
527
503
9