From ff4d37d03aa683801711199f774cfd633f858f5d Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 13:51:21 -0400 Subject: [PATCH 01/10] fix(a11y): Fix some a11y issues in Site Sidebar and use native Bootstrap Collapse and Card classes --- .../components/common/banner-icon-header.tsx | 4 +- src/shared/components/home/site-sidebar.tsx | 49 ++++++++++++------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/shared/components/common/banner-icon-header.tsx b/src/shared/components/common/banner-icon-header.tsx index 1df23bef..d2fae2e1 100644 --- a/src/shared/components/common/banner-icon-header.tsx +++ b/src/shared/components/common/banner-icon-header.tsx @@ -14,7 +14,7 @@ export class BannerIconHeader extends Component { render() { const banner = this.props.banner; const icon = this.props.icon; - return ( + return banner || icon ? (
{banner && } {icon && ( @@ -26,6 +26,6 @@ export class BannerIconHeader extends Component { /> )}
- ); + ) : null; } } diff --git a/src/shared/components/home/site-sidebar.tsx b/src/shared/components/home/site-sidebar.tsx index 66a48ca1..283ddf83 100644 --- a/src/shared/components/home/site-sidebar.tsx +++ b/src/shared/components/home/site-sidebar.tsx @@ -29,17 +29,23 @@ export class SiteSidebar extends Component { render() { return ( -
-
-
-
{this.siteName()}
- {!this.state.collapsed && ( - <> - - {this.siteInfo()} - - )} -
+
+
+ {this.siteName()} + {!this.state.collapsed && ( + + )} +
+ +
+
{this.siteInfo()}
); @@ -47,13 +53,22 @@ export class SiteSidebar extends Component { siteName() { return ( -
- {this.props.site.name} +
+
{this.props.site.name}
-
+
); } From 878e0f0f85d078b5e7ee09d738ef9f39d253a224 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 14:24:13 -0400 Subject: [PATCH 02/10] fix: Add .accordion wrapper around sidebar to obtain negative bottom margin --- src/shared/components/home/site-sidebar.tsx | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/shared/components/home/site-sidebar.tsx b/src/shared/components/home/site-sidebar.tsx index 283ddf83..b09f27d2 100644 --- a/src/shared/components/home/site-sidebar.tsx +++ b/src/shared/components/home/site-sidebar.tsx @@ -29,25 +29,27 @@ export class SiteSidebar extends Component { render() { return ( -
-
- {this.siteName()} - {!this.state.collapsed && ( - - )} -
- -
+
-
{this.siteInfo()}
-
-
+
+ {this.siteName()} + {!this.state.collapsed && ( + + )} +
+ +
+
{this.siteInfo()}
+
+
+ ); } From 072d253baa978b66708abe6bc31a8267b37e4595 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 15:09:10 -0400 Subject: [PATCH 03/10] fix(a11y): Apply same accordion/collapse markup to Subscribed Communities sidebar card --- src/shared/components/home/home.tsx | 80 +++++++++++++-------- src/shared/components/home/site-sidebar.tsx | 9 ++- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 4d79bc63..851c5c25 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -492,12 +492,14 @@ export class Home extends Component { showLocal={showLocal(this.isoData)} /> {this.hasFollows && ( -
-
{this.subscribedCommunities}
-
+
+
+ {this.subscribedCommunities} +
+
)} ); @@ -543,39 +545,59 @@ export class Home extends Component { const { subscribedCollapsed } = this.state; return ( -
-
- - # - + <> +
+
+ # - - + + # + + +
-
- {!subscribedCollapsed && ( -
    - {UserService.Instance.myUserInfo?.follows.map(cfv => ( -
  • - -
  • - ))} -
- )} -
+ +
+
+
    + {UserService.Instance.myUserInfo?.follows.map(cfv => ( +
  • + +
  • + ))} +
+
+
+ ); } diff --git a/src/shared/components/home/site-sidebar.tsx b/src/shared/components/home/site-sidebar.tsx index b09f27d2..3df4eb69 100644 --- a/src/shared/components/home/site-sidebar.tsx +++ b/src/shared/components/home/site-sidebar.tsx @@ -34,7 +34,10 @@ export class SiteSidebar extends Component { id="sidebarInfo" className="card border-secondary mb-3 overflow-hidden" > -
+
{this.siteName()} {!this.state.collapsed && ( @@ -55,7 +58,7 @@ export class SiteSidebar extends Component { siteName() { return ( -
+ <>
{this.props.site.name}
-
+ ); } From cf5c8a1c07a73581eb11aeaf7829460863ce2b5b Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 15:24:55 -0400 Subject: [PATCH 04/10] fix(a11y): Fix some mobile styles for Sidebar Cards --- src/shared/components/home/home.tsx | 53 +++++++++++---------- src/shared/components/home/site-sidebar.tsx | 45 +++++++++-------- 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 851c5c25..23b09414 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -443,16 +443,17 @@ export class Home extends Component { admins={admins} counts={counts} showLocal={showLocal(this.isoData)} + isMobile={true} /> )} {showTrendingMobile && ( -
+
{this.trendingCommunities(true)}
)} {showSubscribedMobile && ( -
-
{this.subscribedCommunities}
+
+ {this.subscribedCommunities(true)}
)}
@@ -497,7 +498,7 @@ export class Home extends Component { id="sidebarSubscribed" className="card border-secondary mb-3" > - {this.subscribedCommunities} + {this.subscribedCommunities(false)}
)} @@ -541,7 +542,7 @@ export class Home extends Component { } } - get subscribedCommunities() { + subscribedCommunities(isMobile = false) { const { subscribedCollapsed } = this.state; return ( @@ -558,26 +559,28 @@ export class Home extends Component { - + {!isMobile && ( + + )}
{ return ( <>
{this.props.site.name}
- + {!this.props.isMobile && ( + + )} ); } From 0d302c0e40c52a15d39f0531c4d1af56bd9d873e Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 15:32:29 -0400 Subject: [PATCH 05/10] fix: Cleaner logic --- .../components/common/banner-icon-header.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/shared/components/common/banner-icon-header.tsx b/src/shared/components/common/banner-icon-header.tsx index d2fae2e1..7028ef4f 100644 --- a/src/shared/components/common/banner-icon-header.tsx +++ b/src/shared/components/common/banner-icon-header.tsx @@ -14,18 +14,20 @@ export class BannerIconHeader extends Component { render() { const banner = this.props.banner; const icon = this.props.icon; - return banner || icon ? ( -
- {banner && } - {icon && ( - - )} -
- ) : null; + return ( + (banner || icon) && ( +
+ {banner && } + {icon && ( + + )} +
+ ) + ); } } From c8758317f7ed08b05ec80597fd3df06e3618d514 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 15:32:49 -0400 Subject: [PATCH 06/10] fix: Fix Trending sidebar card too --- src/shared/components/home/home.tsx | 68 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 23b09414..0acef492 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -1,3 +1,4 @@ +import classNames from "classnames"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent, MouseEventHandler } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -448,7 +449,7 @@ export class Home extends Component { )} {showTrendingMobile && (
-
{this.trendingCommunities(true)}
+ {this.trendingCommunities(true)}
)} {showSubscribedMobile && ( @@ -472,19 +473,7 @@ export class Home extends Component { return (
-
- {this.trendingCommunities()} - {canCreateCommunity(this.state.siteRes) && ( - - )} - -
+ {this.trendingCommunities()}
{ case "success": { const trending = this.state.trendingCommunitiesRes.data.communities; return ( -
-
- - # - +
+
+
+ # - - -
-
    - {trending.map(cv => ( -
  • - -
  • - ))} -
+ + # + + +
+
+
+
    + {trending.map(cv => ( +
  • + +
  • + ))} +
+ {canCreateCommunity(this.state.siteRes) && ( + + )} + +
); } From 3564c6c379ff7be50b26dea9240080656bc30316 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 17:01:14 -0400 Subject: [PATCH 07/10] fix: Fix some small style issues --- src/shared/components/home/home.tsx | 25 +++++++++------------ src/shared/components/home/site-sidebar.tsx | 5 +---- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 0acef492..483d8ccb 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -1,4 +1,3 @@ -import classNames from "classnames"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent, MouseEventHandler } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -506,11 +505,7 @@ export class Home extends Component { case "success": { const trending = this.state.trendingCommunitiesRes.data.communities; return ( -
+ <>
@@ -522,13 +517,15 @@ export class Home extends Component {
-
    - {trending.map(cv => ( -
  • - -
  • - ))} -
+ {trending.length > 0 && ( +
    + {trending.map(cv => ( +
  • + +
  • + ))} +
+ )} {canCreateCommunity(this.state.siteRes) && ( { translationKey="explore_communities" />
-
+ ); } } diff --git a/src/shared/components/home/site-sidebar.tsx b/src/shared/components/home/site-sidebar.tsx index f4081737..cc587bfb 100644 --- a/src/shared/components/home/site-sidebar.tsx +++ b/src/shared/components/home/site-sidebar.tsx @@ -31,10 +31,7 @@ export class SiteSidebar extends Component { render() { return (
-
+
Date: Sat, 17 Jun 2023 19:16:24 -0400 Subject: [PATCH 08/10] fix: Remove unused var --- src/shared/components/home/home.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 483d8ccb..c7fccb8e 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -448,7 +448,7 @@ export class Home extends Component { )} {showTrendingMobile && (
- {this.trendingCommunities(true)} + {this.trendingCommunities}
)} {showSubscribedMobile && ( @@ -472,7 +472,7 @@ export class Home extends Component { return (
- {this.trendingCommunities()} + {this.trendingCommunities}
{ ); } - trendingCommunities(isMobile = false) { + trendingCommunities() { switch (this.state.trendingCommunitiesRes?.state) { case "loading": return ( From f702cbd2564bca9cfa28beadb28ff9934cc0a66b Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sat, 17 Jun 2023 19:27:11 -0400 Subject: [PATCH 10/10] fix: Fix build error --- src/shared/components/home/home.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index c7fccb8e..4f9b9694 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -448,7 +448,7 @@ export class Home extends Component { )} {showTrendingMobile && (
- {this.trendingCommunities} + {this.trendingCommunities()}
)} {showSubscribedMobile && ( @@ -472,7 +472,7 @@ export class Home extends Component { return (
- {this.trendingCommunities} + {this.trendingCommunities()}