From 472092201584360950048bc512aa181fcc5046fc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 26 Apr 2023 12:45:39 -0500 Subject: [PATCH] ComposeButton: style group compose button --- .../features/ui/components/compose-button.tsx | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/app/soapbox/features/ui/components/compose-button.tsx b/app/soapbox/features/ui/components/compose-button.tsx index 155a7194e..dc414647b 100644 --- a/app/soapbox/features/ui/components/compose-button.tsx +++ b/app/soapbox/features/ui/components/compose-button.tsx @@ -1,11 +1,23 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; +import { useLocation, useRouteMatch } from 'react-router-dom'; import { openModal } from 'soapbox/actions/modals'; -import { Button } from 'soapbox/components/ui'; +import { Avatar, Button, HStack } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; +import { useGroupLookup } from 'soapbox/hooks/api/groups/useGroupLookup'; const ComposeButton = () => { + const location = useLocation(); + + if (location.pathname.startsWith('/group/')) { + return ; + } + + return ; +}; + +const HomeComposeButton = () => { const dispatch = useAppDispatch(); const onOpenCompose = () => dispatch(openModal('COMPOSE')); @@ -22,4 +34,32 @@ const ComposeButton = () => { ); }; +const GroupComposeButton = () => { + const dispatch = useAppDispatch(); + const match = useRouteMatch<{ groupSlug: string }>('/group/:groupSlug'); + const { entity: group } = useGroupLookup(match?.params.groupSlug || ''); + + const onOpenCompose = () => dispatch(openModal('COMPOSE')); + + if (group) { + return ( + + ); + } + + return null; +}; + export default ComposeButton;