Skip to content

Commit

Permalink
Cleaned up pages
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonwoo committed Mar 28, 2020
1 parent cf85f47 commit be81320
Show file tree
Hide file tree
Showing 41 changed files with 1,229 additions and 1,217 deletions.
13 changes: 7 additions & 6 deletions pages/active.tsx
Expand Up @@ -5,19 +5,20 @@ import { sampleData } from '../src/data/sample-data';
import { withDataAndRouter } from '../src/helpers/with-data';
import { MainLayout } from '../src/layouts/main-layout';

export const ActivePage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function ActivePage(props): JSX.Element {
const { router } = props;
const pageNumber = (router.query && +router.query.p) || 0;

return (
<MainLayout currentUrl={props.router.pathname}>
<MainLayout currentUrl={router.pathname}>
<NewsFeedView
currentUrl={props.router.pathname}
currentUrl={router.pathname}
first={30}
newsItems={sampleData.newsItems}
skip={pageNumber * 30}
/>
</MainLayout>
);
});
}

export default ActivePage;
export default withDataAndRouter(ActivePage);
13 changes: 7 additions & 6 deletions pages/ask.tsx
Expand Up @@ -25,19 +25,20 @@ export interface IAskPageProps {
};
}

export const AskPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function AskPage(props): JSX.Element {
const { router } = props;
const pageNumber = (router.query && +router.query.p) || 0;

const first = POSTS_PER_PAGE;
const skip = POSTS_PER_PAGE * pageNumber;

const { data } = useQuery(query, { variables: { first, skip, type: FeedType.ASK } });

return (
<MainLayout currentUrl={props.router.pathname}>
<NewsFeed data={data} currentUrl={props.router.pathname} first={first} skip={skip} />
<MainLayout currentUrl={router.pathname}>
<NewsFeed data={data} currentUrl={router.pathname} first={first} skip={skip} />
</MainLayout>
);
});
}

export default AskPage;
export default withDataAndRouter(AskPage);
14 changes: 8 additions & 6 deletions pages/best.tsx
Expand Up @@ -25,19 +25,21 @@ export interface IBestNewsFeedProps {
};
}

export const BestPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function BestPage(props): JSX.Element {
const { router } = props;

const pageNumber = (router.query && +router.query.p) || 0;

const first = POSTS_PER_PAGE;
const skip = POSTS_PER_PAGE * pageNumber;

const { data } = useQuery(query, { variables: { first, skip, type: FeedType.BEST } });

return (
<MainLayout currentUrl={props.router.pathname}>
<NewsFeed data={data} currentUrl={props.router.pathname} first={first} skip={skip} />
<MainLayout currentUrl={router.pathname}>
<NewsFeed data={data} currentUrl={router.pathname} first={first} skip={skip} />
</MainLayout>
);
});
}

export default BestPage;
export default withDataAndRouter(BestPage);
14 changes: 8 additions & 6 deletions pages/bestcomments.tsx
Expand Up @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data';
import { withDataAndRouter } from '../src/helpers/with-data';
import { MainLayout } from '../src/layouts/main-layout';

export const BestCommentsPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function BestCommentsPage(props): JSX.Element {
const { router } = props;

const pageNumber = (router.query && +router.query.p) || 0;

return (
<MainLayout currentUrl={props.router.pathname}>
<MainLayout currentUrl={router.pathname}>
<NewsFeedView
currentUrl={props.router.pathname}
currentUrl={router.pathname}
first={30}
newsItems={sampleData.newsItems}
skip={pageNumber * 30}
/>
</MainLayout>
);
});
}

export default BestCommentsPage;
export default withDataAndRouter(BestCommentsPage);
78 changes: 40 additions & 38 deletions pages/bookmarklet.tsx
Expand Up @@ -3,47 +3,49 @@ import * as React from 'react';

import { NoticeLayout } from '../src/layouts/notice-layout';

