Skip to content

Commit b3a0efd

Browse files
committed
some style
1 parent 2f30526 commit b3a0efd

File tree

4 files changed

+168
-26
lines changed

4 files changed

+168
-26
lines changed

app/assets/styles.css

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,113 @@
11
body {
2-
background: pink;
2+
font-family: "Helvetica Neue";
3+
font-weight: 200;
34
}
45

5-
a.active {
6-
color: red;
6+
h1, h2 {
7+
font-weight: normal;
78
}
89

10+
a {
11+
text-decoration: none;
12+
color: #007adc;
13+
}
14+
15+
a:active {
16+
color: #ff3b30;
17+
}
18+
19+
.App {
20+
position: absolute;
21+
top: 0;
22+
right: 0;
23+
bottom: 0;
24+
left: 0;
25+
}
26+
27+
.Master {
28+
position: absolute;
29+
left: 0;
30+
width: 300px;
31+
top: 0;
32+
bottom: 0;
33+
}
34+
35+
.Detail {
36+
position: absolute;
37+
left: 302px;
38+
top: 0;
39+
bottom: 0;
40+
right: 0;
41+
}
42+
43+
.ContactList {
44+
list-style: none;
45+
padding: 0;
46+
margin: 0;
47+
}
48+
49+
.ContactList__Contact {
50+
display: block;
51+
padding: 4px 8px;
52+
font-size: 120%;
53+
}
54+
55+
.Heading {
56+
margin: 0;
57+
text-align: center;
58+
padding: 10px;
59+
background: #007adc;
60+
color: #fff;
61+
font-size: 100%;
62+
box-sizing: border-box;
63+
height: 40px;
64+
}
65+
66+
.Heading--alt {
67+
background-color: #4cd964;
68+
}
69+
70+
.Content {
71+
position: absolute;
72+
left: 0;
73+
right: 0;
74+
top: 41px;
75+
bottom: 0;
76+
overflow: scroll;
77+
}
78+
79+
.padBox {
80+
padding: 20px;
81+
}
82+
83+
.Avatar {
84+
height: 150px;
85+
width: 150px;
86+
border-radius: 50%;
87+
background: #ccc;
88+
display: inline-block;
89+
margin: 20px;
90+
}
91+
92+
.KVSet {
93+
margin: 20px;
94+
}
95+
96+
.KV {
97+
display: flex;
98+
flex-direction: row;
99+
}
100+
101+
.KV__Key,
102+
.KV__Value {
103+
box-sizing: border-box;
104+
margin: 10px;
105+
font-size: 150%;
106+
}
107+
108+
.KV__Key {
109+
width: 150px;
110+
color: hsl(0, 0%, 75%);
111+
}
112+
113+

app/handlers/Contact.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,31 @@ var Contact = module.exports = React.createClass({
2222
return <div/>;
2323

2424
return (
25-
<div>
26-
<h2>{contact.first} {contact.last}</h2>
25+
<div className="Contact">
26+
<h1 className="Heading Heading--alt">{contact.first} {contact.last}</h1>
27+
<div className="Content padBox">
28+
<img className="Avatar" key={contact.id} src={contact.avatar}/>
29+
<div className="KVSet">
30+
<div className="KV">
31+
<div className="KV__Key">First Name</div>
32+
<div className="KV__Value">{contact.first}</div>
33+
</div>
34+
<div className="KV">
35+
<div className="KV__Key">Last Name</div>
36+
<div className="KV__Value">{contact.last}</div>
37+
</div>
38+
<div className="KV">
39+
<div className="KV__Key">Avatar URL</div>
40+
<div className="KV__Value">{contact.avatar}</div>
41+
</div>
42+
<div className="KV">
43+
<div className="KV__Key"> </div>
44+
<div className="KV__Value">
45+
<a onClick={this.startEditing} href="#">edit</a>
46+
</div>
47+
</div>
48+
</div>
49+
</div>
2750
</div>
2851
);
2952
}

app/handlers/Root.js

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@ var Root = module.exports = React.createClass({
2626
this.setState({contacts: newProps.contacts});
2727
},
2828

29-
renderContacts: function() {
30-
if (!this.props.contacts)
31-
return null;
32-
33-
var contacts = this.state.contacts.records;
34-
return contacts.map(function(contact) {
35-
return <li key={contact.id}>
36-
<Link to="contact" params={{id: contact.id}}>{contact.first} {contact.last}</Link>
37-
</li>;
38-
});
39-
},
40-
4129
componentDidMount: function() {
4230
ContactStore.addChangeListener(this.handleContactsChange);
4331
},
@@ -50,15 +38,41 @@ var Root = module.exports = React.createClass({
5038
this.setState({contactData: ContactStore.getAll()});
5139
},
5240

41+
renderContacts: function() {
42+
if (!this.props.contacts)
43+
return null;
44+
45+
var contacts = this.state.contacts.records;
46+
return contacts.map(function(contact) {
47+
return (
48+
<li key={contact.id}>
49+
<Link
50+
className="ContactList__Contact"
51+
to="contact"
52+
params={{id: contact.id}}
53+
>
54+
{contact.first} {contact.last}
55+
</Link>
56+
</li>
57+
);
58+
});
59+
},
60+
5361
render: function() {
5462
return (
55-
<div>
56-
<h1>Address Book</h1>
57-
<NewContactForm/>
58-
<ul>
59-
{this.renderContacts()}
60-
</ul>
61-
{this.props.activeRouteHandler()}
63+
<div className="App">
64+
<div className="Master">
65+
<h2 className="Heading">Contacts</h2>
66+
<div className="Content">
67+
<ul className="ContactList">
68+
{this.renderContacts()}
69+
</ul>
70+
</div>
71+
</div>
72+
73+
<div className="Detail">
74+
{this.props.activeRouteHandler()}
75+
</div>
6276
</div>
6377
);
6478
}

app/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ var mainJS = fs.readFileSync(__dirname+'/../public/js/main.js');
1010

1111
require('mach').serve(function (req, res) {
1212
switch (req.path) {
13-
case '/styles.css':
14-
return fs.readFileSync(__dirname+'/assets/styles.css');
1513
case '/js/main.js':
1614
return mainJS;
1715
case '/favicon.ico':
1816
return 'haha';
1917
default:
18+
if (req.path.match(/^\/styles.css/))
19+
return fs.readFileSync(__dirname+'/assets/styles.css');
2020
return renderApp(req.path);
2121
}
2222
}, process.env.PORT || 5000);

0 commit comments

Comments
 (0)