From 613b77819f0e09542cfeaaa9a663e3aecdaef7f3 Mon Sep 17 00:00:00 2001 From: FredrikOseberg Date: Wed, 19 Mar 2025 22:57:32 +0100 Subject: [PATCH] feat: tags in project list --- .../FeatureOverviewCell.tsx | 83 +++++++++---------- frontend/src/component/common/Tag/Tag.tsx | 2 +- src/server-dev.ts | 2 +- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/frontend/src/component/common/Table/cells/FeatureOverviewCell/FeatureOverviewCell.tsx b/frontend/src/component/common/Table/cells/FeatureOverviewCell/FeatureOverviewCell.tsx index 79c061e556..cce0a2b8a2 100644 --- a/frontend/src/component/common/Table/cells/FeatureOverviewCell/FeatureOverviewCell.tsx +++ b/frontend/src/component/common/Table/cells/FeatureOverviewCell/FeatureOverviewCell.tsx @@ -1,6 +1,6 @@ import type { FC, ReactElement } from 'react'; import type { FeatureSearchResponseSchema } from '../../../../../openapi'; -import { Box, IconButton, styled } from '@mui/material'; +import { Box, IconButton, styled, Chip } from '@mui/material'; import useFeatureTypes from 'hooks/api/getters/useFeatureTypes/useFeatureTypes'; import { getFeatureTypeIcons } from 'utils/getFeatureTypeIcons'; import { useSearchHighlightContext } from '../../SearchHighlightContext/SearchHighlightContext'; @@ -54,20 +54,13 @@ const CustomTagButton = styled('button')(({ theme }) => ({ color: 'inherit', })); -const StyledTag = styled('div')(({ theme }) => ({ - display: 'flex', - alignItems: 'center', - marginRight: theme.spacing(0.5), - border: `1px solid ${theme.palette.divider}`, - borderRadius: theme.shape.borderRadius, - fontSize: theme.fontSizes.smallerBody, - textOverflow: 'ellipsis', - overflow: 'hidden', - textWrap: 'nowrap', - maxWidth: '250px', - padding: theme.spacing(0.25, 0.5), - cursor: 'pointer', +const StyledTag = styled(Chip)(({ theme }) => ({ + overflowWrap: 'anywhere', + lineHeight: theme.typography.body1.lineHeight, backgroundColor: theme.palette.neutral.light, + color: theme.palette.text.primary, + padding: theme.spacing(0.25), + height: theme.spacing(3.5), })); const CappedDescription: FC<{ text: string; searchQuery: string }> = ({ @@ -164,11 +157,10 @@ const ArchivedFeatureName: FC<{ ); }; -const RestTags: FC<{ - tags: ITag[]; - onClick: (tag: string) => void; - isTagTypeColorEnabled: boolean; -}> = ({ tags, onClick, isTagTypeColorEnabled }) => { +const RestTags: FC<{ tags: ITag[]; onClick: (tag: string) => void }> = ({ + tags, + onClick, +}) => { return ( ( @@ -211,9 +203,9 @@ const Tags: FC<{ onClick(`${tag.type}:${tag.value}`); }; - const renderCappedTag = (tag: ITag) => { + const renderTag = (tag: ITag) => { const tagFullText = `${tag.type}:${tag.value}`; - const needsTooltip = tagFullText.length > 30; + const isOverflowing = tagFullText.length > 30; if (isTagTypeColorEnabled) { const tagComponent = ( @@ -225,44 +217,43 @@ const Tags: FC<{ ); - return needsTooltip ? ( - - {tagComponent} - - ) : ( - {tagComponent} - ); - } else { - // Fallback to simple tag rendering without color return ( - handleTagClick(tag)}> - {tagFullText.length > 25 - ? `${tagFullText.substring(0, 25)}…` - : tagFullText} - + {tagComponent} ); } + + return ( + + + {tagFullText.substring(0, 30)} + {isOverflowing ? '...' : ''} + + + } + size='small' + onClick={() => handleTagClick(tag)} + sx={{ cursor: 'pointer' }} + /> + ); }; return ( - {tag1 && renderCappedTag(tag1)} - {tag2 && renderCappedTag(tag2)} - {tag3 && renderCappedTag(tag3)} + {tag1 && renderTag(tag1)} + {tag2 && renderTag(tag2)} + {tag3 && renderTag(tag3)} 0} - show={ - - } + show={} /> ); diff --git a/frontend/src/component/common/Tag/Tag.tsx b/frontend/src/component/common/Tag/Tag.tsx index e71596652d..43e83175da 100644 --- a/frontend/src/component/common/Tag/Tag.tsx +++ b/frontend/src/component/common/Tag/Tag.tsx @@ -6,7 +6,7 @@ import type { ReactElement } from 'react'; const StyledChip = styled(Chip)<{ $color?: string }>(({ theme, $color }) => ({ borderRadius: theme.spacing(2), border: `1px solid ${theme.palette.divider}`, - backgroundColor: theme.palette.common.white, + backgroundColor: theme.palette.background.paper, color: theme.palette.text.primary, height: '26px', '& .MuiChip-label': { diff --git a/src/server-dev.ts b/src/server-dev.ts index 257a49cf93..311d0efabc 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -59,7 +59,7 @@ process.nextTick(async () => { teamsIntegrationChangeRequests: true, simplifyDisableFeature: true, adminNavUI: false, - tagTypeColor: false, + tagTypeColor: true, }, }, authentication: {