export const BookmarkletPage = (props) => (
<NoticeLayout>
<b>Bookmarklet</b>
<br />
<br />
<div id="main">
<p id="first">
Thanks to Phil Kast for writing this bookmarklet for submitting links to{' '}
<Link href="/">
<a>Hacker News</a>
</Link>
. When you click on the bookmarklet, it will submit the page you&#39;re on. To install, drag
this link to your browser toolbar:
<br />
<br />
</p>
<div style={{ textAlign: 'center' }}>
<a
style={{ color: '#777', fontSize: '2em' }}
href="javascript:window.location=%22http://news.ycombinator.com/submitlink?u=%22+encodeURIComponent(document.location)+%22&amp;t=%22+encodeURIComponent(document.title)"
>
post to HN
</a>
</div>
export function BookmarkletPage(props): JSX.Element {
return (
<NoticeLayout>
<b>Bookmarklet</b>
<br />
<br />
<table style={{ padding: '0px', backgroundColor: '#ff6600', width: '100%' }}>
<tbody>
<tr style={{ height: '0px' }}>
<td style={{ padding: '0px' }} />
</tr>
</tbody>
</table>
<p style={{ textAlign: 'center' }}>
<span className="foot">
<div id="main">
<p id="first">
Thanks to Phil Kast for writing this bookmarklet for submitting links to{' '}
<Link href="/">
<a>Hacker News</a>
</Link>
. When you click on the bookmarklet, it will submit the page you&#39;re on. To install,
drag this link to your browser toolbar:
<br />
<br />
</span>
</p>
</div>
</NoticeLayout>
);
</p>
<div style={{ textAlign: 'center' }}>
<a
style={{ color: '#777', fontSize: '2em' }}
href="javascript:window.location=%22http://news.ycombinator.com/submitlink?u=%22+encodeURIComponent(document.location)+%22&amp;t=%22+encodeURIComponent(document.title)"
>
post to HN
</a>
</div>
<br />
<br />
<table style={{ padding: '0px', backgroundColor: '#ff6600', width: '100%' }}>
<tbody>
<tr style={{ height: '0px' }}>
<td style={{ padding: '0px' }} />
</tr>
</tbody>
</table>
<p style={{ textAlign: 'center' }}>
<span className="foot">
<br />
<br />
</span>
</p>
</div>
</NoticeLayout>
);
}

export default BookmarkletPage;
16 changes: 10 additions & 6 deletions pages/changepw.tsx
Expand Up @@ -3,10 +3,14 @@ import * as React from 'react';
import { withDataAndRouter } from '../src/helpers/with-data';
import { MainLayout } from '../src/layouts/main-layout';

export const ChangePasswordPage = withDataAndRouter((props) => (
<MainLayout currentUrl={props.router.pathname}>
<h1>Change PW</h1>
</MainLayout>
));
export function ChangePasswordPage(props): JSX.Element {
const { router } = props;

export default ChangePasswordPage;
return (
<MainLayout currentUrl={router.pathname}>
<h1>Change PW</h1>
</MainLayout>
);
}

export default withDataAndRouter(ChangePasswordPage);
14 changes: 8 additions & 6 deletions pages/favorites.tsx
Expand Up @@ -25,19 +25,21 @@ export interface INewestNewsFeedOwnProps {
};
}

export const FavoritesPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function FavoritesPage(props): JSX.Element {
const { router } = props;

const pageNumber = (router.query && +router.query.p) || 0;

const first = POSTS_PER_PAGE;
const skip = POSTS_PER_PAGE * pageNumber;

const { data } = useQuery(query, { variables: { first, skip, type: FeedType.NEW } });

return (
<MainLayout currentUrl={props.router.pathname}>
<NewsFeed data={data} currentUrl={props.router.pathname} first={first} skip={skip} />
<MainLayout currentUrl={router.pathname}>
<NewsFeed data={data} currentUrl={router.pathname} first={first} skip={skip} />
</MainLayout>
);
});
}

export default FavoritesPage;
export default withDataAndRouter(FavoritesPage);
11 changes: 3 additions & 8 deletions pages/forgot.tsx
@@ -1,5 +1,4 @@
import gql from 'graphql-tag';
import { withRouter, NextRouter } from 'next/router';
import { NextRouter } from 'next/router';
import React, { useState } from 'react';

