Skip to content

Commit f521bf5

Browse files
committed
Added styling, placeholder data and todos
1 parent 8ba3b0b commit f521bf5

File tree

7 files changed

+111
-6
lines changed

7 files changed

+111
-6
lines changed

src/__tests__/App.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { render, screen } from '@testing-library/react';
2-
import App from './App';
2+
import App from '../components/App';
33

44
test('renders learn react link', () => {
55
render(<App />);
6-
const linkElement = screen.getByText(/learn react/i);
6+
const linkElement = screen.getByText("Intro to React II");
77
expect(linkElement).toBeInTheDocument();
88
});

src/components/App.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import '../styles/app.css';
1+
import "../styles/app.css";
2+
import Post from "./Post";
23

3-
function App() {
4+
const App = () => {
45
return (
56
<div className="app">
6-
App component
7+
<div className="app__background-wrap" />
8+
<div className="app__foreground-wrap">
9+
<div className="app__title">Intro to React II</div>
10+
{
11+
// TODO: Send data to Post component and verify it works
12+
// wrap all Posts in a PostList component
13+
// TODO: Create a Postlist component to wrap all Posts in,
14+
// display name of last upvoted post at the top
15+
}
16+
<Post />
17+
</div>
718
</div>
819
);
920
}

src/components/Post.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react";
2+
3+
const Post = (props) => {
4+
return (
5+
<div className="post">
6+
<div className="post-heading">
7+
{
8+
// TODO: Use data from props to populate title, author, date
9+
// published, body and tags, validate props
10+
}
11+
<h2>"title"</h2>
12+
{
13+
// TODO: show post body if isPublished, or 'Coming soon!' if not
14+
}
15+
</div>
16+
<div className="post-author">Author: "author"</div>
17+
<div className="post-date">Published: "date"</div>
18+
<h3>Tags:</h3>
19+
{
20+
// TODO: Create list of all all provided tags
21+
}
22+
</div>
23+
);
24+
};
25+
26+
export default Post;

src/data/posts.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"id": 1,
4+
"title": "Should I learn React?",
5+
"body": "React is a declarative, efficient, and flexible JavaScript library for building UIs (user interfaces) in web apps (viewed in the browser). It has gained popularity steadily since then and is one of the most in demand front end libraries in use today.",
6+
"tags": ["react", "introduction", "front end", "2023"],
7+
"author": "September22",
8+
"date": "17-01-2023",
9+
"isPublished": true
10+
},
11+
{
12+
"id": 2,
13+
"title": "React is awesome!",
14+
"body": "React has some extremely useful features, including the ability to hold and manipulate data, handle user events, provide validation for props, multiple hooks (and the functionality to implement your own custom hooks from scratch), and its widespread use means support can often be found in the community",
15+
"tags": ["react", "further introduction", "lecture 2", "state", "props"],
16+
"author": "September22",
17+
"date": "19-01-2023",
18+
"isPublished": true
19+
},
20+
{
21+
"id": 3,
22+
"title": "Lifecycle and hooks in React!",
23+
"body": "Useful hooks include useState, useEffect, useContext, useRef... and many more. Will be looking some of these soon enough",
24+
"tags": ["react", "hooks", "lecture 3", "useEffect", "useContext"],
25+
"author": "September22",
26+
"date": "24-01-2023",
27+
"isPublished": false
28+
}
29+
]
File renamed without changes.

src/index.css

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
html,
2+
body,
3+
#root {
4+
height: 100%;
5+
box-sizing: border-box;
6+
}
7+
8+
body {
9+
background-color: black;
10+
color: white;
11+
}
12+
113
body {
214
margin: 0;
315
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',

src/styles/app.css

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
.app {
2-
text-align: center;
2+
position: relative;
3+
box-sizing: border-box;
4+
padding: 2em 4em;
5+
min-height: 100%;
6+
}
7+
8+
.app__background-wrap {
9+
background-image: url("../images/logo192.png");
10+
content: "";
11+
position: absolute;
12+
z-index: -1;
13+
top: 0;
14+
bottom: 0;
15+
left: 0;
16+
right: 0;
17+
opacity: 0.5;
318
}
19+
20+
.app__foreground-wrap {
21+
background-color: rgb(20,20,20, 0.9);
22+
}
23+
24+
.app__title {
25+
font-size: 2em;
26+
font-weight: bold;
27+
color: white;
28+
text-align: center;
29+
padding-bottom: 1rem;
30+
}

0 commit comments

Comments
 (0)