Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js committed Feb 6, 2018
2 parents d4baa2e + 9908ac5 commit 8f79216
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 101 deletions.
46 changes: 31 additions & 15 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React, { Component } from 'react';
import bootstrap from 'bootstrap/scss/bootstrap.scss';

import Header from './Header';
import Story from './Story';
import CreateStory from './CreateStory';
import posts from '../mock-posts';
import styles from '../styles/main.scss';
import styles from './App.scss';

class App extends Component {
constructor(props) {
super(props);
this.state = {
stories: posts,
form: false,
};

this.addStory = this.addStory.bind(this);
this.deleteStory = this.deleteStory.bind(this);
this.showForm = this.showForm.bind(this);
}

addStory(story) {
Expand All @@ -31,22 +34,35 @@ class App extends Component {
});
}

showForm() {
this.setState({
form: true,
});
}

render() {
let createForm = null;
if (this.state.form) {
createForm = <CreateStory addStory={this.addStory} />;
}
return (
<div className="container">
<CreateStory addStory={this.addStory} />
<div className="card-columns js-news-list">
{this.state.stories.map(story => (
<Story
key={story.heading}
heading={story.heading}
body={story.body}
image={story.image}
timestamp={story.timestamp}
deleteStory={this.deleteStory}
/>
))}
</div>
<div>
<Header showForm={this.showForm} />
<main className="container">
{createForm}
<div className="card-columns">
{this.state.stories.map(story => (
<Story
key={story.heading}
heading={story.heading}
body={story.body}
image={story.image}
timestamp={story.timestamp}
deleteStory={this.deleteStory}
/>
))}
</div>
</main>
</div>
);
}
Expand Down
21 changes: 21 additions & 0 deletions src/components/App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.news-list {
display: grid;
//overflow: hidden;
//width: 100%;
//padding: 0 20px;
grid-column-gap: 15px;
grid-row-gap: 15px;
grid-template-columns: 33% 33% 33%;

@media screen and (min-width:768px) {
//column-count: 2;
}

@media screen and (min-width:992px) {
//column-count: 3;
}

@media screen and (min-width:1200px) {
//column-count: 4;
}
}
4 changes: 2 additions & 2 deletions src/components/CreateStory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CreateStory extends Component {
<input
placeholder="Your heading"
type="text"
className="form-control js-new-post__heading"
className="form-control"
value={this.state.heading}
onChange={this.handleHeadingChange}
/>
Expand All @@ -82,7 +82,7 @@ class CreateStory extends Component {
<textarea
placeholder="Write something"
rows="3"
className="form-control js-new-post__main-text"
className="form-control"
value={this.state.body}
onChange={this.handleBodyChange}
/>
Expand Down
32 changes: 32 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { Component } from 'react';
import bootstrap from 'bootstrap/scss/bootstrap.scss';
import PropTypes from 'prop-types';
import StoriesFeed from './Story';

class Header extends Component {
render() {
return (
<nav className="navbar navbar-dark bg-dark">
<div className="container">
<a className="navbar-brand" href="#home">Local microblogging client</a>
<div>
<form className="form-inline my-2 my-lg-0">
<button
className="btn btn-outline-primary my-2 my-sm-0"
type="button"
onClick={this.props.showForm}
>New post
</button>
</form>
</div>
</div>
</nav>
);
}
}

Header.propTypes = {
showForm: PropTypes.func.isRequired,
};

export default Header;
2 changes: 1 addition & 1 deletion src/components/Story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StoriesFeed extends Component {
const date = datetime.toLocaleString('en-us', { day: 'numeric', month: 'long' });

return (
<section className="card js-news-list__item">
<section className="card">
<img className="card-img-top" src={this.props.image} alt="Card cap" />
<div className="card-body">
<h3 className="card-title">
Expand Down
2 changes: 1 addition & 1 deletion src/index-template.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<title>Local microblogging client</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
</head>
Expand Down
6 changes: 0 additions & 6 deletions src/styles/main.scss

This file was deleted.

6 changes: 0 additions & 6 deletions src/styles/modules/_colors.scss

This file was deleted.

27 changes: 0 additions & 27 deletions src/styles/partials/_base.scss

This file was deleted.

19 changes: 0 additions & 19 deletions src/styles/partials/_news-list.scss

This file was deleted.

24 changes: 0 additions & 24 deletions src/styles/partials/_typography.scss

This file was deleted.

0 comments on commit 8f79216

Please sign in to comment.