Skip to content

Commit

Permalink
docs(shape): Update doc-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Mar 30, 2016
1 parent e7610e0 commit 1c38250
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/Text.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
import Shape from 'kittik-shape-basic';

/**
* Implements Text shape which is rendering the text at specified point.
* Supports different styles kinda bold, dim, underlined, etc...
* Implements Text shape which renders the text at specified point.
*
* @since 1.0.0
* @extends {Shape}
*/
export default class Text extends Shape {
/**
* Create Text shape.
*
* @constructor
* @param {Cursor} cursor Cursor instance
* @param {Object} [options]
* @param {Boolean} [options.bold]
* @param {Boolean} [options.dim]
* @param {Boolean} [options.underlined]
* @param {Boolean} [options.blink]
* @param {Boolean} [options.reverse]
* @param {Boolean} [options.hidden]
* @param {String} [options.align]
* @param {Object} [options] Options object
* @param {Boolean} [options.bold] Bold styling
* @param {Boolean} [options.dim] Dim styling
* @param {Boolean} [options.underlined] Underlined styling
* @param {Boolean} [options.blink] Blink styling
* @param {Boolean} [options.reverse] Reverse styling
* @param {Boolean} [options.hidden] Hidden styling
* @param {String} [options.align] Align text in the shape (left, center, right)
* @example
* Text.create(cursor, {
* bold: true,
* dim: false,
* underlined: true,
* blink: false,
* reverse: false,
* hidden: false,
* align: 'center'
* });
*/
constructor(cursor, options = {}) {
super(cursor, options);
Expand All @@ -35,7 +45,10 @@ export default class Text extends Shape {

/**
* Returns actual width of the shape.
* Since text hasn't specified width, we need to override default.
* It looks for the longest line in your shape and returns its length.
*
* @override
* @returns {Number}
*/
getWidth() {
Expand All @@ -45,7 +58,10 @@ export default class Text extends Shape {

/**
* Returns actual height of the shape.
* Since text hasn't specified height, we need to override default.
* It returns count of lines in our shape.
*
* @override
* @returns {Number}
*/
getHeight() {
Expand All @@ -65,7 +81,7 @@ export default class Text extends Shape {
* Toggle bold mode.
*
* @param {Boolean} [bold=false] If true, print bold text
* @returns {Shape}
* @returns {Text}
*/
setBold(bold = false) {
return this.set('bold', bold);
Expand All @@ -84,7 +100,7 @@ export default class Text extends Shape {
* Toggle dim mode.
*
* @param {Boolean} [dim=false] If true, print dim text
* @returns {Shape}
* @returns {Text}
*/
setDim(dim = false) {
return this.set('dim', dim);
Expand All @@ -103,7 +119,7 @@ export default class Text extends Shape {
* Toggle underlined mode.
*
* @param {Boolean} [underlined=false] If true, print underlined text
* @returns {Shape}
* @returns {Text}
*/
setUnderlined(underlined = false) {
return this.set('underlined', underlined);
Expand All @@ -122,7 +138,7 @@ export default class Text extends Shape {
* Toggle blink mode.
*
* @param {Boolean} [blink=false] If true, print blink text
* @returns {Shape}
* @returns {Text}
*/
setBlink(blink = false) {
return this.set('blink', blink);
Expand All @@ -141,7 +157,7 @@ export default class Text extends Shape {
* Toggle reverse mode.
*
* @param {Boolean} [reverse=false] If true, print text with reversed colors
* @returns {Shape}
* @returns {Text}
*/
setReverse(reverse = false) {
return this.set('reverse', reverse);
Expand All @@ -160,7 +176,7 @@ export default class Text extends Shape {
* Toggle hidden mode.
*
* @param {Boolean} [hidden=false] If true, print hidden text
* @returns {Shape}
* @returns {Text}
*/
setHidden(hidden = false) {
return this.set('hidden', hidden);
Expand All @@ -177,9 +193,10 @@ export default class Text extends Shape {

/**
* Set text align.
* Aligns text in the shape by anchors to the left, center or to the right.
*
* @param {String} align
* @returns {Shape}
* @param {String} [align='center'] Align value can be left, center or right
* @returns {Text}
*/
setAlign(align = 'center') {
if (['left', 'center', 'right'].indexOf(align) === -1) throw new Error(`Unknown align option: ${align}`);
Expand Down

0 comments on commit 1c38250

Please sign in to comment.