Move trash icon to the top bar of right drawer (#1014)

* Move trash icon to the top bar of right drawer

Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Fix background

Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Refactor the code

Co-authored-by: Matheus <matheus_benini@hotmail.com>

---------

Co-authored-by: Matheus <matheus_benini@hotmail.com>
This commit is contained in:
gitstart-twenty
2023-08-02 13:10:02 +08:00
committed by GitHub
parent 55f1e2a5bb
commit 991cadbe48
3 changed files with 19 additions and 21 deletions

View File

@ -21,7 +21,6 @@ import { debounce } from '~/utils/debounce';
import { ActivityAssigneeEditableField } from '../editable-fields/components/ActivityAssigneeEditableField'; import { ActivityAssigneeEditableField } from '../editable-fields/components/ActivityAssigneeEditableField';
import { ActivityRelationEditableField } from '../editable-fields/components/ActivityRelationEditableField'; import { ActivityRelationEditableField } from '../editable-fields/components/ActivityRelationEditableField';
import { ActivityActionBar } from '../right-drawer/components/ActivityActionBar';
import { CommentForDrawer } from '../types/CommentForDrawer'; import { CommentForDrawer } from '../types/CommentForDrawer';
import { ActivityTitle } from './ActivityTitle'; import { ActivityTitle } from './ActivityTitle';
@ -59,14 +58,6 @@ const StyledTopContainer = styled.div`
padding: 24px 24px 24px 48px; padding: 24px 24px 24px 48px;
`; `;
const StyledTopActionsContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
justify-content: space-between;
width: 100%;
`;
type OwnProps = { type OwnProps = {
activity: Pick< activity: Pick<
Activity, Activity,
@ -155,10 +146,7 @@ export function ActivityEditor({
<StyledContainer> <StyledContainer>
<StyledUpperPartContainer> <StyledUpperPartContainer>
<StyledTopContainer> <StyledTopContainer>
<StyledTopActionsContainer> <ActivityTypeDropdown activity={activity} />
<ActivityTypeDropdown activity={activity} />
<ActivityActionBar activityId={activity?.id ?? ''} />
</StyledTopActionsContainer>
<ActivityTitle <ActivityTitle
title={title ?? ''} title={title ?? ''}
completed={!!completedAt} completed={!!completedAt}

View File

@ -6,14 +6,14 @@ import { useRecoilState } from 'recoil';
import { GET_ACTIVITIES_BY_TARGETS } from '@/activities/queries'; import { GET_ACTIVITIES_BY_TARGETS } from '@/activities/queries';
import { GET_COMPANIES } from '@/companies/queries'; import { GET_COMPANIES } from '@/companies/queries';
import { GET_PEOPLE } from '@/people/queries'; import { GET_PEOPLE } from '@/people/queries';
import { Button, ButtonVariant } from '@/ui/button/components/Button'; import { IconButton } from '@/ui/button/components/IconButton';
import { IconTrash } from '@/ui/icon'; import { IconTrash } from '@/ui/icon';
import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState'; import { isRightDrawerOpenState } from '@/ui/right-drawer/states/isRightDrawerOpenState';
import { useDeleteActivityMutation } from '~/generated/graphql'; import { useDeleteActivityMutation } from '~/generated/graphql';
const StyledContainer = styled.div` const StyledContainer = styled.div`
color: ${({ theme }) => theme.font.color.tertiary}; border: 1px solid ${({ theme }) => theme.border.color.medium};
cursor: pointer; border-radius: ${({ theme }) => theme.border.radius.sm};
`; `;
type OwnProps = { type OwnProps = {
@ -39,12 +39,11 @@ export function ActivityActionBar({ activityId }: OwnProps) {
return ( return (
<StyledContainer> <StyledContainer>
<Button <IconButton
icon={ icon={
<IconTrash size={theme.icon.size.sm} stroke={theme.icon.stroke.md} /> <IconTrash size={theme.icon.size.sm} stroke={theme.icon.stroke.md} />
} }
onClick={deleteActivity} onClick={deleteActivity}
variant={ButtonVariant.Tertiary}
/> />
</StyledContainer> </StyledContainer>
); );

View File

@ -1,5 +1,8 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { useRecoilValue } from 'recoil';
import { ActivityActionBar } from '@/activities/right-drawer/components/ActivityActionBar';
import { viewableActivityIdState } from '@/activities/states/viewableActivityIdState';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { RightDrawerTopBarCloseButton } from './RightDrawerTopBarCloseButton'; import { RightDrawerTopBarCloseButton } from './RightDrawerTopBarCloseButton';
@ -15,19 +18,27 @@ const StyledRightDrawerTopBar = styled.div`
font-size: ${({ theme }) => theme.font.size.md}; font-size: ${({ theme }) => theme.font.size.md};
gap: ${({ theme }) => theme.spacing(1)}; gap: ${({ theme }) => theme.spacing(1)};
height: 56px; height: 56px;
justify-content: flex-start; justify-content: space-between;
padding-left: ${({ theme }) => theme.spacing(2)}; padding-left: ${({ theme }) => theme.spacing(2)};
padding-right: ${({ theme }) => theme.spacing(2)}; padding-right: ${({ theme }) => theme.spacing(2)};
`; `;
const TopBarWrapper = styled.div`
display: flex;
`;
export function RightDrawerTopBar() { export function RightDrawerTopBar() {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const activityId = useRecoilValue(viewableActivityIdState);
return ( return (
<StyledRightDrawerTopBar> <StyledRightDrawerTopBar>
<RightDrawerTopBarCloseButton /> <TopBarWrapper>
{!isMobile && <RightDrawerTopBarExpandButton />} <RightDrawerTopBarCloseButton />
{!isMobile && <RightDrawerTopBarExpandButton />}
</TopBarWrapper>
<ActivityActionBar activityId={activityId ?? ''} />
</StyledRightDrawerTopBar> </StyledRightDrawerTopBar>
); );
} }