-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some unused components, start putting styles and page structur…
…e in place
- Loading branch information
Showing
8 changed files
with
17 additions
and
256 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,12 @@ | ||
import Image from "next/image"; | ||
import { useRouter } from "next/router"; | ||
import React, { FC, useCallback } from "react"; | ||
import { useForm } from "react-hook-form"; | ||
import { FormattedMessage, useIntl, defineMessages } from "react-intl"; | ||
|
||
import { Button } from "~/atoms/Button"; | ||
import { Column } from "~/atoms/Column"; | ||
import { Icon } from "~/atoms/Icon"; | ||
import React, { FC } from "react"; | ||
import { PageContent } from "~/atoms/PageContent"; | ||
import { TextField } from "~/atoms/TextField"; | ||
import { H1 } from "~/atoms/typography/H1"; | ||
import { commonMessages } from "~/commonMessages"; | ||
import { scale } from "~/design"; | ||
import { LanguageSelector } from "~/molecules/LanguageSelector"; | ||
import { getSubredditPage } from "~/paths"; | ||
|
||
const messages = defineMessages({ | ||
title: { | ||
id: "pages.index.title", | ||
defaultMessage: "Go to subreddit", | ||
}, | ||
subreddit: { | ||
id: "pages.index.subreddit", | ||
defaultMessage: "Subreddit", | ||
}, | ||
placeholder: { | ||
id: "pages.index.input.placeholder", | ||
defaultMessage: "all", | ||
}, | ||
subredditRequired: { | ||
id: "pages.index.subredditRequired", | ||
defaultMessage: "Subreddit is required", | ||
}, | ||
}); | ||
|
||
export const IndexPage: FC = () => { | ||
const intl = useIntl(); | ||
const router = useRouter(); | ||
|
||
const { handleSubmit, register, errors, getValues } = useForm({ | ||
mode: "onChange", | ||
reValidateMode: "onChange", | ||
shouldFocusError: true, | ||
defaultValues: { | ||
subreddit: "all", | ||
}, | ||
}); | ||
|
||
const onSubmit = useCallback(() => { | ||
const { subreddit } = getValues(); | ||
|
||
const { href, as } = getSubredditPage({ subreddit }); | ||
router.push(href, as); | ||
}, [getValues, router]); | ||
|
||
return ( | ||
<PageContent> | ||
<Column alignCenter> | ||
<form | ||
css={({ scale }) => ({ | ||
padding: scale(6), | ||
width: "100%", | ||
maxWidth: scale(120), | ||
})} | ||
onSubmit={handleSubmit(onSubmit)} | ||
> | ||
<div | ||
css={{ | ||
maxWidth: scale(40), | ||
margin: "0 auto", | ||
marginBottom: scale(14), | ||
}} | ||
> | ||
<Image | ||
src="/logo-fraktio-transparent.png" | ||
alt="Fraktio" | ||
layout="intrinsic" | ||
width={792} | ||
height={213} | ||
/> | ||
</div> | ||
<H1 css={({ scale }) => ({ marginBottom: scale(6) })}> | ||
<FormattedMessage {...messages.title} /> | ||
<Icon name="camera" /> | ||
</H1> | ||
|
||
<TextField | ||
id="subreddit" | ||
required | ||
label={intl.formatMessage(messages.subreddit)} | ||
name="subreddit" | ||
ref={register({ | ||
required: true, | ||
maxLength: 64, | ||
})} | ||
placeholder={intl.formatMessage(messages.placeholder)} | ||
error={ | ||
errors.subreddit && intl.formatMessage(messages.subredditRequired) | ||
} | ||
/> | ||
|
||
<Button css={{ width: "100%" }} type="submit"> | ||
<FormattedMessage {...commonMessages.submit} /> | ||
</Button> | ||
</form> | ||
<LanguageSelector /> | ||
</Column> | ||
<H1>Olutkerho.fi</H1> | ||
</PageContent> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,16 +1,10 @@ | ||
{ | ||
"app.head.description": "Kanalautanen simppelillä reddit hakukoneella", | ||
"app.head.title": "Next.js Kanalautanen", | ||
"app.head.description": "Olutkerho, No Limits", | ||
"app.head.title": "Olutkerho", | ||
"defaultMessages.submit": "Lähetä", | ||
"head.title.fix": "{title} - Next.js Rest Kanalautanen", | ||
"head.title.fix": "{title} - No Limits", | ||
"languages.en": "Englanti", | ||
"languages.fi": "Suomi", | ||
"pages.genericError.title": "Virhe", | ||
"pages.index.input.placeholder": "all", | ||
"pages.index.subreddit": "Subreddit", | ||
"pages.index.subredditRequired": "Subreddit on vaadittu", | ||
"pages.index.title": "Subreddit", | ||
"pages.r.head.description": "Katso postauksia r/{subreddit}", | ||
"pages.r.head.title": "r/{subreddit}", | ||
"pages.r.title": "Subreddit" | ||
"pages.index.input.placeholder": "all" | ||
} |