mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-25 18:41:49 +01:00
Linking to github and discord on error boundary
Co-authored-by: William Oldham <wegg7250@gmail.com>
This commit is contained in:
parent
f3c14ec460
commit
3798496985
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
"editor.detectIndentation": false,
|
"editor.detectIndentation": false,
|
||||||
"editor.formatOnSave": true
|
"editor.formatOnSave": false,
|
||||||
|
"editor.tabSize": 2
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ Check out [this project's issues](https://github.com/JamesHawkinss/movie-web/iss
|
|||||||
- [x] Store watched percentage
|
- [x] Store watched percentage
|
||||||
- [ ] Add Brand tag top left
|
- [ ] Add Brand tag top left
|
||||||
- [ ] Add github and discord top right
|
- [ ] Add github and discord top right
|
||||||
- [ ] Link Github and Discord in error boundary
|
- [x] Link Github and Discord in error boundary
|
||||||
- [ ] Implement movie + series view
|
- [ ] Implement movie + series view
|
||||||
- [ ] Global state for media objects
|
- [ ] Global state for media objects
|
||||||
- [ ] Styling for pages
|
- [ ] Styling for pages
|
||||||
|
53
src/components/Text/ArrowLink.tsx
Normal file
53
src/components/Text/ArrowLink.tsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { Icon, Icons } from "components/Icon";
|
||||||
|
import { Link as LinkRouter } from "react-router-dom";
|
||||||
|
|
||||||
|
interface IArrowLinkPropsBase {
|
||||||
|
linkText: string;
|
||||||
|
className?: string;
|
||||||
|
onClick?: () => void;
|
||||||
|
direction?: "left" | "right";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IArrowLinkPropsExternal extends IArrowLinkPropsBase {
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IArrowLinkPropsInternal extends IArrowLinkPropsBase {
|
||||||
|
to: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ArrowLinkProps =
|
||||||
|
| IArrowLinkPropsExternal
|
||||||
|
| IArrowLinkPropsInternal
|
||||||
|
| IArrowLinkPropsBase;
|
||||||
|
|
||||||
|
export function ArrowLink(props: ArrowLinkProps) {
|
||||||
|
const direction = props.direction || "right";
|
||||||
|
const isExternal = !!(props as IArrowLinkPropsExternal).url;
|
||||||
|
const isInternal = !!(props as IArrowLinkPropsInternal).to;
|
||||||
|
const content = (
|
||||||
|
<span className="text-bink-600 hover:text-bink-700 group inline-flex cursor-pointer items-center space-x-1 font-bold active:scale-95">
|
||||||
|
{direction === "left" ? (
|
||||||
|
<span className="text-xl transition-transform group-hover:-translate-x-1">
|
||||||
|
<Icon icon={Icons.ARROW_LEFT} />
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
<span className="flex-1">{props.linkText}</span>
|
||||||
|
{direction === "right" ? (
|
||||||
|
<span className="text-xl transition-transform group-hover:translate-x-1">
|
||||||
|
<Icon icon={Icons.ARROW_RIGHT} />
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isExternal)
|
||||||
|
return <a href={(props as IArrowLinkPropsExternal).url}>{content}</a>;
|
||||||
|
else if (isInternal)
|
||||||
|
return (
|
||||||
|
<LinkRouter to={(props as IArrowLinkPropsInternal).to}>{content}</LinkRouter>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<span onClick={() => props.onClick && props.onClick()}>{content}</span>
|
||||||
|
);
|
||||||
|
}
|
@ -1,48 +1,37 @@
|
|||||||
import { Icon, Icons } from "components/Icon";
|
import { ReactNode } from "react";
|
||||||
import { Link as LinkRouter } from "react-router-dom";
|
import { Link as LinkRouter } from "react-router-dom";
|
||||||
|
|
||||||
interface ILinkPropsBase {
|
interface ILinkPropsBase {
|
||||||
linkText: string;
|
children?: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
direction?: "left" | "right";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ILinkPropsExternal extends ILinkPropsBase {
|
interface ILinkPropsExternal extends ILinkPropsBase {
|
||||||
url: string;
|
url: string;
|
||||||
|
newTab?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ILinkPropsInternal extends ILinkPropsBase {
|
interface ILinkPropsInternal extends ILinkPropsBase {
|
||||||
to: string;
|
to: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LinkProps =
|
type LinkProps =
|
||||||
| ILinkPropsExternal
|
| ILinkPropsExternal
|
||||||
| ILinkPropsInternal
|
| ILinkPropsInternal
|
||||||
| ILinkPropsBase;
|
| ILinkPropsBase;
|
||||||
|
|
||||||
export function Link(props: LinkProps) {
|
export function Link(props: LinkProps) {
|
||||||
const direction = props.direction || "right";
|
|
||||||
const isExternal = !!(props as ILinkPropsExternal).url;
|
const isExternal = !!(props as ILinkPropsExternal).url;
|
||||||
const isInternal = !!(props as ILinkPropsInternal).to;
|
const isInternal = !!(props as ILinkPropsInternal).to;
|
||||||
const content = (
|
const content = (
|
||||||
<span className="text-bink-600 hover:text-bink-700 group inline-flex cursor-pointer items-center space-x-1 font-bold active:scale-95">
|
<span className="text-bink-600 hover:text-bink-700 cursor-pointer font-bold">
|
||||||
{direction === "left" ? (
|
{props.children}
|
||||||
<span className="text-xl transition-transform group-hover:-translate-x-1">
|
|
||||||
<Icon icon={Icons.ARROW_LEFT} />
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
<span className="flex-1">{props.linkText}</span>
|
|
||||||
{direction === "right" ? (
|
|
||||||
<span className="text-xl transition-transform group-hover:translate-x-1">
|
|
||||||
<Icon icon={Icons.ARROW_RIGHT} />
|
|
||||||
</span>
|
|
||||||
) : null}
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
return <a href={(props as ILinkPropsExternal).url}>{content}</a>;
|
return <a target={(props as ILinkPropsExternal).newTab ? "blank" : undefined} rel="noopener" href={(props as ILinkPropsExternal).url}>{content}</a>;
|
||||||
else if (isInternal)
|
else if (isInternal)
|
||||||
return (
|
return (
|
||||||
<LinkRouter to={(props as ILinkPropsInternal).to}>{content}</LinkRouter>
|
<LinkRouter to={(props as ILinkPropsInternal).to}>{content}</LinkRouter>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { IconPatch } from "components/Buttons/IconPatch";
|
import { IconPatch } from "components/Buttons/IconPatch";
|
||||||
import { Icons } from "components/Icon";
|
import { Icons } from "components/Icon";
|
||||||
|
import { Link } from "components/Text/Link";
|
||||||
import { Title } from "components/Text/Title";
|
import { Title } from "components/Text/Title";
|
||||||
|
import { DISCORD_LINK, GITHUB_LINK } from "mw_constants";
|
||||||
import { Component } from "react";
|
import { Component } from "react";
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
interface ErrorBoundaryState {
|
||||||
@ -49,7 +51,7 @@ export class ErrorBoundary extends Component<{}, ErrorBoundaryState> {
|
|||||||
<Title>Whoops, it broke</Title>
|
<Title>Whoops, it broke</Title>
|
||||||
<p className="my-6 max-w-lg">
|
<p className="my-6 max-w-lg">
|
||||||
The app encountered an error and wasn't able to recover, please
|
The app encountered an error and wasn't able to recover, please
|
||||||
report it to the discord server or on GitHub.
|
report it to the <Link url={DISCORD_LINK} newTab>Discord server</Link> or on <Link url={GITHUB_LINK} newTab>GitHub</Link>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{this.state.error ? (
|
{this.state.error ? (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Icon, Icons } from "components/Icon";
|
import { Icon, Icons } from "components/Icon";
|
||||||
import { Link } from "components/Text/Link";
|
import { ArrowLink } from "components/Text/ArrowLink";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
interface SectionHeadingProps {
|
interface SectionHeadingProps {
|
||||||
@ -23,7 +23,7 @@ export function SectionHeading(props: SectionHeadingProps) {
|
|||||||
{props.title}
|
{props.title}
|
||||||
</p>
|
</p>
|
||||||
{props.linkText ? (
|
{props.linkText ? (
|
||||||
<Link
|
<ArrowLink
|
||||||
linkText={props.linkText}
|
linkText={props.linkText}
|
||||||
direction="left"
|
direction="left"
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export const CORS_PROXY_URL =
|
export const CORS_PROXY_URL = "https://proxy-1.movie-web.workers.dev/?destination=";
|
||||||
"https://proxy-1.movie-web.workers.dev/?destination=";
|
export const DISCORD_LINK = "https://discord.gg/Jhqt4Xzpfb";
|
||||||
|
export const GITHUB_LINK = "https://github.com/JamesHawkinss/movie-web";
|
||||||
|
@ -10,6 +10,7 @@ export function MovieView() {
|
|||||||
const store = useWatchedContext();
|
const store = useWatchedContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
throw new Error("Hi");
|
||||||
(async () => {
|
(async () => {
|
||||||
setStreamUrl(mediaPortable && (await getStream(mediaPortable)));
|
setStreamUrl(mediaPortable && (await getStream(mediaPortable)));
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user