Skip to content

Commit af0c0a2

Browse files
committed
Add echo toggle to rx/tx bar
1 parent 30a6dae commit af0c0a2

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

src/console-store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
const createStore = require('@phated/redux-create-store');
1010

1111
const reducers = {
12+
echo: require('./reducers/echo'),
1213
rxtx: require('./reducers/rxtx')
1314
};
1415

src/creators/echo-off.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const {
4+
ECHO_OFF
5+
} = require('../constants/action-types');
6+
7+
function echoOff(){
8+
return {
9+
type: ECHO_OFF,
10+
payload: {}
11+
};
12+
}
13+
14+
module.exports = echoOff;

src/creators/echo-on.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const {
4+
ECHO_ON
5+
} = require('../constants/action-types');
6+
7+
function echoOn(){
8+
return {
9+
type: ECHO_ON,
10+
payload: {}
11+
};
12+
}
13+
14+
module.exports = echoOn;

src/plugins/rxtx.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ const styles = {
3232
float: 'right',
3333
paddingTop: '3px'
3434
},
35+
echo: {
36+
display: 'inline-block',
37+
paddingTop: '3px',
38+
paddingLeft: '16px'
39+
},
40+
echoOn: {
41+
color: '#000000'
42+
},
43+
echoOff: {
44+
color: '#888888'
45+
},
3546
rx: {
3647
backgroundColor: blue
3748
},
@@ -49,9 +60,10 @@ function rxtxBar(app, opts, done){
4960
let bottomBar;
5061
let rx;
5162
let tx;
63+
let echoContainer, echoLabel;
5264

5365
function onConsoleChange(){
54-
const { rxtx } = consoleStore.getState();
66+
const { rxtx, echo } = consoleStore.getState();
5567
const { flashRx, flashTx } = rxtx;
5668

5769
if(flashRx){
@@ -65,6 +77,14 @@ function rxtxBar(app, opts, done){
6577
} else {
6678
tx.style.backgroundColor = styles.indicator.backgroundColor;
6779
}
80+
81+
if(echo){
82+
applyStyles(echoContainer, styles.echoOn);
83+
echoLabel.nodeValue = 'Echo On';
84+
}else{
85+
applyStyles(echoContainer, styles.echoOff);
86+
echoLabel.nodeValue = 'Echo Off';
87+
}
6888
}
6989

7090
app.view('editor', function(el, cb){
@@ -73,6 +93,14 @@ function rxtxBar(app, opts, done){
7393
bottomBar = document.createElement('div');
7494
applyStyles(bottomBar, styles.bar);
7595

96+
echoContainer = document.createElement('span');
97+
applyStyles(echoContainer, styles.echo);
98+
applyStyles(echoContainer, styles.echoOff);
99+
bottomBar.appendChild(echoContainer);
100+
101+
echoLabel = document.createTextNode('Echo Off');
102+
echoContainer.appendChild(echoLabel);
103+
76104
const rxtxContainer = document.createElement('span');
77105
applyStyles(rxtxContainer, styles.rxtx);
78106
bottomBar.appendChild(rxtxContainer);

src/reducers/echo.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
/*
4+
Don't include this in the index.js because it is used only
5+
for the console-store
6+
*/
7+
8+
const {
9+
ECHO_OFF,
10+
ECHO_ON
11+
} = require('../constants/action-types');
12+
13+
const initial = false;
14+
15+
function echo(state = initial, { type }){
16+
switch(type){
17+
case ECHO_OFF:
18+
return false;
19+
case ECHO_ON:
20+
return true;
21+
default:
22+
return state;
23+
}
24+
}
25+
26+
module.exports = echo;

0 commit comments

Comments
 (0)