From 66154a4e51d56b0b41a2326135c3a5b0f3a22dd5 Mon Sep 17 00:00:00 2001 From: Lukas Heiligenbrunner Date: Sat, 30 May 2020 15:37:53 +0200 Subject: [PATCH] init --- src/App.css | 42 ++++++++++++++++---------------- src/App.js | 52 +++++++++++++++++++++++++-------------- src/App.test.js | 9 ------- src/Zwei.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/index.css | 10 ++++---- src/index.js | 2 +- 6 files changed, 126 insertions(+), 54 deletions(-) delete mode 100644 src/App.test.js create mode 100644 src/Zwei.js diff --git a/src/App.css b/src/App.css index 74b5e05..78b8850 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,38 @@ .App { - text-align: center; + text-align: center; } .App-logo { - height: 40vmin; - pointer-events: none; + height: 40vmin; + pointer-events: none; } @media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } + .App-logo { + animation: App-logo-spin infinite 20s linear; + } } .App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; + background-color: #282c34; + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); + color: white; } .App-link { - color: #61dafb; + color: #61dafb; } @keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } } diff --git a/src/App.js b/src/App.js index ce9cbd2..50e5976 100644 --- a/src/App.js +++ b/src/App.js @@ -1,26 +1,42 @@ import React from 'react'; import logo from './logo.svg'; import './App.css'; +import ReactDOM from "react-dom"; +import TodoApp from "./Zwei" function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); + return ( +
+
+ logo +

+ Edit src/App.js and save to reload. +

+ + Learn React + + + +
+
+ ); } export default App; diff --git a/src/App.test.js b/src/App.test.js deleted file mode 100644 index 4db7ebc..0000000 --- a/src/App.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/src/Zwei.js b/src/Zwei.js new file mode 100644 index 0000000..654e3ef --- /dev/null +++ b/src/Zwei.js @@ -0,0 +1,65 @@ +import React from 'react'; + +class TodoApp extends React.Component { + constructor(props) { + super(props); + this.state = { items: [], text: '' }; + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + render() { + return ( +
+

TODO

+ +
+ + + +
+
+ ); + } + + handleChange(e) { + this.setState({ text: e.target.value }); + } + + handleSubmit(e) { + e.preventDefault(); + if (this.state.text.length === 0) { + return; + } + const newItem = { + text: this.state.text, + id: Date.now() + }; + this.setState(state => ({ + items: state.items.concat(newItem), + text: '' + })); + } +} + +class TodoList extends React.Component { + render() { + return ( + + ); + } +} + +export default TodoApp; \ No newline at end of file diff --git a/src/index.css b/src/index.css index ec2585e..da92873 100644 --- a/src/index.css +++ b/src/index.css @@ -1,13 +1,13 @@ body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/src/index.js b/src/index.js index f5185c1..fcb1762 100644 --- a/src/index.js +++ b/src/index.js @@ -14,4 +14,4 @@ ReactDOM.render( // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.register();