Skip to content

Commit

Permalink
Added tooltip on overflowing texts (#771)
Browse files Browse the repository at this point in the history
* Ok

* Fixes

* Fix according to PR

* Fix lint

---------

Co-authored-by: Charles Bochet <[email protected]>
  • Loading branch information
lucasbordeau and charlesBochet authored Jul 20, 2023
1 parent 60b5038 commit 7670ae5
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 28 deletions.
24 changes: 16 additions & 8 deletions front/src/modules/activities/timeline/components/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
beautifyPastDateRelativeToNow,
} from '~/utils/date-utils';

import { OverflowingTextWithTooltip } from '../../../ui/tooltip/OverflowingTextWithTooltip';

const StyledMainContainer = styled.div`
align-items: flex-start;
align-self: stretch;
Expand Down Expand Up @@ -144,17 +146,15 @@ const StyledCardTitle = styled.div`
color: ${({ theme }) => theme.font.color.primary};
font-weight: ${({ theme }) => theme.font.weight.medium};
line-height: ${({ theme }) => theme.text.lineHeight.lg};
width: 100%;
`;

const StyledCardContent = styled.div`
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
align-self: stretch;
color: ${({ theme }) => theme.font.color.secondary};
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
`;

const StyledTooltip = styled(Tooltip)`
Expand Down Expand Up @@ -279,10 +279,18 @@ export function Timeline({ entity }: { entity: CommentableEntity }) {
}
>
<StyledCardTitle>
{commentThread.title ? commentThread.title : '(No title)'}
<OverflowingTextWithTooltip
text={
commentThread.title
? commentThread.title
: '(No title)'
}
/>
</StyledCardTitle>
<StyledCardContent>
{body ? body : '(No content)'}
<OverflowingTextWithTooltip
text={body ? body : '(No content)'}
/>
</StyledCardContent>
</StyledCard>
</StyledCardContainer>
Expand Down
2 changes: 2 additions & 0 deletions front/src/modules/companies/components/CompanyBoardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const StyledBoardCard = styled.div<{ selected: boolean }>`

const StyledBoardCardWrapper = styled.div`
padding-bottom: ${({ theme }) => theme.spacing(2)};
width: 100%;
`;

const StyledBoardCardHeader = styled.div`
Expand All @@ -64,6 +65,7 @@ const StyledBoardCardHeader = styled.div`
width: ${({ theme }) => theme.icon.size.md}px;
}
`;

const StyledBoardCardBody = styled.div`
display: flex;
flex-direction: column;
Expand Down
2 changes: 2 additions & 0 deletions front/src/modules/ui/board/components/BoardColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const StyledColumn = styled.div<{ isFirstColumn: boolean }>`
isFirstColumn ? 'none' : theme.border.color.light};
display: flex;
flex-direction: column;
max-width: 200px;
min-width: 200px;
padding: ${({ theme }) => theme.spacing(2)};
`;

Expand Down
10 changes: 8 additions & 2 deletions front/src/modules/ui/chip/components/EntityChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import styled from '@emotion/styled';

import { Avatar, AvatarType } from '@/users/components/Avatar';

import { OverflowingTextWithTooltip } from '../../tooltip/OverflowingTextWithTooltip';

export enum ChipVariant {
opaque = 'opaque',
transparent = 'transparent',
Expand Down Expand Up @@ -94,7 +96,9 @@ export function EntityChip({
size={14}
type={avatarType}
/>
<StyledName>{name}</StyledName>
<StyledName>
<OverflowingTextWithTooltip text={name} />
</StyledName>
</StyledContainerLink>
) : (
<StyledContainerReadOnly data-testid="entity-chip">
Expand All @@ -105,7 +109,9 @@ export function EntityChip({
size={14}
type={avatarType}
/>
<StyledName>{name}</StyledName>
<StyledName>
<OverflowingTextWithTooltip text={name} />
</StyledName>
</StyledContainerReadOnly>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ const DropdownMenuSelectableItemContainer = styled(DropdownMenuItem)<Props>`
display: flex;
justify-content: space-between;
max-width: 150px;
`;

const StyledLeftContainer = styled.div`
align-items: center;
display: flex;
gap: ${({ theme }) => theme.spacing(2)};
overflow: hidden;
`;

const StyledRightIcon = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function NumberEditableField({
/>
}
displayModeContent={internalValue}
isDisplayModeContentEmpty={!(internalValue !== '')}
isDisplayModeContentEmpty={!(internalValue !== '' && internalValue)}
/>
</RecoilScope>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText';
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';

import { OverflowingTextWithTooltip } from '../../../tooltip/OverflowingTextWithTooltip';

type OwnProps = {
icon?: React.ReactNode;
placeholder?: string;
Expand Down Expand Up @@ -54,7 +56,7 @@ export function TextEditableField({
}}
/>
}
displayModeContent={internalValue}
displayModeContent={<OverflowingTextWithTooltip text={internalValue} />}
isDisplayModeContentEmpty={!(internalValue !== '')}
/>
</RecoilScope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
beautifyPastDateRelativeToNow,
} from '~/utils/date-utils';

import { OverflowingTextWithTooltip } from '../../../tooltip/OverflowingTextWithTooltip';

type OwnProps = {
id?: string;
logoOrAvatar?: string;
Expand All @@ -31,6 +33,7 @@ const StyledInfoContainer = styled.div`
display: flex;
flex-direction: column;
gap: ${({ theme }) => theme.spacing(1)};
width: 100%;
`;

const StyledDate = styled.div`
Expand All @@ -42,6 +45,8 @@ const StyledTitle = styled.div`
color: ${({ theme }) => theme.font.color.primary};
font-size: ${({ theme }) => theme.font.size.xl};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
max-width: 100%;
`;

