Skip to content

Commit

Permalink
Merge pull request #4 from EgorBlagov/support-info
Browse files Browse the repository at this point in the history
Add homepage button
  • Loading branch information
EgorBlagov authored Sep 18, 2020
2 parents 9325293 + 78de6e8 commit 6ab2360
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 11 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ npm run lint

I was not able to make **Electron** and **Parcel** best friends, so on `npm run dev` there are several reloads of electron app

# Localization

If you want to contribute, you should do:

- check available localizations at `/common/l10n/`
- make a new one using an existing one as sample
- add enum entry to `/common/l10n/index.ts`

Or you can just translate and submit an issue, I'll add new one.

# Support

- [PayPal](https://www.paypal.com/paypalme/emblagov)
- [Qiwi](https://qiwi.com/n/STRAL577)

# License

ISC © [Egor Blagov](https://github.com/EgorBlagov)
1 change: 1 addition & 0 deletions common/l10n/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ export const english = {
caseHelp: "Case sensitivity",

moveSubdirForbidden: "Move to same directory or subdirectory is forbidden, please, choose separate directory",
homepage: "Homepage",
};
1 change: 1 addition & 0 deletions common/l10n/russian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ export const russian: Translation = {
caseHelp: "Чувствительность к регистру",

moveSubdirForbidden: "Перемещать в ту же папку или подпапку нельзя, пожалуйста, выберите другую папку",
homepage: "Домашняя страница",
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"authorGithub": "github.com/EgorBlagov",
"assistant": "opasnostya",
"assistantEmail": "[email protected]",
"assistantPatreon": "www.patreon.com/opasnostya"
"assistantPatreon": "www.patreon.com/opasnostya",
"homepage": "github.com/EgorBlagov/sims-mod-assistant/blob/master/README.md"
}
}
26 changes: 24 additions & 2 deletions ui/components/about/AboutDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { Dialog, DialogContent, DialogTitle, List, Typography } from "@material-ui/core";
import {
Box,
Button,
Dialog,
DialogContent,
DialogTitle,
List,
ListItem,
Tooltip,
Typography,
} from "@material-ui/core";
import Github from "@material-ui/icons/GitHub";
import Mail from "@material-ui/icons/Mail";
import { shell } from "electron";
import _ from "lodash";
import React from "react";
import assistantAvatar from "../../../assets/assistant-avatar.png";
import authorAvatar from "../../../assets/author-avatar.png";
import pjson from "../../../package.json";
import { useL10n } from "../../utils/l10n-hooks";
import { preprocessUrl } from "../../utils/url";
import { PatreonIcon } from "../icons/PatreonIcon";
import { Contact, IContact } from "./Contact";

Expand All @@ -17,7 +29,6 @@ interface IProps {

export const AboutDialog = ({ visible, close }: IProps) => {
const [l10n] = useL10n();

const contacts: IContact[] = [
{
avatar: authorAvatar,
Expand Down Expand Up @@ -50,6 +61,7 @@ export const AboutDialog = ({ visible, close }: IProps) => {
role: l10n.assistant,
},
];
const openHomepage = () => shell.openExternal(preprocessUrl(pjson.contacts.homepage));

return (
<Dialog onClose={close} open={visible}>
Expand All @@ -58,12 +70,22 @@ export const AboutDialog = ({ visible, close }: IProps) => {
<Typography variant="h5" component="h2">
{pjson.nameLong} {pjson.version}
</Typography>

<Typography color="textSecondary">{l10n.description}</Typography>
<br />
<List>
{_.map(contacts, (c) => (
<Contact key={c.name} {...c} />
))}
<ListItem>
<Box display="flex" justifyContent="center" width="100%">
<Tooltip title={pjson.contacts.homepage} placement="top">
<Button onClick={openHomepage} color="primary" variant="contained">
{l10n.homepage}
</Button>
</Tooltip>
</Box>
</ListItem>
</List>
</DialogContent>
</Dialog>
Expand Down
10 changes: 2 additions & 8 deletions ui/components/about/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Avatar, Box, IconButton, ListItem, ListItemAvatar, ListItemText, Toolti
import { shell } from "electron";
import _ from "lodash";
import React from "react";
import { preprocessUrl } from "../../utils/url";

export interface IContactIcon {
icon: React.ReactElement;
Expand All @@ -17,14 +18,7 @@ export interface IContact {

export const Contact = ({ name, role, avatar, icons }: IContact) => {
const handleClick = (link: string) => () => {
let linkToOpen = link;
if (link.includes("@")) {
linkToOpen = `mailto: ${link}`;
} else if (!link.startsWith("http")) {
linkToOpen = `https://${link}`;
}

shell.openExternal(linkToOpen);
shell.openExternal(preprocessUrl(link));
};

return (
Expand Down
9 changes: 9 additions & 0 deletions ui/utils/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const preprocessUrl = (url: string): string => {
if (url.includes("@")) {
return `mailto: ${url}`;
} else if (!url.startsWith("http")) {
return `https://${url}`;
}

return url;
};

0 comments on commit 6ab2360

Please sign in to comment.