Skip to content

Commit b574d6d

Browse files
committed
Add katex error tooltip and fix tooltip overflows
1 parent a82cf72 commit b574d6d

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

packages/markups/src/katex/KatexErrorBoundary.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
// import colors from '@rocket.chat/fuselage-tokens/colors.json';
21
import React, { useState } from 'react';
32
import { ErrorBoundary } from 'react-error-boundary';
43
import PropTypes from 'prop-types';
5-
import { Box } from '@embeddedchat/ui-elements';
4+
import { Box, Tooltip, useTheme } from '@embeddedchat/ui-elements';
65
import { css } from '@emotion/react';
76

8-
// const Fallback = styled('span')`
9-
// text-decoration: underline;
10-
// text-decoration-color: ${colors.r400};
11-
// `;
12-
137
const KatexErrorBoundary = ({ children, code }) => {
148
const [error, setError] = useState(null);
9+
const { theme } = useTheme();
1510
return (
1611
<ErrorBoundary
17-
// children={children}
1812
onError={setError}
1913
fallback={
20-
<Box
21-
is="span"
22-
title={error?.message}
23-
css={css`
24-
text-decoration: underline;
25-
text-decoration-color: red;
26-
`}
14+
<Tooltip
15+
text={error?.message}
16+
position="top"
2717
>
28-
<span>{code}</span>
29-
</Box>
18+
<Box
19+
is="span"
20+
css={css`
21+
text-decoration: underline;
22+
text-decoration-color: ${theme.colors.destructive};
23+
`}
24+
>
25+
<span>{code}</span>
26+
</Box>
27+
</Tooltip>
3028
}
3129
>
3230
{children}

packages/react/src/views/AttachmentHandler/AudioAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const AudioAttachment = ({
3232
<Box
3333
css={[
3434
css`
35-
line-height: 0;
35+
line-height: 0.75rem;
3636
border-radius: inherit;
3737
padding: 0.5rem;
3838
`,

packages/react/src/views/AttachmentHandler/ImageAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const ImageAttachment = ({
4242
css`
4343
cursor: pointer;
4444
border-radius: inherit;
45-
line-height: 0;
45+
line-height: 0.75rem;
4646
padding: 0.5rem;
4747
`,
4848
(type ? variantStyles.pinnedContainer : '') ||

packages/react/src/views/AttachmentHandler/VideoAttachment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const VideoAttachment = ({
4242
<Box
4343
css={[
4444
css`
45-
line-height: 0;
45+
line-height: 0.75rem;
4646
border-radius: inherit;
4747
padding: 0.5rem;
4848
@media (max-width: 450px) {

packages/ui-elements/src/components/Tooltip/Tooltip.styles.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ const getTooltipStyles = (theme, position) => {
1414
z-index: ${theme.zIndex?.tooltip || 1400};
1515
font-size: 12.5px;
1616
font-weight: 500;
17-
white-space: nowrap;
17+
max-width: 160px;
18+
width: max-content;
1819
font-family: sans-serif;
19-
top: ${position === 'top' ? 'calc(-100% - 20px)' : 'calc(100% + 10px)'};
20+
${position === 'top' ? 'bottom: calc(100% + 10px)' : 'top: calc(100% + 10px)'};
2021
`,
2122
tooltipArrow: css`
2223
content: '';

0 commit comments

Comments
 (0)