Skip to content

Commit

Permalink
react tutorial: first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evelyn.graumann committed Jan 23, 2020
1 parent 114a54a commit 2c6f949
Show file tree
Hide file tree
Showing 12 changed files with 2,783 additions and 1,422 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4,091 changes: 2,671 additions & 1,420 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"react-dom": "^16.12.0"
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"prettier": "^1.19.1",
"react-scripts": "3.2.0"
"react-scripts": "^3.3.0",
"react-test-renderer": "^16.12.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />
<link href="https://fonts.googleapis.com/css?family=Orbitron:400,700" rel="stylesheet">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png" />
<title>Calcultronic 5000</title>
</head>
Expand Down
7 changes: 7 additions & 0 deletions src/components/App/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.app-container {
height: 100vh;
width: 100vw;
align-items: center;
display: flex;
justify-content: center;
}
7 changes: 7 additions & 0 deletions src/components/App/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import './App.css';
import Calculator from "../Calculator/Calculator";

const App = () => <div className="app-container"><Calculator/></div>;

export default App;
18 changes: 18 additions & 0 deletions src/components/App/App.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { shallow } from 'enzyme';
import App from './App';
import Calculator from "../Calculator/Calculator";

describe('App', () => {
let wrapper;

beforeEach(() => wrapper = shallow(<App />));

it('should render a <div />', () => {
expect(wrapper.find('div').length).toEqual(1);
});

it('should render the Calculator Component', () => {
expect(wrapper.containsMatchingElement(<Calculator />)).toEqual(true);
});
});
36 changes: 36 additions & 0 deletions src/components/Calculator/Calculator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { Component } from 'react';

class Calculator extends Component {
state = {
// value to be displayed in <Display />
displayValue: '0',
// values to be displayed in number <Keys />
numbers: [],
// values to be displayed in operator <Keys />
operators: [],
// operator selected for math operation
selectedOperator: '',
// stored value to use for math operation
storedValue: '',
}

callOperator = () => {
console.log('call operation');
}

setOperator = () => {
console.log('set operation');
}

updateDisplay = () => {
console.log('update display');
}

render = () => {
return (
<div className="calculator-container" />
);
}
}

export default Calculator;
13 changes: 13 additions & 0 deletions src/components/Calculator/Calculator.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import Calculator from './Calculator';

describe('Calculator', () => {
let wrapper;

beforeEach(() => wrapper = shallow(<Calculator />));

it('should render a <div />', () => {
expect(wrapper.find('div').length).toEqual(1);
});
});
17 changes: 17 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
app variables
*/

:root {
/* font */
--main-font: 'Orbitron', sans-serif;
}

/*
app CSS reset
*/

body, div, p {
margin: 0;
padding: 0;
}
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './components/App/App';

ReactDOM.render(<div>Hello World!</div>, document.getElementById('root'));
ReactDOM.render(<App />, document.getElementById('root'));
4 changes: 4 additions & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

0 comments on commit 2c6f949

Please sign in to comment.