Showing
4 changed files
with
50 additions
and
39 deletions
This diff is collapsed. Click to expand it.
... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
3 | "version": "0.1.0", | 3 | "version": "0.1.0", |
4 | "private": true, | 4 | "private": true, |
5 | "dependencies": { | 5 | "dependencies": { |
6 | + "@material-ui/core": "^4.10.2", | ||
6 | "@testing-library/jest-dom": "^4.2.4", | 7 | "@testing-library/jest-dom": "^4.2.4", |
7 | "@testing-library/react": "^9.5.0", | 8 | "@testing-library/react": "^9.5.0", |
8 | "@testing-library/user-event": "^7.2.1", | 9 | "@testing-library/user-event": "^7.2.1", | ... | ... |
1 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
2 | import './App.css'; | 2 | import './App.css'; |
3 | -import Customer from './components/Customer' | 3 | +import Customer from './components/Customer'; |
4 | +import Paper from '@material-ui/core/Paper'; | ||
5 | +import Table from '@material-ui/core/Table'; | ||
6 | +import TableHead from '@material-ui/core/TableHead'; | ||
7 | +import TableBody from '@material-ui/core/TableBody'; | ||
8 | +import TableRow from '@material-ui/core/TableRow'; | ||
9 | +import TableCell from '@material-ui/core/TableCell'; | ||
10 | +import { withStyles } from '@material-ui/core/styles'; | ||
11 | + | ||
12 | +const styles = theme => ({ | ||
13 | + root: { | ||
14 | + width: '100%', | ||
15 | + marginTop: theme.spacing.unit*3, | ||
16 | + overflowX: "auto" | ||
17 | + }, | ||
18 | + table: { | ||
19 | + minWidth: 1080 | ||
20 | + } | ||
21 | +}) | ||
4 | 22 | ||
5 | const customers =[ | 23 | const customers =[ |
6 | { | 24 | { |
... | @@ -32,18 +50,28 @@ const customers =[ | ... | @@ -32,18 +50,28 @@ const customers =[ |
32 | 50 | ||
33 | class App extends Component { | 51 | class App extends Component { |
34 | render() { | 52 | render() { |
53 | + const { classes } = this.props; | ||
35 | return ( | 54 | return ( |
36 | - <div> | 55 | + <Paper className = {classes.root}> |
37 | - { | 56 | + <Table className = {classes.table}> |
38 | - customers.map(c=> { return (<Customer key={c.id} id={c.id} image={c.image} name={c.name} birthday={c.birthday} gender={c.gender} job={c.job} /> | 57 | + <TableHead> |
39 | - ) | 58 | + <TableRow> |
40 | - }) | 59 | + <TableCell>번호</TableCell> |
41 | - } | 60 | + <TableCell>이미지</TableCell> |
42 | - </div> | 61 | + <TableCell>이름</TableCell> |
62 | + <TableCell>생년월일</TableCell> | ||
63 | + <TableCell>성별</TableCell> | ||
64 | + <TableCell>직업</TableCell> | ||
65 | + </TableRow> | ||
66 | + </TableHead> | ||
67 | + | ||
68 | + <TableBody> | ||
69 | + {customers.map(c=> { return (<Customer key={c.id} id={c.id} image={c.image} name={c.name} birthday={c.birthday} gender={c.gender} job={c.job} />)})} | ||
70 | + </TableBody> | ||
71 | + </Table> | ||
72 | + </Paper> | ||
43 | ); | 73 | ); |
44 | } | 74 | } |
45 | } | 75 | } |
46 | 76 | ||
47 | - | 77 | +export default withStyles(styles)(App); |
48 | - | ||
49 | -export default App; | ... | ... |
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | +import TableRow from '@material-ui/core/TableRow'; | ||
3 | +import TableCell from '@material-ui/core/TableCell'; | ||
2 | 4 | ||
3 | class Customer extends React.Component { | 5 | class Customer extends React.Component { |
4 | render(){ | 6 | render(){ |
5 | return( | 7 | return( |
6 | - <div> | 8 | + <TableRow> |
7 | - <CustomerProfile id ={this.props.id} image = {this.props.image} name = {this.props.name}/> | 9 | + <TableCell>{this.props.id}</TableCell> |
8 | - <CustomerInfo birthday = {this.props.birthday} gender = {this.props.gender} job = {this.props.job}/> | 10 | + <TableCell><img src={this.props.image} alt="profile"/></TableCell> |
9 | - </div> | 11 | + <TableCell>{this.props.name}</TableCell> |
12 | + <TableCell>{this.props.birthday}</TableCell> | ||
13 | + <TableCell>{this.props.gender}</TableCell> | ||
14 | + <TableCell>{this.props.job}</TableCell> | ||
15 | + </TableRow> | ||
10 | ); | 16 | ); |
11 | } | 17 | } |
12 | } | 18 | } |
13 | 19 | ||
14 | -class CustomerProfile extends React.Component{ | ||
15 | - render(){ | ||
16 | - return( | ||
17 | - <div> | ||
18 | - <img src={this.props.image}alt="profile"/> | ||
19 | - <h2>{this.props.name}({this.props.id})</h2> | ||
20 | - </div> | ||
21 | - ); | ||
22 | - } | ||
23 | -} | ||
24 | - | ||
25 | -class CustomerInfo extends React.Component { | ||
26 | - render() { | ||
27 | - return ( | ||
28 | - <div> | ||
29 | - <p>{this.props.birthday}</p> | ||
30 | - <p>{this.props.gender}</p> | ||
31 | - <p>{this.props.job}</p> | ||
32 | - </div> | ||
33 | - ) | ||
34 | - } | ||
35 | - | ||
36 | - | ||
37 | -} | ||
38 | 20 | ||
39 | 21 | ||
40 | export default Customer; | 22 | export default Customer; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment