diff --git a/app/soapbox/features/ui/components/panels/my-groups-panel.tsx b/app/soapbox/features/ui/components/panels/my-groups-panel.tsx new file mode 100644 index 000000000..438d86de4 --- /dev/null +++ b/app/soapbox/features/ui/components/panels/my-groups-panel.tsx @@ -0,0 +1,33 @@ +import React from 'react'; + +import { Widget } from 'soapbox/components/ui'; +import GroupListItem from 'soapbox/features/groups/components/discover/group-list-item'; +import PlaceholderGroupSearch from 'soapbox/features/placeholder/components/placeholder-group-search'; +import { useGroups } from 'soapbox/hooks'; + +const MyGroupsPanel = () => { + const { groups, isFetching, isFetched, isError } = useGroups(); + const isEmpty = (isFetched && groups.length === 0) || isError; + + if (isEmpty) { + return null; + } + + return ( + + {isFetching ? ( + new Array(3).fill(0).map((_, idx) => ( + + )) + ) : ( + groups.slice(0, 3).map((group) => ( + + )) + )} + + ); +}; + +export default MyGroupsPanel; diff --git a/app/soapbox/features/ui/util/async-components.ts b/app/soapbox/features/ui/util/async-components.ts index e9b015d8c..63d2794e2 100644 --- a/app/soapbox/features/ui/util/async-components.ts +++ b/app/soapbox/features/ui/util/async-components.ts @@ -590,6 +590,10 @@ export function NewGroupPanel() { return import(/* webpackChunkName: "features/groups" */'../components/panels/new-group-panel'); } +export function MyGroupsPanel() { + return import(/* webpackChunkName: "features/groups" */'../components/panels/my-groups-panel'); +} + export function SuggestedGroupsPanel() { return import(/* webpackChunkName: "features/groups" */'../components/panels/suggested-groups-panel'); } diff --git a/app/soapbox/pages/group-page.tsx b/app/soapbox/pages/group-page.tsx index c182068f2..595079aea 100644 --- a/app/soapbox/pages/group-page.tsx +++ b/app/soapbox/pages/group-page.tsx @@ -10,6 +10,7 @@ import { CtaBanner, GroupMediaPanel, SignUpPanel, + SuggestedGroupsPanel, } from 'soapbox/features/ui/util/async-components'; import { useGroup, useOwnAccount } from 'soapbox/hooks'; import { Group } from 'soapbox/schemas'; @@ -127,6 +128,9 @@ const GroupPage: React.FC = ({ params, children }) => { {Component => } + + {Component => } + diff --git a/app/soapbox/pages/groups-page.tsx b/app/soapbox/pages/groups-page.tsx index dfe4bf58b..cce55f515 100644 --- a/app/soapbox/pages/groups-page.tsx +++ b/app/soapbox/pages/groups-page.tsx @@ -1,9 +1,10 @@ import React from 'react'; +import { Route, Routes } from 'react-router-dom-v5-compat'; import { Column, Layout } from 'soapbox/components/ui'; import LinkFooter from 'soapbox/features/ui/components/link-footer'; import BundleContainer from 'soapbox/features/ui/containers/bundle-container'; -import { NewGroupPanel } from 'soapbox/features/ui/util/async-components'; +import { MyGroupsPanel, NewGroupPanel, SuggestedGroupsPanel } from 'soapbox/features/ui/util/async-components'; interface IGroupsPage { children: React.ReactNode @@ -22,10 +23,28 @@ const GroupsPage: React.FC = ({ children }) => ( - {Component => } + {Component => } + + + {Component => } + + )} + /> + + {Component => } + + )} + /> + - + );