-
Notifications
You must be signed in to change notification settings - Fork 365
Feat: Added Tooltip for Jump to msg button #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
bb318e3
8ae743e
d0115ad
2ae90fa
9e4882a
dcbcff8
e5ed49d
b774f24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |
| Popup, | ||
| useTheme, | ||
| ActionButton, | ||
| Tooltip, | ||
| Icon, | ||
| } from '@embeddedchat/ui-elements'; | ||
| import { MessageDivider } from '../../Message/MessageDivider'; | ||
|
|
@@ -136,18 +137,25 @@ export const MessageAggregator = ({ | |
| }} | ||
| /> | ||
|
|
||
| <ActionButton | ||
| square | ||
| ghost | ||
| onClick={() => setJumpToMessage(msg._id)} | ||
| css={{ | ||
| position: 'relative', | ||
| zIndex: 10, | ||
| 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, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason to hardcode this zIndex ? We might want to align with that standard
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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..
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: |
||
| marginRight: '5px', | ||
| marginTop: '6px', | ||
| }} | ||
| > | ||
| <Icon name="arrow-back" size="1.25rem" /> | ||
| </ActionButton> | ||
| </Tooltip> | ||
| </Box> | ||
| )} | ||
| </React.Fragment> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason we need this huge change for this ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, Any other way we can have this dynamic positioning
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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%)'}; | ||
| `, | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.