Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment completed #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/components/About.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

const About = ({ image = "https://via.placeholder.com/215", about }) => {
return (
<aside>
<img src={image} alt="blog logo" />
<p>{about}</p>
</aside>
);
};

export default About;
10 changes: 7 additions & 3 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React from "react";
import blogData from "../data/blog";
import Head from "../components/Header";
import About from "./About";
import ArticleList from "./ArticleList";

console.log(blogData);

function App() {
return (
<div className="App">
You're on your own from here! Follow the deliverables; test things out in
the browser as you write your code; and good luck!
<Head name={blogData.name} />
<About image={blogData.image} about={blogData.about} />
<ArticleList posts={blogData.posts} />
</div>
);
}

export default App;
export default App;
27 changes: 27 additions & 0 deletions src/components/Article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
function makeEmojiList(minutes) {
const interval = minutes < 30 ? 5 : 10;
const emoji = minutes < 30 ? "☕️" : "🍱";

let emojis = "";
for (let i = 0; i < minutes; i += interval) {
emojis += emoji;
}

return emojis;
}

function Articles({ title, date = "January 1, 1970", preview, minutes }) {
const emojis = makeEmojiList(minutes);
return (
<article>
<h3> {title} </h3>
<small>
{" "}
{date} • {emojis} {minutes} min read
</small>
<p>{preview}</p>
</article>
);
}
export default Articles;
16 changes: 16 additions & 0 deletions src/components/ArticleList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import Articles from "./Article";

function ArticleList({ posts }) {
const articles = posts.map((post) => (
<Articles
key={post.id}
title={post.title}
date={post.date}
preview={post.preview}
minutes={post.minutes}
/>
));
return <main>{articles}</main>;
}
export default ArticleList;
11 changes: 11 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

const Header = ({ name }) => {
return (
<header>
<h1>{name}</h1>
</header>
);
};

export default Header;