Skip to content

Commit 9e6423a

Browse files
committed
working on refactor to preact
1 parent 64b6ec3 commit 9e6423a

21 files changed

+6340
-4694
lines changed

app/build/mojs-curve-editor.js

Lines changed: 5945 additions & 4610 deletions
Large diffs are not rendered by default.

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

Lines changed: 6 additions & 4 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: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,33 @@
3232
top: 0;
3333
right: 0;
3434
bottom: 0;
35+
}
3536

36-
$radius: 16;
37-
$leftPanel: 42;
38-
& resize-handle {
39-
position: absolute;
40-
41-
&[type="top"] {
42-
top: calc( -$radius*$PX );
43-
}
37+
$radius: 16;
38+
$leftPanel: 42;
39+
&__resize-handle {
40+
position: absolute;
4441

45-
&[type="bottom"] {
46-
bottom: 0;
47-
}
42+
&[data-type="top"] {
43+
top: calc( -$radius*$PX );
44+
}
4845

49-
&[type="top"],
50-
&[type="bottom"] {
51-
left: 50%;
52-
margin-left: calc( (-$radius - $gap/2)*$PX );
53-
}
46+
&[data-type="bottom"] {
47+
bottom: 0;
48+
}
5449

55-
&[type="right"] {
56-
right: calc( -$radius*$PX );
57-
top: 50%;
58-
margin-top: calc( -$radius*$PX );
59-
}
50+
&[data-type="top"],
51+
&[data-type="bottom"] {
52+
left: 50%;
53+
margin-left: calc( (-$radius - $gap/2)*$PX );
54+
}
6055

56+
&[data-type="right"] {
57+
right: calc( -$radius*$PX );
58+
top: 50%;
59+
margin-top: calc( -$radius*$PX );
6160
}
61+
6262
}
6363

6464
&__anchor-buttons {
@@ -81,7 +81,7 @@
8181
margin-left: calc( 1 * $PX );
8282
transform: translateX(-50%);
8383

84-
& icon {
84+
& [data-component="icon"] {
8585
fill: $c-orange;
8686
width: calc( 12*$PX );
8787
height: calc( 12*$PX );
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"curve-editor":"_curve-editor_1vq6l_4","curve-editor__left":"_curve-editor__left_1vq6l_1","curve-editor__right":"_curve-editor__right_1vq6l_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_1vq6l_1","curve-editor__mojs-logo":"_curve-editor__mojs-logo_1vq6l_1"}
1+
{"curve-editor":"_curve-editor_1co9o_4","curve-editor__left":"_curve-editor__left_1co9o_1","curve-editor__right":"_curve-editor__right_1co9o_1","curve-editor__resize-handle":"_curve-editor__resize-handle_1co9o_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_1co9o_1","curve-editor__mojs-logo":"_curve-editor__mojs-logo_1co9o_1"}

app/css/blocks/curve.postcss.css

Lines changed: 1 addition & 0 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_3s9gm_5","curve__background":"_curve__background_3s9gm_1","curve__svg-wrapper":"_curve__svg-wrapper_3s9gm_1","curve__svg":"_curve__svg_3s9gm_1","curve__svg-segment":"_curve__svg-segment_3s9gm_1"}
1+
{"curve":"_curve_v5h9c_5","curve__background":"_curve__background_v5h9c_1","curve__svg-wrapper":"_curve__svg-wrapper_v5h9c_1","curve__svg":"_curve__svg_v5h9c_1","curve__svg-segment":"_curve__svg-segment_v5h9c_1"}

app/css/blocks/resize-handle.postcss.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $radius: 16;
2323
z-index: 2;
2424
}
2525

26-
& icon {
26+
& [data-component="icon"] {
2727
position: absolute;
2828
left: 0;
2929
top: calc( -7*$PX )
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"resize-handle":"_resize-handle_5gtb1_4","resize-handle--right":"_resize-handle--right_5gtb1_1","resize-handle--bottom":"_resize-handle--bottom_5gtb1_1"}
1+
{"resize-handle":"_resize-handle_k81kc_4","resize-handle--right":"_resize-handle--right_k81kc_1","resize-handle--bottom":"_resize-handle--bottom_k81kc_1"}

app/js/app.babel.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ require('../css/main');
33
import {render, h} from 'preact';
44
import CurveEditor from './tags/curve-editor';
55
import store from './store';
6+
import { Provider } from 'preact-redux';
67

78
// TODO
89
// - init points with function
910
// - move bunch of points at once
1011
// - add grid background
1112

1213
document.addEventListener('DOMContentLoaded', () => {
13-
render(<CurveEditor state={ store.getState() } />, document.body);
14-
// store.subscribe(renderRoot);
14+
render(
15+
<Provider store={store}>
16+
<CurveEditor />
17+
</Provider>, document.body);
1518
});

app/js/reducers/resize-reducer.babel.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import C from '../constants';
22

33
const INITIAL_STATE = {
4-
translate: { x: 150, y: 100 },
4+
x: 150,
5+
tempX: 0,
6+
7+
y: 100,
8+
tempY: 0,
9+
510
top: 0,
611
temp_top: 0,
712

@@ -44,7 +49,18 @@ const resizeReducer = (state = INITIAL_STATE, action) => {
4449
return newState;
4550
}
4651

47-
case 'EDITOR_TRANSLATE': { return { ...state, translate: action.data }; }
52+
case 'EDITOR_TRANSLATE': {
53+
const {x, y} = action.data;
54+
return { ...state, tempX: x, tempY: y };
55+
}
56+
57+
case 'EDITOR_TRANSLATE_END': {
58+
let {x, y} = action.data;
59+
x += state.x;
60+
y += state.y;
61+
return { ...state, x, y, tempX: 0, tempY: 0 };
62+
}
63+
4864
}
4965
return state;
5066
}

0 commit comments

Comments
 (0)