Skip to content

Commit 3a23ef8

Browse files
committed
feat(shape): Add accessors for align
1 parent 2b6c92a commit 3a23ef8

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

examples/Text.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Cursor = require('kittik-cursor').Cursor;
44
const Shape = require('../lib/Basic').default;
55
const cursor = new Cursor().resetTTY();
66

7+
// Create class that extends from Shape and implement render() method
78
class Text extends Shape {
89
render(cursor) {
910
const text = this.getText();

src/Basic.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,35 @@ export default class Shape {
194194
return this;
195195
}
196196

197+
/**
198+
* Get align property from this shape.
199+
*
200+
* @returns {String}
201+
*/
202+
getAlign() {
203+
return this.get('align');
204+
}
205+
206+
/**
207+
* Set align to this shape.
208+
*
209+
* @param {String} align
210+
* @returns {Shape}
211+
*/
212+
setAlign(align) {
213+
this.set('align', align);
214+
return this;
215+
}
216+
217+
/**
218+
* Check if this shape must be aligned.
219+
*
220+
* @returns {Boolean}
221+
*/
222+
isAligned() {
223+
return !!this.get('align');
224+
}
225+
197226
/**
198227
* Get animation options from this shape.
199228
*

0 commit comments

Comments
 (0)