import { withDataAndRouter } from '../src/helpers/with-data';
Expand All @@ -9,7 +8,7 @@ export interface IForgotPageProps {
router: NextRouter; // { how: UserLoginErrorCode }
}

function ForgotPageView(props: IForgotPageProps): JSX.Element {
function ForgotPage(props: IForgotPageProps): JSX.Element {
const [username, setUsername] = useState<string>('');

return (
Expand All @@ -30,8 +29,4 @@ function ForgotPageView(props: IForgotPageProps): JSX.Element {
);
}

export const ForgotPage = withDataAndRouter(
withRouter((props) => <ForgotPageView router={props.router} />)
);

export default ForgotPage;
export default withDataAndRouter(ForgotPage);
10 changes: 6 additions & 4 deletions pages/formatdoc.tsx
Expand Up @@ -3,12 +3,14 @@ import * as React from 'react';
import { MainLayout } from '../src/layouts/main-layout';
import { withDataAndRouter } from '../src/helpers/with-data';

export const FormatDocPage = withDataAndRouter((props) => {
export function FormatDocPage(props): JSX.Element {
const { router } = props;

return (
<MainLayout
isFooterVisible={false}
isNavVisible={false}
currentUrl={props.router.pathname}
currentUrl={router.pathname}
title="Formatting Options"
>
<tr>
Expand Down Expand Up @@ -45,6 +47,6 @@ export const FormatDocPage = withDataAndRouter((props) => {
</tr>
</MainLayout>
);
});
}

export default FormatDocPage;
export default withDataAndRouter(FormatDocPage);
15 changes: 9 additions & 6 deletions pages/front.tsx
Expand Up @@ -3,10 +3,13 @@ import * as React from 'react';
import { withDataAndRouter } from '../src/helpers/with-data';
import { MainLayout } from '../src/layouts/main-layout';

export const FrontPage = withDataAndRouter((props) => (
<MainLayout currentUrl={props.router.pathname}>
<span>total</span>
</MainLayout>
));
export function FrontPage(props): JSX.Element {
const { router } = props;
return (
<MainLayout currentUrl={router.pathname}>
<span>total</span>
</MainLayout>
);
}

export default FrontPage;
export default withDataAndRouter(FrontPage);
14 changes: 8 additions & 6 deletions pages/hidden.tsx
Expand Up @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data';
import { withDataAndRouter } from '../src/helpers/with-data';
import { MainLayout } from '../src/layouts/main-layout';

export const HiddenPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function HiddenPage(props): JSX.Element {
const { router } = props;

const pageNumber = (router.query && +router.query.p) || 0;

return (
<MainLayout currentUrl={props.router.pathname}>
<MainLayout currentUrl={router.pathname}>
<NewsFeedView
currentUrl={props.router.pathname}
currentUrl={router.pathname}
first={30}
newsItems={sampleData.newsItems}
skip={pageNumber * 30}
/>
</MainLayout>
);
});
}

export default HiddenPage;
export default withDataAndRouter(HiddenPage);
14 changes: 8 additions & 6 deletions pages/index.tsx
Expand Up @@ -25,19 +25,21 @@ export interface ITopNewsFeedProps {
};
}

export const IndexPage = withDataAndRouter((props) => {
const pageNumber = (props.router.query && +props.router.query.p) || 0;
export function IndexPage(props): JSX.Element {
const { router } = props;

const pageNumber = (router.query && +router.query.p) || 0;

const first = POSTS_PER_PAGE;
const skip = POSTS_PER_PAGE * pageNumber;

const { data } = useQuery(query, { variables: { first, skip, type: FeedType.TOP } });

return (
<MainLayout currentUrl={props.router.pathname}>
<NewsFeed data={data} currentUrl={props.router.pathname} first={first} skip={skip} />
<MainLayout currentUrl={router.pathname}>
<NewsFeed data={data} currentUrl={router.pathname} first={first} skip={skip} />
</MainLayout>
);
});
}

export default IndexPage;
export default withDataAndRouter(IndexPage);

0 comments on commit be81320

Please sign in to comment.