Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/design ui useable #38

Merged
merged 37 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4d12fd3
feat: ui improvement start
jinwoo-kim-nhn Jun 8, 2018
6bede58
feat: shape, draw menu Improved usability.
jinwoo-kim-nhn Jun 11, 2018
2e070e8
middle commit
jinwoo-kim-nhn Jun 11, 2018
a65c61b
add icon add with resize
Jun 11, 2018
9c9f738
icon useable resize icon
Jun 11, 2018
3cff2e4
complete icon menu useable
jinwoo-kim-nhn Jun 12, 2018
694ba62
middle commit
jinwoo-kim-nhn Jun 12, 2018
322a05b
middle commit2
Jun 12, 2018
d8d25f5
fixed middlecommit 3
Jun 12, 2018
59f5b5d
fixed bug all
Jun 13, 2018
504fe05
refactoring icon action
Jun 13, 2018
80b3045
feat: group selction style & action for ui usable
jinwoo-kim-nhn Jun 14, 2018
9aa3f67
fixed: shape stroke limit maxsize
jinwoo-kim-nhn Jun 14, 2018
959258c
fixed: submenu transition and mask apply hidden
Jun 14, 2018
d46b595
fixed crop zone bug
Jun 14, 2018
58be310
fixed action test
Jun 14, 2018
5cd6b06
added big menu tooltip
jinwoo-kim-nhn Jun 15, 2018
ebc9292
crop zone Flicker removal.
jinwoo-kim-nhn Jun 15, 2018
cf932dd
fixed shape standard mode
jinwoo-kim-nhn Jun 15, 2018
e5792cd
fixed shpae change stanbymode bug and filter partition height
jinwoo-kim-nhn Jun 15, 2018
3a41377
added iconsize theme
jinwoo-kim-nhn Jun 15, 2018
6d0cc9b
add jsdoc
jinwoo-kim-nhn Jun 15, 2018
f7a650d
add jsdoc & editor-wrap style
jinwoo-kim-nhn Jun 15, 2018
0527890
add test code job - 1
jinwoo-kim-nhn Jun 15, 2018
f065c12
feat: design - ui useable - add test all
Jun 17, 2018
8f3ae35
fixed undo stack bug
Jun 17, 2018
866158c
broken test fixed
jinwoo-kim-nhn Jun 18, 2018
ba1e4f4
fixed broken test2
jinwoo-kim-nhn Jun 18, 2018
4ed8c4b
fixed broken test 3
jinwoo-kim-nhn Jun 18, 2018
040766a
fixed broken test - 4
jinwoo-kim-nhn Jun 18, 2018
140530c
apply ui review
Jun 18, 2018
e05f58f
fixed: added file cleanup and theme properties.
jinwoo-kim-nhn Jun 19, 2018
c9e429b
fixed typpo
jinwoo-kim-nhn Jun 19, 2018
5368e6e
apply codereview
jinwoo-kim-nhn Jun 19, 2018
80bad1f
add sample bg file
jinwoo-kim-nhn Jun 19, 2018
9b51ae1
fixed broken test
jinwoo-kim-nhn Jun 19, 2018
60d64da
apply codereview
jinwoo-kim-nhn Jun 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: design - ui useable - add test all
  • Loading branch information
