Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Popup,
useTheme,
ActionButton,
Tooltip,
Icon,
} from '@embeddedchat/ui-elements';
import { MessageDivider } from '../../Message/MessageDivider';
Expand Down Expand Up @@ -136,18 +137,25 @@ export const MessageAggregator = ({
}}
/>

<ActionButton
square
ghost
onClick={() => setJumpToMessage(msg._id)}
css={{
position: 'relative',
zIndex: 10,
Comment thread
dhairyashiil marked this conversation as resolved.
Outdated
marginRight: '5px',
}}
<Tooltip
text="Jump to message"
position="left"
key={msg._id}
>
<Icon name="arrow-back" size="1.25rem" />
</ActionButton>
<ActionButton
square
ghost
onClick={() => setJumpToMessage(msg._id)}
css={{
position: 'relative',
zIndex: 10,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to hardcode this zIndex ?
The thing is, if you notice, we are using specific set of zIndex mentioned in the documentation

We might want to align with that standard

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that z-index logic was not added by me. I added only the tooltip part here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay cool then, still not sure how it is there.. there was specific set of z-indexes I made after my gsoc..
That's fine
Will see..

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see PR #667. It looks like this hardcoded code came from there. No worries, I’ll fix the logic in the current PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spiral-Memory, what value should I set for zIndex?

I can see that in the codebase, the zIndex value can come from the theme, but if not, we’re maintaining specific zIndex values for certain components, like:

z-index: ${theme.zIndex?.sidebar || 1200};
z-index: ${theme.zIndex?.menu || 1300};
z-index: ${theme.zIndex?.tooltip || 1400};
z-index: ${theme.zIndex?.modal || 1500};
z-index: ${theme.zIndex?.toastbar || 1600};

marginRight: '5px',
marginTop: '6px',
}}
>
<Icon name="arrow-back" size="1.25rem" />
</ActionButton>
</Tooltip>
</Box>
)}
</React.Fragment>
Expand Down
45 changes: 40 additions & 5 deletions packages/ui-elements/src/components/Tooltip/Tooltip.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const getTooltipStyles = (theme, position) => {
const styles = {
tooltip: css`
position: absolute;
left: 64%;
transform: translateX(-50%);
background-color: ${theme.invertedColors.secondary};
color: ${theme.invertedColors.secondaryForeground};
padding: 8.5px;
Expand All @@ -16,21 +14,58 @@ const getTooltipStyles = (theme, position) => {
font-weight: 500;
white-space: nowrap;
font-family: sans-serif;
top: ${position === 'top' ? 'calc(-100% - 20px)' : 'calc(100% + 10px)'};

top: ${position === 'top'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason we need this huge change for this ?
I am just worried that it should not affect the other existing tooltips

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I double-checked the changed code. I also tried reducing the code, but I was unable to reduce many lines because, earlier, we were only considering the top and bottom positions, and we were hardcoding the CSS values for the left and transform properties in the tooltip. Now, we have 4 positions and are setting the required fields dynamically.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay,
That is fine, but the code is not very readable

Any other way we can have this dynamic positioning

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, Let's see. I will look into it.

? 'calc(-100% - 20px)'
: position === 'bottom'
? 'calc(100% + 10px)'
: position === 'left'
? '50%'
: position === 'right'
? '50%'
: 'auto'};
left: ${position === 'left'
? 'calc(-100% - 80px)'
: position === 'right'
? 'calc(100% + 10px)'
: '64%'};
transform: ${position === 'top'
? 'translateX(-50%)'
: position === 'bottom'
? 'translateX(-50%)'
: position === 'left' || position === 'right'
? 'translateY(-50%)'
: 'auto'};
`,

tooltipArrow: css`
content: '';
position: absolute;
left: 50%;
margin-left: -4px;
border-width: 6px;
border-style: solid;
border-color: ${theme.invertedColors.secondary} transparent transparent
transparent;
top: ${position === 'top' ? '100%' : 'auto'};

top: ${position === 'top'
? '100%'
: position === 'bottom'
? 'auto'
: position === 'left' || position === 'right'
? '50%'
: 'auto'};
bottom: ${position === 'bottom' ? '100%' : 'auto'};
left: ${position === 'left'
? '102%'
: position === 'right'
? '-7px'
: '50%'};
transform: ${position === 'bottom'
? 'translateX(-50%) rotate(180deg)'
: position === 'right'
? 'translateY(-50%) rotate(90deg)'
: position === 'left'
? 'translateY(-50%) rotate(-90deg)'
: 'translateX(-50%)'};
`,
};
Expand Down