const StyledTooltip = styled(Tooltip)`
Expand All @@ -50,6 +55,8 @@ const StyledTooltip = styled(Tooltip)`
color: ${({ theme }) => theme.font.color.primary};
font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.regular};
padding: ${({ theme }) => theme.spacing(2)};
`;

Expand All @@ -74,7 +81,9 @@ export function ShowPageSummaryCard({
placeholder={title}
/>
<StyledInfoContainer>
<StyledTitle>{title}</StyledTitle>
<StyledTitle>
<OverflowingTextWithTooltip text={title} />
</StyledTitle>
<StyledDate id={dateElementId}>
Added {beautifiedCreatedAt} ago
</StyledDate>
Expand Down
41 changes: 27 additions & 14 deletions front/src/modules/ui/layout/top-bar/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { IconButton } from '@/ui/button/components/IconButton';
import { IconChevronLeft, IconPlus } from '@/ui/icon/index';
import NavCollapseButton from '@/ui/navbar/components/NavCollapseButton';

import { OverflowingTextWithTooltip } from '../../../tooltip/OverflowingTextWithTooltip';

export const TOP_BAR_MIN_HEIGHT = 40;

const TopBarContainer = styled.div`
Expand All @@ -14,20 +16,27 @@ const TopBarContainer = styled.div`
color: ${({ theme }) => theme.font.color.primary};
display: flex;
flex-direction: row;
font-size: 14px;
font-size: ${({ theme }) => theme.font.size.lg};
justify-content: space-between;
min-height: ${TOP_BAR_MIN_HEIGHT}px;
padding: ${({ theme }) => theme.spacing(2)};
padding-right: ${({ theme }) => theme.spacing(3)};
`;

const TitleContainer = styled.div`
const StyledLeftContainer = styled.div`
align-items: center;
display: flex;
font-family: 'Inter';
font-size: 14px;
margin-left: 4px;
flex-direction: row;
width: 100%;
`;

const TitleContainer = styled.div`
display: flex;
font-size: ${({ theme }) => theme.font.size.md};
margin-left: ${({ theme }) => theme.spacing(1)};
max-width: 50%;
`;

const BackIconButton = styled(IconButton)`
margin-right: ${({ theme }) => theme.spacing(1)};
`;
Expand All @@ -51,15 +60,19 @@ export function TopBar({
return (
<>
<TopBarContainer>
<NavCollapseButton hideIfOpen={true} />
{hasBackButton && (
<BackIconButton
icon={<IconChevronLeft size={16} />}
onClick={navigateBack}
/>
)}
{icon}
<TitleContainer data-testid="top-bar-title">{title}</TitleContainer>
<StyledLeftContainer>
<NavCollapseButton hideIfOpen={true} />
{hasBackButton && (
<BackIconButton
icon={<IconChevronLeft size={16} />}
onClick={navigateBack}
/>
)}
{icon}
<TitleContainer data-testid="top-bar-title">
<OverflowingTextWithTooltip text={title} />
</TitleContainer>
</StyledLeftContainer>
{onAddButtonClick && (
<IconButton
icon={<IconPlus size={16} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useScopedHotkeys } from '@/ui/hotkey/hooks/useScopedHotkeys';
import { Avatar } from '@/users/components/Avatar';
import { isDefined } from '~/utils/isDefined';

import { OverflowingTextWithTooltip } from '../../tooltip/OverflowingTextWithTooltip';
import { useEntitySelectScroll } from '../hooks/useEntitySelectScroll';
import { EntityForSelect } from '../types/EntityForSelect';
import { RelationPickerHotkeyScope } from '../types/RelationPickerHotkeyScope';
Expand Down Expand Up @@ -86,7 +87,7 @@ export function SingleEntitySelectBase<
size={16}
type={entity.avatarType ?? 'rounded'}
/>
{entity.name}
<OverflowingTextWithTooltip text={entity.name} />
</DropdownMenuSelectableItem>
))
)}
Expand Down
2 changes: 2 additions & 0 deletions front/src/modules/ui/themes/border.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const borderLight = {
strong: grayScale.gray25,
medium: grayScale.gray20,
light: grayScale.gray15,
invertedSecondary: grayScale.gray50,
inverted: grayScale.gray60,
},
...common,
Expand All @@ -24,6 +25,7 @@ export const borderDark = {
strong: grayScale.gray65,
medium: grayScale.gray70,
light: grayScale.gray75,
invertedSecondary: grayScale.gray40,
inverted: grayScale.gray30,
},
...common,
Expand Down
18 changes: 18 additions & 0 deletions front/src/modules/ui/tooltip/AppTooltip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Tooltip } from 'react-tooltip';
import styled from '@emotion/styled';

export const AppTooltip = styled(Tooltip)`
background-color: ${({ theme }) => theme.background.primary};
box-shadow: ${({ theme }) => theme.boxShadow.light};
color: ${({ theme }) => theme.font.color.primary};
font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.regular};
max-width: 40%;
padding: ${({ theme }) => theme.spacing(2)};
word-break: break-word;
z-index: ${({ theme }) => theme.lastLayerZIndex};
`;
Loading

0 comments on commit 7670ae5

Please sign in to comment.