Skip to content

Commit

Permalink
feat(v2): add about page (#128)
Browse files Browse the repository at this point in the history
* feat(v2): add about page

* fix app icon when app is built

* fix typo in label
  • Loading branch information
murgatt committed Feb 5, 2024
1 parent 9b15d1d commit 5bcfc35
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/AppMenu/AppMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HomeIcon, SettingsIcon } from 'lucide-react';
import { HelpCircleIcon, HomeIcon, SettingsIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { NavigationMenu, NavigationMenuList } from '../ui/NavigationMenu';
import { AppMenuItem } from './AppMenuItem';
Expand All @@ -14,6 +14,9 @@ export const AppMenu = () => {
</AppMenuItem>
</NavigationMenuList>
<NavigationMenuList className="flex-col">
<AppMenuItem label={t('appMenu.about')} to="/about">
<HelpCircleIcon size="16" />
</AppMenuItem>
<AppMenuItem label={t('appMenu.settings')} to="/settings">
<SettingsIcon size="16" />
</AppMenuItem>
Expand Down
22 changes: 22 additions & 0 deletions src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

type ExternalLinkProps = {
href: string;
} & React.AnchorHTMLAttributes<HTMLAnchorElement>;

export const ExternalLink = React.forwardRef<HTMLAnchorElement, ExternalLinkProps>(
({ children, href, ...otherProps }, ref) => {
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
event.preventDefault();
window.electron.openExternalLink(href);
};

return (
<a href={href} ref={ref} {...otherProps} onClick={handleClick}>
{children}
</a>
);
},
);

ExternalLink.displayName = 'ExternalLink';
2 changes: 1 addition & 1 deletion src/components/UpdateAvailableModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { APP_WEBSITE_URL } from 'src/constants';
import { version } from '../../package.json';
import {
AlertDialog,
Expand All @@ -13,7 +14,6 @@ import {
} from './ui/AlertDialog';

const GITHUB_API_URL = 'https://api.github.com/repos/murgatt/recode-converter/releases/latest';
const APP_WEBSITE_URL = 'https://murgatt.github.io/recode-converter/';

export const UpdateAvailableModal = () => {
const { t } = useTranslation();
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const APP_WEBSITE_URL = 'https://murgatt.github.io/recode-converter/';
export const AUTHOR_GITHUB_URL = 'https://github.com/murgatt/';
export const GITHUB_REPOSITORY_URL = 'https://github.com/murgatt/recode-converter';
7 changes: 7 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"translation": {
"about": {
"appIconAlt": "Recode Converter icon",
"developedBy": "Developed by",
"githubLabel": "GitHub repository",
"websiteLabel": "Website"
},
"appMenu": {
"about": "About",
"home": "Converter",
"settings": "Settings"
},
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"translation": {
"about": {
"appIconAlt": "Icône de Recode Converter",
"developedBy": "Développé par",
"githubLabel": "Dépôt GitHub",
"websiteLabel": "Site web"
},
"appMenu": {
"about": "A propos",
"home": "Convertisseur",
"settings": "Paramètres"
},
Expand Down
5 changes: 5 additions & 0 deletions src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createHashRouter } from 'react-router-dom';
import { App } from './App';
import { About } from './routes/About';
import { Converter } from './routes/Converter';
import { Settings } from './routes/Settings';

Expand All @@ -15,6 +16,10 @@ export const router = createHashRouter([
path: '/settings',
element: <Settings />,
},
{
path: '/about',
element: <About />,
},
],
},
]);
43 changes: 43 additions & 0 deletions src/routes/About.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { GithubIcon, LinkIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { ExternalLink } from 'src/components/ExternalLink';
import { Button } from 'src/components/ui/Button';
import { Tooltip } from 'src/components/ui/Tooltip';
import { APP_WEBSITE_URL, AUTHOR_GITHUB_URL, GITHUB_REPOSITORY_URL } from 'src/constants';
import { version } from '../../package.json';

export const About = () => {
const { t } = useTranslation();

return (
<section className="flex h-screen flex-col items-center overflow-y-auto p-6">
<img alt={t('about.appIconAlt')} className="w-48 max-w-full" src="./icon.png" />
<div className="flex w-full flex-col items-center gap-3">
<h1 className="title-lg w-full text-center">Recode Converter</h1>
<p className="caption-sm">v{version}</p>
<p className="paragraph-sm">
{t('about.developedBy')}{' '}
<ExternalLink className="underline underline-offset-4" href={AUTHOR_GITHUB_URL}>
@murgatt
</ExternalLink>
</p>
<div className="flex gap-1">
<Tooltip content={t('about.githubLabel')} position="bottom">
<Button aria-label={t('about.githubLabel')} asChild size="icon" variant="ghost">
<ExternalLink href={GITHUB_REPOSITORY_URL}>
<GithubIcon size="16" />
</ExternalLink>
</Button>
</Tooltip>
<Tooltip content={t('about.websiteLabel')} position="bottom">
<Button aria-label={t('about.websiteLabel')} asChild size="icon" variant="ghost">
<ExternalLink href={APP_WEBSITE_URL}>
<LinkIcon size="16" />
</ExternalLink>
</Button>
</Tooltip>
</div>
</div>
</section>
);
};

0 comments on commit 5bcfc35

Please sign in to comment.