Skip to content

Commit

Permalink
Tooltip on icons (#3529)
Browse files Browse the repository at this point in the history
* Step 3: Set up PostgreSQL Database

* Tooltip on Icons

* Cleaning icon tooltip code

* Fix according to review

---------

Co-authored-by: Charles Bochet <[email protected]>
  • Loading branch information
seAfnan and charlesBochet authored Jan 23, 2024
1 parent d176ba9 commit 0100244
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useState } from 'react';
import { Tooltip } from 'react-tooltip';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { motion } from 'framer-motion';
import kebabCase from 'lodash.kebabcase';

import { IconComponent } from '@/ui/display/icon/types/IconComponent';
import { EllipsisDisplay } from '@/ui/field/display/components/EllipsisDisplay';
Expand Down Expand Up @@ -69,6 +71,17 @@ const StyledInlineCellBaseContainer = styled.div`
user-select: none;
`;

const StyledTooltip = 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};
padding: ${({ theme }) => theme.spacing(2)};
`;

type RecordInlineCellContainerProps = {
IconLabel?: IconComponent;
label?: string;
Expand Down Expand Up @@ -127,7 +140,7 @@ export const RecordInlineCellContainer = ({
onMouseLeave={handleContainerMouseLeave}
>
{(!!IconLabel || !!label) && (
<StyledLabelAndIconContainer>
<StyledLabelAndIconContainer id={kebabCase(label)}>
{IconLabel && (
<StyledIconContainer>
<IconLabel stroke={theme.icon.stroke.sm} />
Expand All @@ -138,6 +151,16 @@ export const RecordInlineCellContainer = ({
<EllipsisDisplay maxWidth={labelWidth}>{label}</EllipsisDisplay>
</StyledLabelContainer>
)}
{!showLabel && (
<StyledTooltip
anchorSelect={`#${kebabCase(label)}`}
content={label}
clickable
noArrow
place="left"
positionStrategy="fixed"
/>
)}
</StyledLabelAndIconContainer>
)}
<StyledValueContainer>
Expand Down

0 comments on commit 0100244

Please sign in to comment.