Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://linear.app/unleash/issue/2-576/improve-how-text-that-has-tooltip-should-look-so-they-are-not ![image](https://user-images.githubusercontent.com/14320932/212140467-46d4f7f9-b5c1-40ea-9748-4a6ccc7950bb.png) ![image](https://user-images.githubusercontent.com/14320932/212140316-d6e88bc0-c26e-436b-855f-5f6e8697aed8.png) - Adapts the existing `HtmlTooltip` component to support setting `maxHeight` and `maxWidth` properties; - Introduces a new common component: `TooltipLink`; - Adapts SA (tokens), features (tags), variants (overrides, payloads) and project access (role and role description); - Role description in project access now uses this component instead of the old jankier popover component;
- Loading branch information
Showing
8 changed files
with
150 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 37 additions & 22 deletions
59
frontend/src/component/common/HtmlTooltip/HtmlTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
import { styled, Tooltip, tooltipClasses, TooltipProps } from '@mui/material'; | ||
import { SpacingArgument } from '@mui/system/createTheme/createSpacing'; | ||
|
||
const StyledHtmlTooltip = styled(({ className, ...props }: TooltipProps) => ( | ||
<Tooltip {...props} classes={{ popper: className }} /> | ||
))(({ theme }) => ({ | ||
maxWidth: theme.spacing(37.5), | ||
[`& .${tooltipClasses.tooltip}`]: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
backgroundColor: theme.palette.background.paper, | ||
padding: theme.spacing(1, 1.5), | ||
borderRadius: theme.shape.borderRadiusMedium, | ||
boxShadow: theme.shadows[2], | ||
color: theme.palette.text.primary, | ||
fontWeight: theme.fontWeight.medium, | ||
maxWidth: 'inherit', | ||
border: `1px solid ${theme.palette.lightBorder}`, | ||
}, | ||
[`& .${tooltipClasses.arrow}`]: { | ||
'&:before': { | ||
const StyledHtmlTooltip = styled( | ||
({ className, maxWidth, maxHeight, ...props }: IHtmlTooltipProps) => ( | ||
<Tooltip {...props} classes={{ popper: className }} /> | ||
), | ||
{ | ||
shouldForwardProp: prop => prop !== 'maxWidth' && prop !== 'maxHeight', | ||
} | ||
)<{ maxWidth?: SpacingArgument; maxHeight?: SpacingArgument }>( | ||
({ theme, maxWidth, maxHeight }) => ({ | ||
maxWidth: maxWidth || theme.spacing(37.5), | ||
[`& .${tooltipClasses.tooltip}`]: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
backgroundColor: theme.palette.background.paper, | ||
padding: theme.spacing(1, 1.5), | ||
borderRadius: theme.shape.borderRadiusMedium, | ||
boxShadow: theme.shadows[2], | ||
color: theme.palette.text.primary, | ||
fontWeight: theme.fontWeight.medium, | ||
maxWidth: 'inherit', | ||
border: `1px solid ${theme.palette.lightBorder}`, | ||
maxHeight: maxHeight || theme.spacing(37.5), | ||
overflow: 'auto', | ||
}, | ||
color: theme.palette.background.paper, | ||
}, | ||
})); | ||
[`& .${tooltipClasses.arrow}`]: { | ||
'&:before': { | ||
border: `1px solid ${theme.palette.lightBorder}`, | ||
}, | ||
color: theme.palette.background.paper, | ||
}, | ||
}) | ||
); | ||
|
||
export interface IHtmlTooltipProps extends TooltipProps { | ||
maxWidth?: SpacingArgument; | ||
maxHeight?: SpacingArgument; | ||
} | ||
|
||
export const HtmlTooltip = (props: TooltipProps) => ( | ||
export const HtmlTooltip = (props: IHtmlTooltipProps) => ( | ||
<StyledHtmlTooltip {...props}>{props.children}</StyledHtmlTooltip> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ReactNode } from 'react'; | ||
import { Link, LinkProps, styled, TooltipProps } from '@mui/material'; | ||
import { HtmlTooltip, IHtmlTooltipProps } from '../HtmlTooltip/HtmlTooltip'; | ||
|
||
const StyledLink = styled(Link, { | ||
shouldForwardProp: prop => prop !== 'highlighted', | ||
})<{ highlighted?: boolean }>(({ theme, highlighted }) => ({ | ||
backgroundColor: highlighted ? theme.palette.highlight : 'transparent', | ||
color: theme.palette.text.primary, | ||
textDecorationColor: theme.palette.text.disabled, | ||
textDecorationStyle: 'dashed', | ||
textUnderlineOffset: theme.spacing(0.5), | ||
})); | ||
|
||
interface ITooltipLinkProps extends LinkProps { | ||
tooltip: ReactNode; | ||
highlighted?: boolean; | ||
tooltipProps?: Omit<IHtmlTooltipProps, 'title' | 'children'>; | ||
children: ReactNode; | ||
} | ||
|
||
export const TooltipLink = ({ | ||
tooltip, | ||
highlighted, | ||
tooltipProps, | ||
children, | ||
...props | ||
}: ITooltipLinkProps) => ( | ||
<HtmlTooltip title={tooltip} {...tooltipProps}> | ||
<StyledLink highlighted={highlighted} {...props}> | ||
{children} | ||
</StyledLink> | ||
</HtmlTooltip> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.