-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
455 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { createGlobalStyle } from 'styled-components'; | ||
|
||
const GlobalStyle = createGlobalStyle` | ||
*, *::before, *::after { | ||
box-sizing: border-box; | ||
} | ||
body { | ||
font-family: "Montserrat", sans-serif; | ||
font-size: 16px; | ||
line-height: 1.69; | ||
color: #93918f; | ||
h1, h2, h3, h4, h5, h6 { | ||
color: #000000; | ||
font-family: "Bitter", serif; | ||
font-weight: normal; | ||
text-align: center; | ||
} | ||
h1 { | ||
font-size: 2.375em; | ||
} | ||
h2 { | ||
font-size: 1.5em; | ||
} | ||
a { | ||
color: #0087ff; | ||
} | ||
} | ||
`; | ||
|
||
export default GlobalStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Button = styled.button` | ||
height: 36px; | ||
line-height: 36px; | ||
padding: 0 16px; | ||
font-size: 14px; | ||
font-weight: 500; | ||
color: #ffffff; | ||
background: #fdb755; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
text-transform: uppercase; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Button as default } from './Button.style'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
width: 100%; | ||
max-width: 778px; | ||
margin: auto; | ||
padding: 0 20px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Container as default } from './Container.style'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { Container, Logo, NavLink } from './Header.style'; | ||
|
||
function Header() { | ||
return ( | ||
<Container as="header"> | ||
<Link to="/"> | ||
<Logo /> | ||
</Link> | ||
|
||
<nav> | ||
<NavLink to="/how-it-works"> | ||
How it works | ||
</NavLink> | ||
|
||
<NavLink to="/about"> | ||
About | ||
</NavLink> | ||
</nav> | ||
</Container> | ||
); | ||
} | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import styled from 'styled-components'; | ||
import { Link } from 'react-router-dom'; | ||
import { ReactComponent } from './logo.svg'; | ||
|
||
export const Container = styled.header` | ||
width: 100%; | ||
height: 100px; | ||
margin: 0 auto; | ||
padding: 0 80px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
`; | ||
|
||
export const Logo = styled(ReactComponent)` | ||
margin-top: 8px; | ||
`; | ||
|
||
export const NavLink = styled(Link)` | ||
margin-left: 26px; | ||
text-decoration: none; | ||
color: #636363; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Header'; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import 'normalize.css'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import App from './App'; | ||
import * as serviceWorker from './serviceWorker'; | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
<Router> | ||
<App /> | ||
</Router> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
); | ||
|
||
// If you want your app to work offline and load faster, you can change | ||
// unregister() to register() below. Note this comes with some pitfalls. | ||
// Learn more about service workers: https://bit.ly/CRA-PWA | ||
serviceWorker.unregister(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState } from 'react'; | ||
import Button from '../../components/Button'; | ||
import { FormContainer, Label, Input } from './Form.style'; | ||
|
||
function Form({ onSearch }) { | ||
const [subreddit, setSubreddit] = useState('javascript'); | ||
|
||
const onSubmit = (event) => { | ||
event.preventDefault(); | ||
onSearch(subreddit); | ||
}; | ||
|
||
return ( | ||
<FormContainer onSubmit={onSubmit}> | ||
<Label> | ||
r / | ||
<Input | ||
type="text" | ||
name="subreddit" | ||
value={subreddit} | ||
onChange={(event) => setSubreddit(event.target.value)} | ||
/> | ||
</Label> | ||
|
||
<Button type="submit"> | ||
Search | ||
</Button> | ||
</FormContainer> | ||
); | ||
} | ||
|
||
export default Form; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const FormContainer = styled.form` | ||
margin: 20px 0 0; | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
export const Label = styled.label` | ||
font-size: 18px; | ||
`; | ||
|
||
export const Input = styled.input` | ||
width: 370px; | ||
height: 36px; | ||
margin: 0 10px; | ||
padding: 0 15px; | ||
font-size: 14px; | ||
color: #000000; | ||
border: 1px solid #d5d5d5; | ||
:focus, :active { | ||
border: 1px solid #d5d5d5; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState } from 'react'; | ||
import Container from '../../components/Container'; | ||
import { Section, Headline, Status, TopPosts } from './Home.style'; | ||
import Form from './Form'; | ||
|
||
function Home() { | ||
const [posts, setPosts] = useState([]); | ||
const [status, setStatus] = useState('idle') | ||
|
||
const onSearch = async (subreddit) => { | ||
setStatus('loading'); | ||
const url = `https://www.reddit.com/r/${subreddit}/top.json`; | ||
const response = await fetch(url); | ||
const { data } = await response.json(); | ||
setPosts(data.children); | ||
setStatus('resolved'); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<Section> | ||
<Headline> | ||
Find the best time for a subreddit | ||
</Headline> | ||
|
||
<Form onSearch={onSearch} /> | ||
</Section> | ||
|
||
{ | ||
status === 'loading' && ( | ||
<Status> | ||
Is loading | ||
</Status> | ||
) | ||
} | ||
{ | ||
status === 'resolved' && ( | ||
<TopPosts> | ||
Number of top posts: {posts.length} | ||
</TopPosts> | ||
) | ||
} | ||
</Container> | ||
); | ||
} | ||
|
||
export default Home; |
Oops, something went wrong.