Changed enum naming convention

This commit is contained in:
DrMint 2022-05-22 16:55:39 +02:00
parent 3a379f98a1
commit 6adae3fb3f
21 changed files with 59 additions and 56 deletions

View File

@ -242,7 +242,7 @@ export function AppLayout(props: Immutable<Props>): JSX.Element {
{/* Content panel */} {/* Content panel */}
<div <div
id={AnchorIds.CONTENT_PANEL} id={AnchorIds.ContentPanel}
className={`texture-paper-dots overflow-y-scroll bg-light [grid-area:content]`} className={`texture-paper-dots overflow-y-scroll bg-light [grid-area:content]`}
> >
{contentPanel ? ( {contentPanel ? (

View File

@ -314,27 +314,27 @@ export function preprocessMarkDawn(text: string): string {
} }
if (line.startsWith("# ")) { if (line.startsWith("# ")) {
return markdawnHeadersParser(headerLevels.h1, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H1, line, visitedSlugs);
} }
if (line.startsWith("## ")) { if (line.startsWith("## ")) {
return markdawnHeadersParser(headerLevels.h2, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H2, line, visitedSlugs);
} }
if (line.startsWith("### ")) { if (line.startsWith("### ")) {
return markdawnHeadersParser(headerLevels.h3, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H3, line, visitedSlugs);
} }
if (line.startsWith("#### ")) { if (line.startsWith("#### ")) {
return markdawnHeadersParser(headerLevels.h4, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H4, line, visitedSlugs);
} }
if (line.startsWith("##### ")) { if (line.startsWith("##### ")) {
return markdawnHeadersParser(headerLevels.h5, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H5, line, visitedSlugs);
} }
if (line.startsWith("###### ")) { if (line.startsWith("###### ")) {
return markdawnHeadersParser(headerLevels.h6, line, visitedSlugs); return markdawnHeadersParser(HeaderLevels.H6, line, visitedSlugs);
} }
return line; return line;
@ -342,17 +342,17 @@ export function preprocessMarkDawn(text: string): string {
return result.join("\n"); return result.join("\n");
} }
enum headerLevels { enum HeaderLevels {
h1 = 1, H1 = 1,
h2 = 2, H2 = 2,
h3 = 3, H3 = 3,
h4 = 4, H4 = 4,
h5 = 5, H5 = 5,
h6 = 6, H6 = 6,
} }
function markdawnHeadersParser( function markdawnHeadersParser(
headerLevel: headerLevels, headerLevel: HeaderLevels,
line: string, line: string,
visitedSlugs: string[] visitedSlugs: string[]
): string { ): string {
@ -365,5 +365,5 @@ function markdawnHeadersParser(
index += 1; index += 1;
} }
visitedSlugs.push(newSlug); visitedSlugs.push(newSlug);
return `<${headerLevels[headerLevel]} id="${newSlug}">${lineText}</${headerLevels[headerLevel]}>`; return `<${HeaderLevels[headerLevel]} id="${newSlug}">${lineText}</${HeaderLevels[headerLevel]}>`;
} }

View File

@ -15,9 +15,9 @@ interface Props {
} }
export enum ReturnButtonType { export enum ReturnButtonType {
mobile = "mobile", Mobile = "mobile",
desktop = "desktop", Desktop = "desktop",
both = "both", Both = "both",
} }
export function ReturnButton(props: Immutable<Props>): JSX.Element { export function ReturnButton(props: Immutable<Props>): JSX.Element {
@ -26,9 +26,9 @@ export function ReturnButton(props: Immutable<Props>): JSX.Element {
return ( return (
<div <div
className={`${ className={`${
props.displayOn === ReturnButtonType.mobile props.displayOn === ReturnButtonType.Mobile
? "desktop:hidden" ? "desktop:hidden"
: props.displayOn === ReturnButtonType.desktop : props.displayOn === ReturnButtonType.Desktop
? "mobile:hidden" ? "mobile:hidden"
: "" : ""
} ${props.className}`} } ${props.className}`}

View File

@ -7,14 +7,14 @@ interface Props {
} }
export enum ContentPanelWidthSizes { export enum ContentPanelWidthSizes {
default = "default", Default = "default",
large = "large", Large = "large",
} }
export function ContentPanel(props: Immutable<Props>): JSX.Element { export function ContentPanel(props: Immutable<Props>): JSX.Element {
const width = props.width ? props.width : ContentPanelWidthSizes.default; const width = props.width ? props.width : ContentPanelWidthSizes.Default;
const widthCSS = const widthCSS =
width === ContentPanelWidthSizes.default ? "max-w-2xl" : "w-full"; width === ContentPanelWidthSizes.Default ? "max-w-2xl" : "w-full";
return ( return (
<div className={`grid px-4 pt-10 pb-20 desktop:py-20 desktop:px-10`}> <div className={`grid px-4 pt-10 pb-20 desktop:py-20 desktop:px-10`}>

View File

@ -70,7 +70,7 @@ export function PostPage(props: Immutable<Props>): JSX.Element {
href={returnHref} href={returnHref}
title={returnTitle} title={returnTitle}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
horizontalLine horizontalLine
/> />
)} )}
@ -126,7 +126,7 @@ export function PostPage(props: Immutable<Props>): JSX.Element {
href={returnHref} href={returnHref}
title={returnTitle} title={returnTitle}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
horizontalLine horizontalLine
/> />
)} )}

View File

@ -1,7 +1,7 @@
import { DependencyList, useEffect } from "react"; import { DependencyList, useEffect } from "react";
export enum AnchorIds { export enum AnchorIds {
CONTENT_PANEL = "contentPanel495922447721572", ContentPanel = "contentPanel495922447721572",
} }
// Scroll to top of element "id" when "deps" update. // Scroll to top of element "id" when "deps" update.

View File

@ -19,7 +19,7 @@ export default function FourOhFour(props: Immutable<Props>): JSX.Element {
href="/" href="/"
title="Home" title="Home"
langui={langui} langui={langui}
displayOn={ReturnButtonType.both} displayOn={ReturnButtonType.Both}
/> />
</ContentPanel> </ContentPanel>
); );

View File

@ -19,7 +19,7 @@ export default function FiveHundred(props: Immutable<Props>): JSX.Element {
href="/" href="/"
title="Home" title="Home"
langui={langui} langui={langui}
displayOn={ReturnButtonType.both} displayOn={ReturnButtonType.Both}
/> />
</ContentPanel> </ContentPanel>
); );

View File

@ -39,7 +39,7 @@ export default function Channel(props: Props): JSX.Element {
href="/archives/videos/" href="/archives/videos/"
title={langui.videos} title={langui.videos}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
className="mb-10" className="mb-10"
/> />
@ -57,7 +57,7 @@ export default function Channel(props: Props): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<div className="mb-8"> <div className="mb-8">
<h1 className="text-3xl">{channel?.title}</h1> <h1 className="text-3xl">{channel?.title}</h1>
<p>{channel?.subscribers.toLocaleString()} subscribers</p> <p>{channel?.subscribers.toLocaleString()} subscribers</p>

View File

@ -57,7 +57,7 @@ export default function Videos(props: Props): JSX.Element {
href="/archives/" href="/archives/"
title={"Archives"} title={"Archives"}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
className="mb-10" className="mb-10"
/> />
@ -75,7 +75,7 @@ export default function Videos(props: Props): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<PageSelector <PageSelector
maxPage={Math.floor(videos.length / itemPerPage)} maxPage={Math.floor(videos.length / itemPerPage)}
page={page} page={page}

View File

@ -42,7 +42,7 @@ export default function Video(props: Props): JSX.Element {
href="/archives/videos/" href="/archives/videos/"
title={langui.videos} title={langui.videos}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
className="mb-10" className="mb-10"
/> />
@ -72,12 +72,12 @@ export default function Video(props: Props): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<ReturnButton <ReturnButton
href="/library/" href="/library/"
title={langui.library} title={langui.library}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
className="mb-10" className="mb-10"
/> />

View File

@ -47,7 +47,7 @@ export default function Content(props: Immutable<Props>): JSX.Element {
languageExtractor: (item) => item.language?.data?.attributes?.code, languageExtractor: (item) => item.language?.data?.attributes?.code,
}); });
useScrollTopOnChange(AnchorIds.CONTENT_PANEL, [selectedTranslation]); useScrollTopOnChange(AnchorIds.ContentPanel, [selectedTranslation]);
const previousContent = content.group?.data?.attributes?.contents const previousContent = content.group?.data?.attributes?.contents
? getPreviousContent( ? getPreviousContent(
@ -66,7 +66,7 @@ export default function Content(props: Immutable<Props>): JSX.Element {
href={`/contents`} href={`/contents`}
title={langui.contents} title={langui.contents}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
horizontalLine horizontalLine
/> />
@ -205,7 +205,7 @@ export default function Content(props: Immutable<Props>): JSX.Element {
href={`/contents`} href={`/contents`}
title={langui.contents} title={langui.contents}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
className="mb-10" className="mb-10"
/> />

View File

@ -116,7 +116,7 @@ export default function Contents(props: Immutable<Props>): JSX.Element {
</SubPanel> </SubPanel>
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
{[...groups].map(([name, items]) => ( {[...groups].map(([name, items]) => (
<Fragment key={name}> <Fragment key={name}>
{items.length > 0 && ( {items.length > 0 && (

View File

@ -21,7 +21,7 @@ export default function CheckupContents(props: Immutable<Props>): JSX.Element {
const testReport = testingContent(contents); const testReport = testingContent(contents);
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
{<h2 className="text-2xl">{testReport.title}</h2>} {<h2 className="text-2xl">{testReport.title}</h2>}
<div className="my-4 grid grid-cols-[2em,3em,2fr,1fr,0.5fr,0.5fr,2fr] items-center gap-2"> <div className="my-4 grid grid-cols-[2em,3em,2fr,1fr,0.5fr,0.5fr,2fr] items-center gap-2">

View File

@ -26,7 +26,7 @@ export default function CheckupLibraryItems(
const testReport = testingLibraryItem(libraryItems); const testReport = testingLibraryItem(libraryItems);
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
{<h2 className="text-2xl">{testReport.title}</h2>} {<h2 className="text-2xl">{testReport.title}</h2>}
<div className="my-4 grid grid-cols-[2em,3em,2fr,1fr,0.5fr,0.5fr,2fr] items-center gap-2"> <div className="my-4 grid grid-cols-[2em,3em,2fr,1fr,0.5fr,0.5fr,2fr] items-center gap-2">

View File

@ -40,7 +40,7 @@ export default function Editor(props: Immutable<Props>): JSX.Element {
} }
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<Popup setState={setConverterOpened} state={converterOpened}> <Popup setState={setConverterOpened} state={converterOpened}>
<div className="text-center"> <div className="text-center">
<h2 className="mt-4">Convert HTML to markdown</h2> <h2 className="mt-4">Convert HTML to markdown</h2>

View File

@ -58,7 +58,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
const { item, langui, currencies } = props; const { item, langui, currencies } = props;
const appLayout = useAppLayout(); const appLayout = useAppLayout();
useScrollTopOnChange(AnchorIds.CONTENT_PANEL, [item]); useScrollTopOnChange(AnchorIds.ContentPanel, [item]);
const isVariantSet = const isVariantSet =
item?.metadata?.[0]?.__typename === "ComponentMetadataGroup" && item?.metadata?.[0]?.__typename === "ComponentMetadataGroup" &&
@ -85,7 +85,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
href="/library/" href="/library/"
title={langui.library} title={langui.library}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
horizontalLine horizontalLine
/> />
@ -114,14 +114,14 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<LightBox /> <LightBox />
<ReturnButton <ReturnButton
href="/library/" href="/library/"
title={langui.library} title={langui.library}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
className="mb-10" className="mb-10"
/> />
<div className="grid place-items-center gap-12"> <div className="grid place-items-center gap-12">
@ -438,7 +438,10 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
<div id="contents" className="grid w-full place-items-center gap-8"> <div id="contents" className="grid w-full place-items-center gap-8">
<h2 className="-mb-6 text-2xl">{langui.contents}</h2> <h2 className="-mb-6 text-2xl">{langui.contents}</h2>
{displayOpenScans && ( {displayOpenScans && (
<Button href={`/library/${item.slug}/scans`} text={langui.view_scans}/> <Button
href={`/library/${item.slug}/scans`}
text={langui.view_scans}
/>
)} )}
<div className="grid w-full gap-4"> <div className="grid w-full gap-4">
{item.contents.data.map((content) => ( {item.contents.data.map((content) => (

View File

@ -45,7 +45,7 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
href={`/library/${item?.slug}`} href={`/library/${item?.slug}`}
title={langui.item} title={langui.item}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
horizontalLine horizontalLine
/> />
@ -69,14 +69,14 @@ export default function LibrarySlug(props: Immutable<Props>): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<LightBox /> <LightBox />
<ReturnButton <ReturnButton
href={`/library/${item?.slug}`} href={`/library/${item?.slug}`}
title={langui.item} title={langui.item}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
className="mb-10" className="mb-10"
/> />

View File

@ -155,7 +155,7 @@ export default function Library(props: Immutable<Props>): JSX.Element {
</SubPanel> </SubPanel>
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
{[...groups].map(([name, items]) => ( {[...groups].map(([name, items]) => (
<Fragment key={name}> <Fragment key={name}>
{items.length > 0 && ( {items.length > 0 && (

View File

@ -42,7 +42,7 @@ export default function News(props: Immutable<Props>): JSX.Element {
); );
const contentPanel = ( const contentPanel = (
<ContentPanel width={ContentPanelWidthSizes.large}> <ContentPanel width={ContentPanelWidthSizes.Large}>
<div <div
className="grid grid-cols-1 items-end gap-8 className="grid grid-cols-1 items-end gap-8
desktop:grid-cols-[repeat(auto-fill,_minmax(20rem,1fr))]" desktop:grid-cols-[repeat(auto-fill,_minmax(20rem,1fr))]"

View File

@ -65,7 +65,7 @@ export default function Chronology(props: Props): JSX.Element {
href="/wiki" href="/wiki"
title={langui.wiki} title={langui.wiki}
langui={langui} langui={langui}
displayOn={ReturnButtonType.desktop} displayOn={ReturnButtonType.Desktop}
horizontalLine horizontalLine
/> />
@ -96,7 +96,7 @@ export default function Chronology(props: Props): JSX.Element {
href="/wiki" href="/wiki"
title={langui.wiki} title={langui.wiki}
langui={langui} langui={langui}
displayOn={ReturnButtonType.mobile} displayOn={ReturnButtonType.Mobile}
className="mb-10" className="mb-10"
/> />