Skip to content

Commit daae14d

Browse files
committed
mockups: initial commit
1 parent 2c6070b commit daae14d

17 files changed

+1231
-1083
lines changed

app/build/mojs-curve-editor.js

Lines changed: 1043 additions & 1014 deletions
Large diffs are not rendered by default.

app/build/mojs-curve-editor.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/css/blocks/curve-editor.postcss.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
width: calc( 403 * $PX );
99
height: calc( 378 * $PX );
1010
border-radius: calc( 12 * $PX );
11-
background: rgba( 58, 8, 58, .85 );
11+
background: #572B51;
1212
z-index: 100;
1313
box-shadow: 2px 2px 2px rgba(0,0,0,.38);
1414

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"curve-editor":"_curve-editor_1f8r5_4","curve-editor__left":"_curve-editor__left_1f8r5_1","curve-editor__right":"_curve-editor__right_1f8r5_1","curve-editor__resize-handle":"_curve-editor__resize-handle_1f8r5_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_1f8r5_1","curve-editor__mojs-logo":"_curve-editor__mojs-logo_1f8r5_1"}
1+
{"curve-editor":"_curve-editor_1itz1_4","curve-editor__left":"_curve-editor__left_1itz1_1","curve-editor__right":"_curve-editor__right_1itz1_1","curve-editor__resize-handle":"_curve-editor__resize-handle_1itz1_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_1itz1_1","curve-editor__mojs-logo":"_curve-editor__mojs-logo_1itz1_1"}

app/css/blocks/curve.postcss.css

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/css/blocks/curve.postcss.css.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"curve":"_curve_gvcrn_5","curve__background":"_curve__background_gvcrn_1","curve__svg-wrapper":"_curve__svg-wrapper_gvcrn_1","curve__svg":"_curve__svg_gvcrn_1","curve__svg-segment":"_curve__svg-segment_gvcrn_1"}
1+
{"curve":"_curve_k9lsx_5","curve__background":"_curve__background_k9lsx_1","curve__svg-wrapper":"_curve__svg-wrapper_k9lsx_1","curve__svg":"_curve__svg_k9lsx_1","curve__svg-segment":"_curve__svg-segment_k9lsx_1"}

app/css/i/pattern1.svg

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<script src="build/mojs-curve-editor.js" charset="utf-8"></script>
2727

2828
<script>
29-
var curveEditor = new window.MojsCurveEditor({ name: 'curve1', isSaveState: false });
29+
var curveEditor = new window.MojsCurveEditor({ name: 'curve1', isSaveState: true });
3030
var curveEditor2 = new window.MojsCurveEditor({ name: 'curve2', isSaveState: true });
3131

3232
// var shape = new mojs.Shape({

app/js/app.babel.jsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import C from './constants';
88
import hash from './helpers/hash';
99
import fallbackTo from './helpers/fallback-to';
1010
import defer from './helpers/defer';
11+
import addPointerDown from './helpers/add-pointer-down';
1112

1213
// TODO
13-
// - handle translate isRecord
14-
// - multiple editors short cuts
1514
// - resize down when points are above the editor border
16-
// - instance dropdown on code panel
15+
// - performance
1716
// - import path data
1817
// - move bunch of points at once
1918

19+
20+
/*
21+
API wrapper above the app itself.
22+
*/
2023
class API {
2124
constructor ( o = {} ) {
2225
this._o = o;
@@ -29,6 +32,7 @@ class API {
2932
this._listenUnload();
3033

3134
this._subscribe();
35+
this._subscribeFocus();
3236
}
3337

3438
_decalareDefaults ( ) {
@@ -57,6 +61,8 @@ class API {
5761
let str = fallbackTo( this._o.name, this._defaults.name );
5862
str += ( str === this._defaults.name ) ? '' : `__${this._defaults.name}`;
5963
this._localStorage = `${str}__${ hash( str ) }`;
64+
65+
this.store.dispatch({ type: 'SET_EDITOR_NAME', data: this._localStorage });
6066
}
6167

6268
_render () {
@@ -83,6 +89,8 @@ class API {
8389
localStorage.removeItem( this._localStorage );
8490
}
8591
});
92+
93+
8694
}
8795

8896
_tryToRestore () {
@@ -100,6 +108,14 @@ class API {
100108
this.store.subscribe( this._compilePath.bind(this) );
101109
}
102110

111+
_subscribeFocus () {
112+
addPointerDown( document.body, (e) => {
113+
if (this._localStorage !== e._mojsCurveEditorName) {
114+
this.store.dispatch({ type: 'POINT_DESELECT_ALL' });
115+
}
116+
});
117+
}
118+
103119
_compilePath () {
104120
const state = this.store.getState(),
105121
points = state.points.present,
@@ -172,11 +188,6 @@ class API {
172188
if ( !el ) { return; }
173189

174190
el.style.left = `${p*100}%`;
175-
176-
// const x = p * ( C.CURVE_SIZE + resize.temp_right + resize.right ),
177-
// transform = `translateX(${x}px)`;
178-
179-
// mojs.h.setPrefixedStyle( el, 'transform', transform );
180191
}
181192

182193
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import calculatePath from '../helpers/calculate-path';
22

33
const INITIAL_STATE = {
4-
isCode: false
4+
isCode: false
55
}
66

7-
const pointControls = (state = INITIAL_STATE, action) => {
7+
const controls = (state = INITIAL_STATE, action) => {
88
switch (action.type) {
99
case 'CODE_TAP': {
1010
return { ...state, isCode: !state.isCode };
@@ -13,4 +13,4 @@ const pointControls = (state = INITIAL_STATE, action) => {
1313
return state;
1414
}
1515

16-
export default pointControls;
16+
export default controls;

0 commit comments

Comments
 (0)