jinwoo-kim-nhn authored and jinwoo-kim-nhn committed Jun 17, 2018
commit f065c1250d3a5ba762e85ba108674c3fd9be2ebf
13 changes: 5 additions & 8 deletions src/js/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
delete: () => {
this.ui.changeDeleteButtonEnabled(false);
exitCropOnAction();
this.reomveActiveObject();
this.removeActiveObject();
this.activeObjectId = null;
},
deleteAll: () => {
Expand Down Expand Up @@ -417,15 +417,12 @@ export default {
/* eslint-enable complexity */
addText: pos => {
this.addText('Double Click', {
position: pos.originPosition
}).then(() => {
this.changeTextStyle(this.activeObjectId, {
position: pos.originPosition,
styles: {
fill: this.ui.text.textColor,
fontSize: util.toInteger(this.ui.text.fontSize)
});
})['catch'](message => (
Promise.reject(message)
));
}
});
},
addObjectAfter: obj => {
if (['rect', 'circle', 'triangle'].indexOf(obj.type) > -1) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/component/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Text extends Component {
this._setInitPos(options.position);

if (options.styles) {
styles = snippet.extend(options.styles, styles);
styles = snippet.extend(styles, options.styles);
}

if (this.useItext) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/imageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ class ImageEditor {

if ((e.keyCode === keyCodes.BACKSPACE || e.keyCode === keyCodes.DEL)) {
e.preventDefault();
this.reomveActiveObject();
this.removeActiveObject();
}
}
/* eslint-enable complexity */

/**
* Remove Active Object
*/
reomveActiveObject() {
removeActiveObject() {
const activeObject = this._graphics.getActiveObject();
const activeObjectGroup = this._graphics.getActiveGroupObject();

Expand Down
192 changes: 172 additions & 20 deletions test/action.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ describe('Ui', () => {

it('removeObject() API should be executed When the delete action occurs', () => {
imageEditorMock.activeObjectId = 10;
spyOn(imageEditorMock, 'reomveActiveObject');
spyOn(imageEditorMock, 'removeActiveObject');

mainAction['delete']();

expect(imageEditorMock.reomveActiveObject).toHaveBeenCalled();
expect(imageEditorMock.removeActiveObject).toHaveBeenCalled();
expect(imageEditorMock.activeObjectId).toBe(null);
});

Expand Down Expand Up @@ -111,7 +111,6 @@ describe('Ui', () => {
done();
});
});

});

describe('shapeAction', () => {
Expand Down Expand Up @@ -281,11 +280,11 @@ describe('Ui', () => {
resolve(300);
});

spyOn(imageEditorMock, 'readyAddIcon');
spyOn(imageEditorMock, 'changeCursor');
spyOn(imageEditorMock, 'addIcon').and.returnValue(promise);

iconAction.addIcon('iconTypeA');
expect(imageEditorMock.readyAddIcon).toHaveBeenCalled();
expect(imageEditorMock.changeCursor).toHaveBeenCalled();

imageEditorMock.fire('mousedown', null, {
x: 10,
Expand Down Expand Up @@ -319,46 +318,199 @@ describe('Ui', () => {
});

describe('commonAction', () => {
it('getActions 메소드에 리턴되는 각각의 액션은 commonAction을 포함하고 있어야 한다.', () => {
it('Each action returned to the getActions method must contain commonAction.', () => {
const submenus = ['shape', 'crop', 'flip', 'rotate', 'text', 'mask', 'draw', 'icon', 'filter'];
snippet.forEach(submenus, submenu => {
expect(actions[submenu].modeChange).toBeDefined();
expect(actions[submenu].deactivateAll).toBeDefined();
expect(actions[submenu].changeSelectableAll).toBeDefined();
expect(actions[submenu].discardSelection).toBeDefined();
expect(actions[submenu].stopDrawingMode).toBeDefined();
});
});

/*
describe('modeChange()', () => {
let commonAction;
beforeEach(() => {
commonAction = actions.main;
});

it('_changeActivateMode("TEXT") API should be executed When the modeChange("text") action occurs', () => {
spyOn(imageEditorMock, '_changeActivateMode');

mainAction.modeChange('text');
commonAction.modeChange('text');
expect(imageEditorMock._changeActivateMode).toHaveBeenCalled();
});

it('startDrawingMode() API should be executed When the modeChange("crop") action occurs', () => {
spyOn(imageEditorMock, 'startDrawingMode');

mainAction.modeChange('crop');
commonAction.modeChange('crop');
expect(imageEditorMock.startDrawingMode).toHaveBeenCalled();
});

it('stopDrawingMode(), setDrawingShape(), _changeActivateMode() API should be executed When the modeChange("shape") action occurs', () => {
spyOn(imageEditorMock, 'setDrawingShape');
spyOn(imageEditorMock, '_changeActivateMode');

mainAction.modeChange('shape');
commonAction.modeChange('shape');
expect(imageEditorMock.setDrawingShape).toHaveBeenCalled();
expect(imageEditorMock._changeActivateMode).toHaveBeenCalled();
});
});
*/
});

describe('reAction', () => {
/*
undoStackChanged
redoStackChanged
objectActivated
addText
addObjectAfter
objectScaled
selectionCleared
*/
beforeEach(() => {
imageEditorMock.setReAction();
});

describe('undoStackChanged', () => {
it('If the undo stack has a length greater than zero, the state of changeUndoButtonStatus, changeResetButtonStatus should be true.', () => {
spyOn(imageEditorMock.ui, 'changeUndoButtonStatus');
spyOn(imageEditorMock.ui, 'changeResetButtonStatus');
imageEditorMock.fire('undoStackChanged', 1);

expect(imageEditorMock.ui.changeUndoButtonStatus.calls.mostRecent().args[0]).toBe(true);
expect(imageEditorMock.ui.changeResetButtonStatus.calls.mostRecent().args[0]).toBe(true);
});

it('If the undo stack has a length of 0, the state of changeUndoButtonStatus, changeResetButtonStatus should be false.', () => {
spyOn(imageEditorMock.ui, 'changeUndoButtonStatus');
spyOn(imageEditorMock.ui, 'changeResetButtonStatus');
imageEditorMock.fire('undoStackChanged', 0);

expect(imageEditorMock.ui.changeUndoButtonStatus.calls.mostRecent().args[0]).toBe(false);
expect(imageEditorMock.ui.changeResetButtonStatus.calls.mostRecent().args[0]).toBe(false);
});
});

describe('redoStackChanged', () => {
it('If the redo stack is greater than zero length, the state of changeRedoButtonStatus should be true.', () => {
spyOn(imageEditorMock.ui, 'changeRedoButtonStatus');
imageEditorMock.fire('redoStackChanged', 1);
expect(imageEditorMock.ui.changeRedoButtonStatus.calls.mostRecent().args[0]).toBe(true);
});

it('If the redo stack has a length of zero, the state of changeRedoButtonStatus should be false.', () => {
spyOn(imageEditorMock.ui, 'changeRedoButtonStatus');
imageEditorMock.fire('redoStackChanged', 0);
expect(imageEditorMock.ui.changeRedoButtonStatus.calls.mostRecent().args[0]).toBe(false);
});
});

describe('objectActivated', () => {
it('When objectActivated occurs, the state of the delete button should be enabled.', () => {
spyOn(imageEditorMock.ui, 'changeDeleteButtonEnabled');
spyOn(imageEditorMock.ui, 'changeDeleteAllButtonEnabled');
imageEditorMock.fire('objectActivated', {id: 1});
expect(imageEditorMock.ui.changeDeleteButtonEnabled.calls.mostRecent().args[0]).toBe(true);
expect(imageEditorMock.ui.changeDeleteAllButtonEnabled.calls.mostRecent().args[0]).toBe(true);
});

it('When objectActivated\'s target is cropzone, changeApplyButtonStatus should be enabled.', () => {
spyOn(imageEditorMock.ui.crop, 'changeApplyButtonStatus');
imageEditorMock.fire('objectActivated', {
id: 1,
type: 'cropzone'
});
expect(imageEditorMock.ui.crop.changeApplyButtonStatus.calls.mostRecent().args[0]).toBe(true);
});

it('If the target of objectActivated is shape and the existing menu is not shpe, the menu should be changed to shape.', () => {
imageEditorMock.ui.submenu = 'crop';
spyOn(imageEditorMock.ui, 'changeMenu');
spyOn(imageEditorMock.ui.shape, 'setShapeStatus');
spyOn(imageEditorMock.ui.shape, 'setMaxStrokeValue');
imageEditorMock.fire('objectActivated', {
id: 1,
type: 'circle'
});

expect(imageEditorMock.ui.changeMenu.calls.mostRecent().args[0]).toBe('shape');
expect(imageEditorMock.ui.shape.setMaxStrokeValue).toHaveBeenCalled();
});

it('If the target of objectActivated is text and the existing menu is not text, the menu should be changed to text.', () => {
imageEditorMock.ui.submenu = 'crop';
spyOn(imageEditorMock.ui, 'changeMenu');
imageEditorMock.fire('objectActivated', {
id: 1,
type: 'i-text'
});

expect(imageEditorMock.ui.changeMenu.calls.mostRecent().args[0]).toBe('text');
});

it('If the target of objectActivated is icon and the existing menu is not icon, the menu should be changed to icon.', () => {
imageEditorMock.ui.submenu = 'crop';
spyOn(imageEditorMock.ui, 'changeMenu');
spyOn(imageEditorMock.ui.icon, 'setIconPickerColor');
imageEditorMock.fire('objectActivated', {
id: 1,
type: 'icon'
});

expect(imageEditorMock.ui.changeMenu.calls.mostRecent().args[0]).toBe('icon');
expect(imageEditorMock.ui.icon.setIconPickerColor).toHaveBeenCalled();
});
});

describe('addText', () => {
it('When addText occurs, the addText () method should be executed.', () => {
spyOn(imageEditorMock, 'addText');
imageEditorMock.fire('addText', {
x: 10,
y: 10
});
expect(imageEditorMock.addText).toHaveBeenCalled();
});
});

describe('addObjectAfter', () => {
it('When addObjectAfter occurs, the shape\'s maxStrokeValue should be changed to match the size of the added object.', () => {
spyOn(imageEditorMock.ui.shape, 'setMaxStrokeValue');
imageEditorMock.fire('addObjectAfter', {
type: 'circle',
width: 100,
height: 200
});

expect(imageEditorMock.ui.shape.setMaxStrokeValue.calls.mostRecent().args[0]).toBe(100);
});
});

describe('objectScaled', () => {
it('If objectScaled occurs on an object of type text, fontSize must be changed.', () => {
imageEditorMock.ui.text.fontSize = 0;
imageEditorMock.fire('objectScaled', {
type: 'i-text',
fontSize: 20
});

expect(imageEditorMock.ui.text.fontSize).toBe(20);
});

it('If objectScaled is for a shape type object and strokeValue is greater than the size of the object, the value should change.', () => {
spyOn(imageEditorMock.ui.shape, 'getStrokeValue').and.returnValue(20);
spyOn(imageEditorMock.ui.shape, 'setStrokeValue');
imageEditorMock.fire('objectScaled', {
type: 'rect',
width: 10,
height: 10
});
expect(imageEditorMock.ui.shape.setStrokeValue.calls.mostRecent().args[0]).toBe(10);
});
});

describe('selectionCleared', () => {
it('If selectionCleared occurs in the text menu state, the menu should be closed.', () => {
imageEditorMock.ui.submenu = 'text';
spyOn(imageEditorMock.ui, 'changeMenu');

imageEditorMock.fire('selectionCleared');
expect(imageEditorMock.ui.changeMenu.calls.mostRecent().args[0]).toBe('text');
});
});
});
});
Loading