Skip to content

Commit ff1026f

Browse files
Merge pull request #3 from marcoaraujojunior/develop
Using card instead table
2 parents e38f1f0 + 13272df commit ff1026f

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

app/components/Client/Client.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { CardStack, Card } from 'react-cardstack';
23

34
import ClientService from 'services/Client';
45
import Error from 'components/Error/Error'
@@ -8,7 +9,7 @@ class Client extends React.Component
89
constructor(props) {
910
super(props);
1011
this.state = {
11-
clients : [],
12+
clients : null,
1213
error : ''
1314
};
1415
this.getClients();
@@ -29,34 +30,36 @@ class Client extends React.Component
2930
if (this.state.error) {
3031
return (<Error error={this.state.error} />);
3132
}
33+
if (!this.state.clients) {
34+
return <div>Loading...</div>;
35+
}
3236
const clientList = this.state.clients.map((client, key) => {
3337
return (
34-
<tr key={key} >
35-
<td>{ client.name }</td>
36-
<td>{ client.address }</td>
37-
<td>{ client.city }</td>
38-
<td className="is-icon"> <a href="#"> <i className="fa fa-calendar"></i> </a> </td>
39-
<td className="is-icon"> <a href="#"> <i className="fa fa-search"></i> </a> </td>
40-
</tr>
38+
<Card key={key}>
39+
<article className={`message ${((key % 2) ? 'is-success' : 'is-info')}`}>
40+
<div className="message-header">
41+
<strong>{ client.name }</strong>
42+
</div>
43+
<div className="message-body">
44+
<address>{ client.address }</address>
45+
<city><small>{ client.city }</small></city>
46+
</div>
47+
</article>
48+
</Card>
4149
);
4250
});
4351

4452
return (
4553
<div className="container hello">
46-
<table className="table">
47-
<thead>
48-
<tr>
49-
<th>Name</th>
50-
<th>Address</th>
51-
<th>City</th>
52-
<th></th>
53-
<th></th>
54-
</tr>
55-
</thead>
56-
<tbody>
57-
{ clientList }
58-
</tbody>
59-
</table>
54+
<CardStack
55+
height={100}
56+
width={1200}
57+
background='#00d1b2'
58+
hoverOffset={0}>
59+
60+
{ clientList }
61+
62+
</CardStack>
6063
</div>
6164
);
6265
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"npm-run-all": "^3.1.0",
3030
"path": "^0.12.7",
3131
"react-addons-test-utils": "^15.3.2",
32+
"react-cardstack": "^0.1.1",
3233
"react-test-renderer": "^15.3.2",
3334
"style-loader": "^0.13.1",
3435
"url-loader": "^0.5.7",

tests/Client.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ describe('Test Client', () => {
9797
let response = {
9898
data: {
9999
clients: [
100-
{name: 'Jon Snow', address: '7 Street', city: 'Winterfell'}
100+
{name: 'Jon Snow', address: '7 Street', city: 'Winterfell'},
101+
{name: 'Cotter Pyke', address: '0 Street', city: 'Castle Black'},
101102
]
102103
}
103104
};
@@ -131,9 +132,9 @@ describe('Test Client', () => {
131132

132133
Promise.all(promises).then(() => {
133134
component.update();
134-
expect(component.find('td').at(0).text()).toEqual('Jon Snow');
135-
expect(component.find('td').at(1).text()).toEqual('7 Street');
136-
expect(component.find('td').at(2).text()).toEqual('Winterfell');
135+
expect(component.find('.message-header').at(0).text()).toEqual('Jon Snow');
136+
expect(component.find('.message-body > address').at(0).text()).toEqual('7 Street');
137+
expect(component.find('.message-body > city').at(0).text()).toEqual('Winterfell');
137138
done();
138139
}).catch((error) => {
139140
console.log(error);

0 commit comments

Comments
 (0)