mirror of
https://github.com/TrentSPalmer/fcc-challenges.git
synced 2025-09-18 12:51:33 -07:00
add calculator-react
This commit is contained in:
14
calculator-react/src/reducers/innerWindowHeightReducer.js
Normal file
14
calculator-react/src/reducers/innerWindowHeightReducer.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { SETWINDOWINNERHEIGHT } from "../actions/innerWindowHeightAction";
|
||||
|
||||
export default (state, action) => {
|
||||
if (!state) {
|
||||
state = window.innerHeight;
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
case SETWINDOWINNERHEIGHT:
|
||||
return action.windowInnerHeight;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
14
calculator-react/src/reducers/innerWindowWidthReducer.js
Normal file
14
calculator-react/src/reducers/innerWindowWidthReducer.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { SETWINDOWINNERWIDTH } from "../actions/innerWindowWidthAction";
|
||||
|
||||
export default (state, action) => {
|
||||
if (!state) {
|
||||
state = window.innerWidth;
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
case SETWINDOWINNERWIDTH:
|
||||
return action.windowInnerWidth;
|
||||
default:
|
||||
return state;
|
||||
};
|
||||
};
|
14
calculator-react/src/reducers/inputStringReducer.js
Normal file
14
calculator-react/src/reducers/inputStringReducer.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { SETINPUTSTRING } from "../actions/inputStringAction";
|
||||
|
||||
export default (state, action) => {
|
||||
if (!state) {
|
||||
state = '';
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
case SETINPUTSTRING:
|
||||
return action.inputString;
|
||||
default:
|
||||
return state;
|
||||
};
|
||||
};
|
14
calculator-react/src/reducers/operationStringReducer.js
Normal file
14
calculator-react/src/reducers/operationStringReducer.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { SETOPERATIONSTRING } from "../actions/operationStringAction";
|
||||
|
||||
export default (state, action) => {
|
||||
if (!state) {
|
||||
state = '';
|
||||
}
|
||||
|
||||
switch (action.type) {
|
||||
case SETOPERATIONSTRING:
|
||||
return action.operationString;
|
||||
default:
|
||||
return state;
|
||||
};
|
||||
};
|
12
calculator-react/src/reducers/rootReducer.js
Normal file
12
calculator-react/src/reducers/rootReducer.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { combineReducers } from "redux";
|
||||
import innerWindowWidthReducer from "./innerWindowWidthReducer";
|
||||
import innerWindowHeightReducer from "./innerWindowHeightReducer";
|
||||
import inputStringReducer from "./inputStringReducer";
|
||||
import operationStringReducer from "./operationStringReducer";
|
||||
|
||||
export default combineReducers({
|
||||
innerWindowWidth: innerWindowWidthReducer,
|
||||
innerWindowHeight: innerWindowHeightReducer,
|
||||
inputString: inputStringReducer,
|
||||
operationString: operationStringReducer,
|
||||
});
|
Reference in New Issue
Block a user