mirror of
https://github.com/10h30/fullstackopen.git
synced 2026-07-14 04:05:52 +09:00
create project for part2
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import React from 'react'
|
||||
|
||||
const App = () => {
|
||||
const course = {
|
||||
name: 'Half Stack application development',
|
||||
parts: [
|
||||
{
|
||||
name: 'Fundamentals of React',
|
||||
exercises: 10
|
||||
},
|
||||
{
|
||||
name: 'Using props to pass data',
|
||||
exercises: 7
|
||||
},
|
||||
{
|
||||
name: 'State of a component',
|
||||
exercises: 14
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header course={course} />
|
||||
<Content part={course.parts} />
|
||||
<Total part={course.parts} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const Header = (props) => {
|
||||
return (
|
||||
<h1>{props.course.name}</h1>
|
||||
)
|
||||
}
|
||||
|
||||
const Content = (props) => {
|
||||
return (
|
||||
<div>
|
||||
<Part part={props.part[0]} />
|
||||
<Part part={props.part[1]} />
|
||||
<Part part={props.part[2]} />
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
const Part = (props) => {
|
||||
return (
|
||||
<p>{props.part.name} {props.part.exercises}</p>
|
||||
)
|
||||
}
|
||||
|
||||
const Total = (props) => {
|
||||
return (
|
||||
<p>Number of exercises {props.part[0].exercises + props.part[1].exercises + props.part[2].exercises}</p>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,13 @@
|
||||
body {
|
||||
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;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './App'
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('root')
|
||||
)
|
||||
Reference in New Issue
Block a user