diff --git a/next-sitemap.config.js b/next-sitemap.config.js index ac4672d..3f572fb 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -24,5 +24,14 @@ module.exports = { hreflang: "ja", }, ], - exclude: ["/en/*", "/fr/*", "/ja/*", "/es/*", "/pt-br/*", "/404", "/500", "/dev/*"], + exclude: [ + "/en/*", + "/fr/*", + "/ja/*", + "/es/*", + "/pt-br/*", + "/404", + "/500", + "/dev/*", + ], }; diff --git a/public/html_code.html b/public/html_code.html deleted file mode 100644 index cfcf03b..0000000 --- a/public/html_code.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/components/Chronicles/ChroniclePreview.tsx b/src/components/Chronicles/ChroniclePreview.tsx index bc65264..a6bfdcd 100644 --- a/src/components/Chronicles/ChroniclePreview.tsx +++ b/src/components/Chronicles/ChroniclePreview.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import { Link } from "components/Inputs/Link"; import { DatePickerFragment } from "graphql/generated"; import { cIf, cJoin } from "helpers/className"; @@ -20,27 +20,23 @@ export const ChroniclePreview = ({ title, isActive, }: Props): JSX.Element => ( - -
-
-

{date.year}

-

- {prettyMonthDay(date.month, date.day)} -

-
-

{title}

+ +
+

{date.year}

+

+ {prettyMonthDay(date.month, date.day)} +

+

{title}

); diff --git a/src/components/Inputs/Button.tsx b/src/components/Inputs/Button.tsx index 28586c9..bb1db7c 100644 --- a/src/components/Inputs/Button.tsx +++ b/src/components/Inputs/Button.tsx @@ -1,5 +1,5 @@ -import { useRouter } from "next/router"; import React, { MouseEventHandler } from "react"; +import { Link } from "./Link"; import { Ico, Icon } from "components/Ico"; import { cIf, cJoin } from "helpers/className"; import { ConditionalWrapper, Wrapper } from "helpers/component"; @@ -17,8 +17,7 @@ interface Props { active?: boolean; icon?: Icon; text?: string | null | undefined; - locale?: string; - target?: "_blank"; + alwaysNewTab?: boolean; onClick?: MouseEventHandler; draggable?: boolean; badgeNumber?: number; @@ -35,70 +34,56 @@ export const Button = ({ className, icon, text, - target, href, - locale, + alwaysNewTab = false, badgeNumber, size = "normal", -}: Props): JSX.Element => { - const router = useRouter(); - - return ( - +}: Props): JSX.Element => ( + +
{ - if (!isDefined(target) && (isDefined(href) || isDefined(locale))) { - router.push(href ?? router.asPath, href, { - locale: locale, - }); - } - }} - > -
- {isDefined(badgeNumber) && ( -
+ {isDefined(badgeNumber) && ( +
-

{badgeNumber}

-
- )} - {isDefinedAndNotEmpty(icon) && ( - - )} - {isDefinedAndNotEmpty(text) && ( -

{text}

- )} -
+ cIf(size === "small", "-top-2 -right-2 h-5 w-5") + )} + > +

{badgeNumber}

+
+ )} + {isDefinedAndNotEmpty(icon) && ( + + )} + {isDefinedAndNotEmpty(text) && ( +

{text}

+ )}
- - ); -}; +
+
+); /* * ╭──────────────────────╮ @@ -106,11 +91,16 @@ export const Button = ({ */ interface LinkWrapperProps { - href?: string; + href: string; + alwaysNewTab: boolean; } -const LinkWrapper = ({ children, href }: LinkWrapperProps & Wrapper) => ( - +const LinkWrapper = ({ + children, + alwaysNewTab, + href, +}: LinkWrapperProps & Wrapper) => ( + {children} - + ); diff --git a/src/components/Inputs/Link.tsx b/src/components/Inputs/Link.tsx new file mode 100644 index 0000000..aec004a --- /dev/null +++ b/src/components/Inputs/Link.tsx @@ -0,0 +1,62 @@ +import router from "next/router"; +import { MouseEventHandler, useState } from "react"; +import { isDefined } from "helpers/others"; + +interface Props { + href: string; + className?: string; + allowNewTab?: boolean; + alwaysNewTab?: boolean; + children: React.ReactNode; + onClick?: MouseEventHandler; +} + +export const Link = ({ + href, + allowNewTab = true, + alwaysNewTab = false, + children, + className, + onClick, +}: Props): JSX.Element => { + const [isValidClick, setIsValidClick] = useState(false); + + return ( +
setIsValidClick(false)} + onContextMenu={(event) => event.preventDefault()} + onMouseDown={(event) => { + event.preventDefault(); + setIsValidClick(true); + }} + onMouseUp={(event) => { + if (isDefined(onClick)) { + onClick(event); + } else if (isValidClick && href) { + if (event.button !== MouseButton.Right) { + if (alwaysNewTab) { + window.open(href, "_blank"); + } else if (event.button === MouseButton.Left) { + if (href.startsWith("#")) { + router.replace(href); + } else { + router.push(href); + } + } else if (allowNewTab) { + window.open(href, "_blank"); + } + } + } + }} + > + {children} +
+ ); +}; + +enum MouseButton { + Left = 0, + Middle = 1, + Right = 2, +} diff --git a/src/components/PanelComponents/NavOption.tsx b/src/components/PanelComponents/NavOption.tsx index 659cada..a723dd4 100644 --- a/src/components/PanelComponents/NavOption.tsx +++ b/src/components/PanelComponents/NavOption.tsx @@ -4,6 +4,7 @@ import { Ico, Icon } from "components/Ico"; import { ToolTip } from "components/ToolTip"; import { cJoin, cIf } from "helpers/className"; import { isDefinedAndNotEmpty } from "helpers/others"; +import { Link } from "components/Inputs/Link"; /* * ╭─────────────╮ @@ -51,17 +52,9 @@ export const NavOption = ({ className="text-left" disabled={!reduced} > -
{ - if (onClick) onClick(event); - if (url) { - if (url.startsWith("#")) { - router.replace(url); - } else { - router.push(url); - } - } - }} + )} -
+ ); }; diff --git a/src/components/Panels/MainPanel.tsx b/src/components/Panels/MainPanel.tsx index 9f7ed8e..33b8f34 100644 --- a/src/components/Panels/MainPanel.tsx +++ b/src/components/Panels/MainPanel.tsx @@ -1,5 +1,4 @@ import Markdown from "markdown-to-jsx"; -import Link from "next/link"; import { HorizontalLine } from "components/HorizontalLine"; import { Button } from "components/Inputs/Button"; import { NavOption } from "components/PanelComponents/NavOption"; @@ -11,6 +10,7 @@ import { useMediaDesktop } from "hooks/useMediaQuery"; import { Icon } from "components/Ico"; import { cIf, cJoin } from "helpers/className"; import { isDefinedAndNotEmpty } from "helpers/others"; +import { Link } from "components/Inputs/Link"; /* * ╭─────────────╮ @@ -54,7 +54,7 @@ export const MainPanel = ({ langui }: Props): JSX.Element => {
- +
-
- {stackNumber > 0 && ( - <> -
- {thumbnail && ( - - )} -
- -
- {thumbnail && ( - - )} -
- - )} - - {thumbnail ? ( + + {stackNumber > 0 && ( + <>
- - {stackNumber > 0 && ( -
- {stackNumber} -
- )} - {hoverlay && hoverlay.__typename === "Video" && ( - <> -
- -
-
- {prettyDuration(hoverlay.duration)} -
- - )} -
- ) : ( -
- {stackNumber > 0 && ( -
- {stackNumber} -
+ {thumbnail && ( + )}
- )} + +
+ {thumbnail && ( + + )} +
+ + )} + + {thumbnail ? (
+ + {stackNumber > 0 && ( +
+ {stackNumber} +
+ )} + {hoverlay && hoverlay.__typename === "Video" && ( + <> +
+ +
+
+ {prettyDuration(hoverlay.duration)} +
+ + )} +
+ ) : ( +
- {metadata?.position === "Top" && metadataJSX} - {topChips && topChips.length > 0 && ( -
- {topChips.map((text, index) => ( - - ))} -
- )} -
- {pre_title && ( -

{pre_title}

- )} - {title && ( -

- {title} -

- )} - {subtitle &&

{subtitle}

} -
- {description &&

{description}

} - {bottomChips && bottomChips.length > 0 && ( + {stackNumber > 0 && (
- {bottomChips.map((text, index) => ( - - ))} + {stackNumber}
)} - - {metadata?.position === "Bottom" && metadataJSX} - - {infoAppend}
+ )} +
+ {metadata?.position === "Top" && metadataJSX} + {topChips && topChips.length > 0 && ( +
+ {topChips.map((text, index) => ( + + ))} +
+ )} +
+ {pre_title && ( +

{pre_title}

+ )} + {title && ( +

+ {title} +

+ )} + {subtitle &&

{subtitle}

} +
+ {description &&

{description}

} + {bottomChips && bottomChips.length > 0 && ( +
+ {bottomChips.map((text, index) => ( + + ))} +
+ )} + + {metadata?.position === "Bottom" && metadataJSX} + + {infoAppend}
); diff --git a/src/components/PreviewLine.tsx b/src/components/PreviewLine.tsx index e6ff745..b909d78 100644 --- a/src/components/PreviewLine.tsx +++ b/src/components/PreviewLine.tsx @@ -1,6 +1,6 @@ -import Link from "next/link"; import { Chip } from "./Chip"; import { Img } from "./Img"; +import { Link } from "./Inputs/Link"; import { UploadImageFragment } from "graphql/generated"; import { ImageQuality } from "helpers/img"; @@ -32,47 +32,44 @@ export const PreviewLine = ({ bottomChips, thumbnailAspectRatio, }: Props): JSX.Element => ( - -
- {thumbnail ? ( -
- -
- ) : ( -
- )} -
- {topChips && topChips.length > 0 && ( -
- {topChips.map((text, index) => ( - - ))} -
- )} -
- {pre_title &&

{pre_title}

} - {title && ( -

- {title} -

- )} - {subtitle &&

{subtitle}

} -
- {bottomChips && bottomChips.length > 0 && ( -
- {bottomChips.map((text, index) => ( - - ))} -
- )} + + {thumbnail ? ( +
+
+ ) : ( +
+ )} +
+ {topChips && topChips.length > 0 && ( +
+ {topChips.map((text, index) => ( + + ))} +
+ )} +
+ {pre_title &&

{pre_title}

} + {title && ( +

{title}

+ )} + {subtitle &&

{subtitle}

} +
+ {bottomChips && bottomChips.length > 0 && ( +
+ {bottomChips.map((text, index) => ( + + ))} +
+ )}
); diff --git a/src/components/Wiki/DefinitionCard.tsx b/src/components/Wiki/DefinitionCard.tsx index 29731fb..d0e6248 100644 --- a/src/components/Wiki/DefinitionCard.tsx +++ b/src/components/Wiki/DefinitionCard.tsx @@ -1,5 +1,4 @@ import { useCallback } from "react"; -import Link from "next/link"; import { Chip } from "components/Chip"; import { ToolTip } from "components/ToolTip"; import { AppStaticProps } from "graphql/getAppStaticProps"; @@ -87,12 +86,10 @@ const DefinitionCard = ({

{selectedTranslation?.definition}

{source?.url && source.name && ( - -
-

{langui.source}:

-
- +
+

{langui.source}:

+
)} ); diff --git a/src/pages/dev/checkup/contents.tsx b/src/pages/dev/checkup/contents.tsx index 7758c28..5d8dc60 100644 --- a/src/pages/dev/checkup/contents.tsx +++ b/src/pages/dev/checkup/contents.tsx @@ -53,15 +53,15 @@ const CheckupContents = ({ contents, ...otherProps }: Props): JSX.Element => { >