Skip to content

Commit 34164ad

Browse files
committed
fix: introduced form controls
1 parent 60b5cd2 commit 34164ad

File tree

8 files changed

+64
-4
lines changed

8 files changed

+64
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"react-draggable": "2.2.2",
6060
"react-icons": "2.2.1",
6161
"react-json-tree": "0.9.0",
62-
"react-tooltip": "3.2.1"
62+
"react-tooltip": "^3.2.1"
6363
},
6464
"peerDependencies": {
6565
"mobx": "^2.6.0",

screenshot.png

-17.8 KB
Loading

src/actions.js

+9
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,14 @@ export default $store => ({
3333
_.set($store.tools, 'heading.sub', (size > 0.11));
3434
}),
3535

36+
handleFormControls: action((type) => {
37+
switch (type) {
38+
case 'submit': $store.selected.form.submit(); break;
39+
case 'clear': $store.selected.form.clear(); break;
40+
case 'reset': $store.selected.form.reset(); break;
41+
default: $store.selected.form.submit();
42+
}
43+
}),
44+
3645
});
3746

src/components/Draggable.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import style from '../styles/Draggable';
1010
export default observer(({ handlers }) => (
1111
<Draggable
1212
axis="y"
13-
handle=".devtools-drag"
13+
handle=".devtools-handle-drag"
1414
zIndex={99999999999}
1515
defaultPosition={{ x: 0, y: 0 }}
1616
>
1717
<div>
1818
<div className={style.draggable}>
19-
<div className="devtools-drag" data-tip="DRAG">
19+
<div className="devtools-handle-drag" data-tip="DRAG">
2020
<Icons.FaBars className={merge(style.icon, style.dragIcon)} />
2121
</div>
2222
<button

src/components/RenderFormData.jsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { observer } from 'mobx-react';
33
import { merge } from 'glamor';
44
import JSONTree from 'react-json-tree';
5+
import ReactTooltip from 'react-tooltip';
56

67
import SelectMenu from './SelectMenu';
78

@@ -12,7 +13,8 @@ import $U from '../styles/_.utils';
1213
import style from '../styles/RenderFormData';
1314

1415
export default observer(({ store, handlers }) =>
15-
<div className="tree">
16+
<div>
17+
<ReactTooltip />
1618
<h4 className={merge(style.heading, $U.clearfix)}>
1719
<div className={$U.left}>
1820
<Icons.FaTh className={style.icon} /> Form
@@ -21,6 +23,17 @@ export default observer(({ store, handlers }) =>
2123
<SelectMenu store={store} handlers={handlers} />
2224
</div>
2325
</h4>
26+
<div className={merge($U.clearfix)}>
27+
<button type="button"className={style.controls.button} onClick={handlers.handleFormOnSubmit} data-tip="SUBMIT">
28+
<Icons.FaDotCircleO className={style.controls.icon} />
29+
</button>
30+
<button type="button"className={style.controls.button} onClick={handlers.handleFormOnClear} data-tip="CLEAR">
31+
<Icons.FaEraser className={style.controls.icon} />
32+
</button>
33+
<button type="button"className={style.controls.button} onClick={handlers.handleFormOnReset} data-tip="RESET">
34+
<Icons.FaRefresh className={style.controls.icon} />
35+
</button>
36+
</div>
2437
<JSONTree
2538
hideRoot
2639
data={parseFormData(store.selected.form)}

src/handlers.js

+15
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,19 @@ export default $actions => ({
2929
$actions.selectForm(e.target.value);
3030
},
3131

32+
handleFormOnSubmit: (e) => {
33+
e.preventDefault();
34+
$actions.handleFormControls('submit');
35+
},
36+
37+
handleFormOnClear: (e) => {
38+
e.preventDefault();
39+
$actions.handleFormControls('clear');
40+
},
41+
42+
handleFormOnReset: (e) => {
43+
e.preventDefault();
44+
$actions.handleFormControls('reset');
45+
},
46+
3247
});

src/icons.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import FaTh from 'react-icons/lib/fa/th';
22
import FaBars from 'react-icons/lib/fa/bars';
33
import FaBook from 'react-icons/lib/fa/book';
4+
import FaRefresh from 'react-icons/lib/fa/refresh';
5+
import FaEraser from 'react-icons/lib/fa/eraser';
46
import FaCircleO from 'react-icons/lib/fa/circle-o';
7+
import FaDotCircleO from 'react-icons/lib/fa/dot-circle-o';
58
import FaChevronLeft from 'react-icons/lib/fa/chevron-left';
69
import FaChevronCircleRight from 'react-icons/lib/fa/chevron-circle-right';
710

811
export default {
912
FaTh,
1013
FaBars,
1114
FaBook,
15+
FaRefresh,
16+
FaEraser,
1217
FaCircleO,
18+
FaDotCircleO,
1319
FaChevronLeft,
1420
FaChevronCircleRight,
1521
};

src/styles/RenderFormData.js

+17
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,21 @@ export default {
1616
icon: style({
1717
marginTop: '-3px',
1818
}),
19+
controls: {
20+
button: style({
21+
'borderRadius': 0,
22+
'width': '33.333%',
23+
'display': 'block',
24+
'float': 'left',
25+
'fontSize': '20px',
26+
'padding': '3px 0 6px 0',
27+
'background': theme.base01,
28+
':hover': {
29+
background: theme.base03,
30+
},
31+
}),
32+
icon: style({
33+
color: theme.base00,
34+
}),
35+
},
1936
};

0 commit comments

Comments
 (0)