Skip to content

Bump websocket-extensions from 0.1.3 to 0.1.4 #1

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

Open
wants to merge 2 commits 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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"normalize.css": "^8.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"styled-components": "^5.1.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link href="https://fonts.googleapis.com/css?family=Bitter|Montserrat:400,500,600&display=swap" rel="stylesheet">
<title>React App</title>
</head>
<body>
Expand Down
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

40 changes: 22 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { Switch, Route } from 'react-router-dom';
import GlobalStyle from './GlobalStyle';
import Header from './components/Header';
import Home from './pages/Home';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<>
<GlobalStyle />
<Header />

<main>
<Switch>
<Route path="/how-it-works">
<h1>How it works</h1>
</Route>
<Route path="/about">
<h1>About</h1>
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
</main>
</>
);
}

Expand Down
35 changes: 35 additions & 0 deletions src/GlobalStyle.js
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;
15 changes: 15 additions & 0 deletions src/components/Button/Button.style.js
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;
`;
1 change: 1 addition & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button as default } from './Button.style';
8 changes: 8 additions & 0 deletions src/components/Container/Container.style.js
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;
`;
1 change: 1 addition & 0 deletions src/components/Container/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Container as default } from './Container.style';
25 changes: 25 additions & 0 deletions src/components/Header/Header.js
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;
23 changes: 23 additions & 0 deletions src/components/Header/Header.style.js
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;
`;
1 change: 1 addition & 0 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Header';
1 change: 1 addition & 0 deletions src/components/Header/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

13 changes: 5 additions & 8 deletions src/index.js
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();
7 changes: 0 additions & 7 deletions src/logo.svg

This file was deleted.

32 changes: 32 additions & 0 deletions src/pages/Home/Form.js
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;
25 changes: 25 additions & 0 deletions src/pages/Home/Form.style.js
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;
}
`;
47 changes: 47 additions & 0 deletions src/pages/Home/Home.js
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;
Loading