Skip to content

Commit

Permalink
Merge pull request #11 from bennyo27/development
Browse files Browse the repository at this point in the history
Can now remove search results and styled log in/out button
  • Loading branch information
bennyo27 authored Jan 2, 2019
2 parents 22aaabd + 8c764ca commit caaf58f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 12 deletions.
17 changes: 17 additions & 0 deletions src/components/App/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,20 @@
.navbar li {
align-self: center;
}

.log-button {
text-decoration: none;
background-color: #fcf1d7;
color: #db8030;
padding: 5px 10px 7px;
border-radius: 20px;
margin-top: 10px;
margin-right: 10px;
cursor: pointer;
transition: 0.4s;
}

.log-button:hover {
background-color: #d36135;
color: #fcf1d7;
}
11 changes: 6 additions & 5 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class App extends Component {
const data = { username, email, email_verified };
axios.post("https://filmsy-app.herokuapp.com/users", data).then(() => {
axios.get(`https://filmsy-app.herokuapp.com/users/${email}`).then(res => {
console.log(res.data);
localStorage.setItem("username", res.data.username);
localStorage.setItem("email", res.data.email);
localStorage.setItem("email_verified", res.data.email_verified);
Expand Down Expand Up @@ -73,16 +72,18 @@ class App extends Component {
</li>
<li>
{!localStorage.getItem("accessToken") && (
<button
<div
className="log-button"
onClick={() => {
lock.show();
}}
>
Login
</button>
</div>
)}
{localStorage.getItem("accessToken") && (
<button
<div
className="log-button"
onClick={() => {
localStorage.removeItem("accessToken");
localStorage.removeItem("username");
Expand All @@ -92,7 +93,7 @@ class App extends Component {
}}
>
Logout
</button>
</div>
)}
</li>
</ul>
Expand Down
14 changes: 9 additions & 5 deletions src/components/Home/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
color: #282b28;
}

.search .close-btn {
.search-btn {
position: absolute;
top: 1.5px;
right: 3px;
top: 0.8px;
right: 0.5px;
cursor: pointer;
color: #fc913a;
background: #fff;
Expand All @@ -51,6 +51,10 @@
font-weight: bold;
}

#search-btn:hover {
color: gray;
}

.featured {
background-color: #d36135;
}
Expand All @@ -59,10 +63,10 @@
color: white;
}

.results {
#results {
max-width: 500px;
width: 100%;
display: inline-block;
display: none;
margin-top: 428px;
}

Expand Down
26 changes: 24 additions & 2 deletions src/components/Home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ class Home extends Component {
handleSubmit = e => {
e.preventDefault();
this.props.searchMovies(this.state.searchText);
let box = document.getElementById("results");
box.style.display = "inline-block";
};

componentWillMount() {
document.addEventListener("mousedown", this.handleClick, false);
}

componentWillUnmount() {
document.removeEventListener("mousedown", this.handleClick, false);
}

handleClick = e => {
if (this.node.contains(e.target)) {
return;
}

let box = document.getElementById("results");
console.log(e.target, box);
if (e.target != box && box.style.display == "inline-block") {
box.style.display = "none";
}
};

render() {
Expand All @@ -35,13 +57,13 @@ class Home extends Component {
<button
type="button"
value="search"
className="close-btn"
className="search-btn"
onClick={this.handleSubmit}
>
Search
</button>
</form>
<div className="results">
<div id="results" ref={node => (this.node = node)}>
{this.props.searchResults.map(result => {
if (result !== undefined) {
return (
Expand Down

0 comments on commit caaf58f

Please sign in to comment.