Skip to content

Commit

Permalink
feat(package): Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Dec 8, 2015
1 parent aa2b5d6 commit 9856348
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ notifications:
email: true
node_js:
- stable
- 4
before_script:
- npm prune
after_success:
Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
![Build Status](https://img.shields.io/travis/kittikjs/kittik.svg)
![Coverage](https://img.shields.io/coveralls/kittikjs/kittik.svg)

![Downloads](https://img.shields.io/npm/dm/@kittikjs/kittik.svg)
![Downloads](https://img.shields.io/npm/dt/@kittikjs/kittik.svg)
![npm version](https://img.shields.io/npm/v/@kittikjs/kittik.svg)
![License](https://img.shields.io/npm/l/@kittikjs/kittik.svg)
![Downloads](https://img.shields.io/npm/dm/kittik.svg)
![Downloads](https://img.shields.io/npm/dt/kittik.svg)
![npm version](https://img.shields.io/npm/v/kittik.svg)
![License](https://img.shields.io/npm/l/kittik.svg)

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
Expand All @@ -18,13 +18,7 @@
Install it via npm:

```shell
npm install -g kittik
```

Start your presentation:

```shell
kittik start my_presentation.json
npm install kittik
```

## License
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
"test": "babel-node ./node_modules/.bin/isparta cover _mocha"
},
"dependencies": {
"charm": "1.0.0",
"commander": "2.9.0",
"keypress": "0.2.1",
"kittik-animation-print": "1.0.0",
"kittik-animation-print": "1.1.0",
"kittik-cursor": "1.0.2",
"kittik-shape-rectangle": "1.0.2",
"kittik-shape-text": "1.0.2"
Expand All @@ -54,7 +52,7 @@
}
},
"publishConfig": {
"tag": "next"
"tag": "latest"
},
"release": {
"branch": "master"
Expand Down
21 changes: 13 additions & 8 deletions src/Presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Slide } from './Slide';
* @version 1.0.0
*/
export class Presentation {
_cursor = Cursor.create([new Print().enable(), process.stdout], [process.stdin]).reset().hide();
_cursor = Cursor.create([new Print().enable().setRandom(false), process.stdout], [process.stdin]).reset().hide();
_currentSlideIndex = 0;
_slides = [];

Expand Down Expand Up @@ -47,8 +47,11 @@ export class Presentation {
* @returns {Presentation}
*/
renderSlide(index = this._currentSlideIndex) {
if (!this._slides[index]) return this;

this._cursor.reset().hide();
if (this._slides[index]) this._slides[index].render(this._cursor);
this._slides[index].render(this._cursor);

return this;
}

Expand All @@ -58,8 +61,9 @@ export class Presentation {
* @returns {Presentation}
*/
nextSlide() {
this._currentSlideIndex = this._currentSlideIndex + 1 > this._slides.length - 1 ? this._slides.length - 1 : this._currentSlideIndex + 1;
this.renderSlide(this._currentSlideIndex);
if (this._currentSlideIndex + 1 > this._slides.length - 1) return this;

this.renderSlide(++this._currentSlideIndex);
return this;
}

Expand All @@ -69,17 +73,18 @@ export class Presentation {
* @returns {Presentation}
*/
prevSlide() {
this._currentSlideIndex = this._currentSlideIndex - 1 < 0 ? 0 : this._currentSlideIndex - 1;
this.renderSlide(this._currentSlideIndex);
if (this._currentSlideIndex - 1 < 0) return this;

this.renderSlide(--this._currentSlideIndex);
return this;
}

/**
* Closes the presentation and returns to terminal.
*/
exit() {
this._cursor.show().reset();
process.exit(0);
this._cursor.reset().show();
setTimeout(process.exit, 500);
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/Slide.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Rectangle from 'kittik-shape-rectangle';
import Text from 'kittik-shape-text';

const shapesManager = {
rectangle: Rectangle,
text: Text
};

/**
* Creates a new slide with shapes.
*
Expand Down Expand Up @@ -28,10 +33,7 @@ export class Slide {
* }]);
*/
constructor(shapes) {
this._shapes = shapes.map(shape => {
if (shape.name === 'Rectangle') return Rectangle.fromObject(shape);
if (shape.name === 'Text') return Text.fromObject(shape);
});
this._shapes = shapes.map(shape => shapesManager[shape.name.toLowerCase()].fromObject(shape));
}

/**
Expand Down

0 comments on commit 9856348

Please sign in to comment.