From 9f6f8bef799661369a3c496f9b90d98f1d974683 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 26 May 2023 12:02:43 -0400 Subject: [PATCH] Implement hiding widgets --- src/handbook/index.html | 5 +++++ src/handbook/src/ui/widgets/HomeButton.tsx | 12 ++++++++++-- src/handbook/src/ui/widgets/SideBarButton.tsx | 12 ++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/handbook/index.html b/src/handbook/index.html index 4e84c88f2..a65597435 100644 --- a/src/handbook/index.html +++ b/src/handbook/index.html @@ -4,7 +4,12 @@ GM Handbook + + +
diff --git a/src/handbook/src/ui/widgets/HomeButton.tsx b/src/handbook/src/ui/widgets/HomeButton.tsx index 3c07ecda8..e95dda356 100644 --- a/src/handbook/src/ui/widgets/HomeButton.tsx +++ b/src/handbook/src/ui/widgets/HomeButton.tsx @@ -24,14 +24,22 @@ class HomeButton extends React.PureComponent { navigate(this.props.anchor); } + /** + * Checks if this component should be showed. + */ + private shouldShow(): boolean { + return !(((window as any).hide) as string[]) + .includes(this.props.anchor.toLowerCase()); + } + render() { - return ( + return this.shouldShow() ? (
this.redirect()}> {this.props.name}

{this.props.name}

- ); + ) : undefined; } } diff --git a/src/handbook/src/ui/widgets/SideBarButton.tsx b/src/handbook/src/ui/widgets/SideBarButton.tsx index 9af875558..83248560d 100644 --- a/src/handbook/src/ui/widgets/SideBarButton.tsx +++ b/src/handbook/src/ui/widgets/SideBarButton.tsx @@ -24,14 +24,22 @@ class SideBarButton extends React.PureComponent { navigate(this.props.anchor); } + /** + * Checks if this component should be showed. + */ + private shouldShow(): boolean { + return !(((window as any).hide) as string[]) + .includes(this.props.anchor.toLowerCase()); + } + render() { - return ( + return this.shouldShow() ? (
this.redirect()}> {this.props.name}

{this.props.name}

- ); + ) : undefined; } }