Skip to content

Commit

Permalink
Merge pull request #9 from TomPlum/dev
Browse files Browse the repository at this point in the history
Home page refactor
  • Loading branch information
TomPlum authored Oct 3, 2023
2 parents f09706f + ba789a1 commit f6c9e48
Show file tree
Hide file tree
Showing 26 changed files with 261 additions and 70 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

Practice reading real Japanese from news articles published in Japan.

# Data Sources
## Local Development

1. Clone the repository
```sh
git clone [email protected]:TomPlum/nyuusu.git
```

2. Install NPM dependencies
```sh
npm install
```

3. Run the local development server
```sh
npm run dev
```

## Data Sources

- The Newscatcher API is used to fetch news article information used in this application. See https://www.newscatcherapi.com/ for more info.
Binary file added src/assets/cards.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/newspaper.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/components/Typography/Typography.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "styles/mixins";

.vertical {
@include vertical-text;
}
17 changes: 17 additions & 0 deletions src/components/Typography/Typography.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { TypographyProps } from "./types.ts"
import { PropsWithChildren } from "react"
import styles from './Typography.module.scss'
import classNames from "classnames"
import { useSettingsContext } from "modules/Settings/context/useSettingsContext.ts"

const Typography = ({ children, className }: PropsWithChildren<TypographyProps>) => {
const { language } = useSettingsContext()

return (
<p className={classNames(className, { [styles.vertical]: language === 'jp' })}>
{children}
</p>
)
}

export default Typography
1 change: 1 addition & 0 deletions src/components/Typography/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Typography.tsx'
3 changes: 3 additions & 0 deletions src/components/Typography/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface TypographyProps {
className?: string
}
2 changes: 1 addition & 1 deletion src/hooks/useLocale/useLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import enLocale from "date-fns/locale/en-GB"
import jpLocale from "date-fns/locale/ja"
import { useSettingsContext } from "modules/Settings/context/useSettingsContext.ts"

