Skip to content

Commit 344652a

Browse files
committed
Hide settings on any click outside it when open
1 parent c5d5a99 commit 344652a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

public/style.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
body {
22
background-color: #fff;
3+
margin: 0;
34
}
45
form {
56
margin: 0;
@@ -52,10 +53,11 @@ span.control:hover {
5253
}
5354
}
5455

55-
.App {
56+
.App__wrap {
5657
width: 90%;
5758
max-width: 1280px;
5859
margin: 0 auto;
60+
padding: 8px 0;
5961
color: #000;
6062
background-color: #f5f5f5;
6163
font-size: 13.3333px;

src/Settings.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ var Settings = React.createClass({
1515
SettingsStore.save()
1616
},
1717

18+
onClick(e) {
19+
e.stopPropagation()
20+
},
21+
1822
render() {
19-
return <div ref="container" className="Settings" tabIndex="-1">
23+
return <div ref="container" className="Settings" tabIndex="-1" onClick={this.onClick}>
2024
<form onChange={this.onChange}>
2125
<div className="Settings__setting Settings__setting--checkbox">
2226
<label htmlFor="autoCollapse">

src/app.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ var App = React.createClass({
5252
},
5353

5454
render() {
55-
return <div className="App">
55+
return <div className="App" onClick={this.state.showSettings && this.toggleSettings}>
56+
<div className="App__wrap">
5657
<div className="App__header">
5758
<img src="logo.png" width="16" height="16" alt="" />{' '}
5859
<Link to="news" className="App__homelink">React HN</Link>{' '}
@@ -69,6 +70,7 @@ var App = React.createClass({
6970
<div className="App__footer">
7071
react-hn v{process.env.VERSION} | <a href="https://github.com/insin/react-hn">insin/react-hn</a>
7172
</div>
73+
</div>
7274
</div>
7375
}
7476
})

0 commit comments

Comments
 (0)