Fix single note in grid (#2437)

- fix single note in grid
This commit is contained in:
brendanlaschke
2023-11-13 16:01:31 +01:00
committed by GitHub
parent 44d046b363
commit c7568ff28b
2 changed files with 10 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import {
} from '@/ui/object/field/contexts/FieldContext'; } from '@/ui/object/field/contexts/FieldContext';
import { Activity, ActivityTarget, Comment } from '~/generated/graphql'; import { Activity, ActivityTarget, Comment } from '~/generated/graphql';
const StyledCard = styled.div` const StyledCard = styled.div<{ isSingleNote: boolean }>`
align-items: flex-start; align-items: flex-start;
background: ${({ theme }) => theme.background.secondary}; background: ${({ theme }) => theme.background.secondary};
border: 1px solid ${({ theme }) => theme.border.color.medium}; border: 1px solid ${({ theme }) => theme.border.color.medium};
@ -20,6 +20,7 @@ const StyledCard = styled.div`
flex-direction: column; flex-direction: column;
height: 300px; height: 300px;
justify-content: space-between; justify-content: space-between;
max-width: ${({ isSingleNote }) => (isSingleNote ? '300px' : 'unset')};
`; `;
const StyledCardDetailsContainer = styled.div` const StyledCardDetailsContainer = styled.div`
@ -73,6 +74,7 @@ const StyledCommentIcon = styled.div`
export const NoteCard = ({ export const NoteCard = ({
note, note,
isSingleNote,
}: { }: {
note: Pick< note: Pick<
Activity, Activity,
@ -81,6 +83,7 @@ export const NoteCard = ({
activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null; activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null;
comments?: Array<Pick<Comment, 'id'>> | null; comments?: Array<Pick<Comment, 'id'>> | null;
}; };
isSingleNote: boolean;
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
const openActivityRightDrawer = useOpenActivityRightDrawer(); const openActivityRightDrawer = useOpenActivityRightDrawer();
@ -95,7 +98,7 @@ export const NoteCard = ({
return ( return (
<FieldContext.Provider value={fieldContext as GenericFieldContextType}> <FieldContext.Provider value={fieldContext as GenericFieldContextType}>
<StyledCard> <StyledCard isSingleNote={isSingleNote}>
<StyledCardDetailsContainer <StyledCardDetailsContainer
onClick={() => openActivityRightDrawer(note.id)} onClick={() => openActivityRightDrawer(note.id)}
> >

View File

@ -59,7 +59,11 @@ export const NoteList = ({ title, notes, button }: NoteListProps) => (
</StyledTitleBar> </StyledTitleBar>
<StyledNoteContainer> <StyledNoteContainer>
{notes.map((note) => ( {notes.map((note) => (
<NoteCard key={note.id} note={note} /> <NoteCard
key={note.id}
note={note}
isSingleNote={notes.length == 1}
/>
))} ))}
</StyledNoteContainer> </StyledNoteContainer>
</StyledContainer> </StyledContainer>