const useLocale = () => {
const useLocale = (): Locale => {
const { language } = useSettingsContext()

return useMemo(() => {
Expand Down
23 changes: 20 additions & 3 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,30 @@
}
},
"home": {
"title": "ニュース。",
"article": {
"publisher": "NYUSU.COM",
"rights": "The copyright of the materials belongs to nyusu.com unless stated otherwise.",
"feed-title": "Latest Japanese headlines",
"body": "Nyusu.com is a small side-project of mine that aims to test your Japanese reading ability using headlines and excerpts from real Japanese news articles written by and for native Japanese people."
},
"title": [
"Most newspapers use only the 2136 characters in the jōyō kanji table.",
"The 5 major daily newspapers are the Yomiuri, Asahi, Mainichi, Sankei and Nihon Keizai Shimbun.",
"Today there are said to be 121 daily newspapers that are members of the NSK."
],
"newspaper": {
"title": "Newspaper",
"desc": "A full-page newspaper article excerpt."
},
"articles": {
"title": "Articles",
"desc": "A library of short article headlines."
"desc": "A library of short article headlines.",
"cards": {
"body": "Browse lots of headlines at a glance. Sort by difficulty and filter by source to find the best material for you."
},
"newspaper": {
"body": "View a single headline in detail. Read related text from an excerpt from the article. See detailed information about the difficulty rating and export the contents into an Anki card."
}
}
}
},
Expand Down Expand Up @@ -125,7 +141,8 @@
"heading": "Anki",
"deck": {
"label": "Deck Name",
"help": "Cannot be empty."
"help": "Folders are separated by ::",
"error": "Cannot be empty."
},
"tags": {
"label": "Tags",
Expand Down
23 changes: 20 additions & 3 deletions src/locales/jp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,30 @@
}
},
"home": {
"title": ["ニュースの見出し。", "記事内容。", "読書の練習", "最新情報"],
"article": {
"publisher": "ニュース・コム",
"rights": "特に断りのない限り、著作権はnyusu.comに帰属します。",
"feed-title": "最新の日本の見出しと記事",
"body": "Nyusu.comは私の小さなサイドプロジェクトで、ネイティブの日本人によって書かれた実際の日本のニュース記事の見出しや抜粋を使って、日本語の読解力をテストすることを目的としている。"
},
"title": [
"ほとんどの新聞は常用漢字表の2136文字しか使わない。",
"5大日刊紙とは、読売新聞、朝日新聞、毎日新聞、産経新聞、日本経済新聞である。",
"現在、NSKに加盟している日刊紙は121紙と言われている。"
],
"newspaper": {
"title": "新聞",
"desc": "新聞記事の抜粋。"
},
"articles": {
"title": "記事",
"desc": "短い記事の見出しのライブラリ。"
"desc": "短い記事の見出しのライブラリ。",
"cards": {
"body": "たくさんの見出しを一目で閲覧できる。難易度でソートし、ソースでフィルタリングして、あなたに最適な記事を見つけよう。"
},
"newspaper": {
"body": "見出しの詳細を見る。 記事の抜粋から関連する文章を読む。難易度の詳細情報を見て、内容をAnkiカードにエクスポートする。"
}
}
}
},
Expand Down Expand Up @@ -118,7 +134,8 @@
"heading": "アンキ",
"deck": {
"label": "デッキ名",
"help": "空は不可"
"help": "フォルダは「::」で区切られる。",
"error": "空は不可"
},
"tags": {
"label": "タグ",
Expand Down
3 changes: 2 additions & 1 deletion src/modules/Newspaper/components/Banner/Banner.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
.border {
border-top: 1px solid $black-ink;
border-bottom: 1px solid $black-ink;
padding: 0 30px;
padding: 8px 30px;
margin-bottom: 5px;
}

.title {
Expand Down
24 changes: 13 additions & 11 deletions src/modules/Newspaper/components/Headline/Headline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ const Headline = ({ headline }: HeadlineProps) => {
const { t } = useTranslation('translation', { keyPrefix: 'newspaper.headline' })

const copy = useCallback(() => {
navigator.clipboard.writeText(headline).then(() => {
fireToast({
type: 'success',
timeout: 2000,
message: t('copy.success')
if (typeof headline === 'string') {
navigator.clipboard.writeText(headline).then(() => {
fireToast({
type: 'success',
timeout: 2000,
message: t('copy.success')
})
}).catch(() => {
fireToast({
type: 'error',
message: t('copy.error')
})
})
}).catch(() => {
fireToast({
type: 'error',
message: t('copy.error')
})
})
}
}, [fireToast, headline, t])

return (
Expand Down
4 changes: 3 additions & 1 deletion src/modules/Newspaper/components/Headline/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ReactElement } from "react"

export interface HeadlineProps {
headline: string
headline: string | ReactElement
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const AnkiDeckSelector = () => {
label={t('label')}
onChange={handleChange}
id='anki-deck-name-selector'
helperText={error ? t('help') : ''}
data-testid='anki-deck-name-selector'
helperText={error ? t('error') : t('help')}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "styles/colours";

.section {
margin-bottom: 10px;
margin-bottom: 5px;
display: flex;
flex-direction: column;

Expand Down
1 change: 1 addition & 0 deletions src/styles/_colours.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// TODO: Move colours here and establish themes

$newspaper: #f9f7f1;
$newspaper-secondary: #fffff8;
$white: #ffffff;
$black-ink: #2e2e2e;
$muted: #686767;
Expand Down
35 changes: 23 additions & 12 deletions src/views/HomeView/HomeView.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
@import "styles/colours";

.view {
height: 100%;
width: 100%;
height: 100%;
background-color: $newspaper;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
}

.wrapper {
color: $black-ink;
height: 100%;
.content {
width: 100%;
max-width: 1000px;
align-items: flex-start;
padding-top: 20px;
}

.left {
Expand Down Expand Up @@ -38,19 +43,25 @@
margin-bottom: 0;
}

.typewriter {
font-size: 5em;
}

.cursor {
font-size: 5em;
}

.dateContainer {
width: 100%;
max-width: 1500px;
}

.date {
color: $black-ink;
}

.typeArticle {
&:hover {
border-radius: 5px;
cursor: pointer;
background-clip: content-box;
background-color: $newspaper-secondary;
transition: all ease-in-out 0.2s;
}
}

.article {
color: $black-ink;
}
Loading

0 comments on commit f6c9e48

Please sign in to comment.