-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add Tool Tip for Bread Crumbs in Comparison View #1717
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
73011a9
rework tooltip component
Kr0nox 09aa5df
add basic breadcrump tooltip
Kr0nox 0726728
token range bread crump
Kr0nox c6ed62d
fix click on match
Kr0nox bf639d1
fix e2e tests
Kr0nox 89a7662
fix more e2e tests
Kr0nox 876cfaa
deactivate pointer events on outer div
Kr0nox f8bb0d0
Merge remote-tracking branch 'origin/develop' into report-viewer/brea…
Kr0nox d4bf752
Merge branch 'report-viewer/breadcrump-tooltips' of https://github.co…
Kr0nox 29e1a08
fix screen scrollable bug
Kr0nox 6539913
fix tooltip in scrollable container
Kr0nox 02afba5
change wording in tooltip
Kr0nox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,85 @@ | ||
<template> | ||
<div class="group relative inline-block"> | ||
<slot></slot> | ||
<div | ||
class="invisible absolute z-10 rounded-md px-1 text-center text-white delay-0 group-hover:visible group-hover:delay-200" | ||
:style="tooltipPosition" | ||
<div class="group pointer-events-none inline"> | ||
<div ref="contentRef" class="pointer-events-auto"><slot></slot></div> | ||
<span | ||
class="invisible absolute box-border delay-0 group-hover:visible group-hover:delay-200" | ||
ref="tooltipRef" | ||
v-if="$slots.tooltip" | ||
> | ||
<slot name="tooltip"></slot> | ||
<div class="absolute border-4 border-solid" :style="arrowStyle" v-if="$slots.tooltip"> | ||
<!-- Arrow --> | ||
</div> | ||
</div> | ||
<span | ||
class="arrowBase pointer-events-auto relative z-10 block rounded-md bg-tooltip px-1 text-center text-white after:absolute after:border-4 after:border-solid after:border-transparent" | ||
:style="tooltipPosition" | ||
:class="{ | ||
'after:top-1/2 after:-mt-1': props.direction == 'left' || props.direction == 'right', | ||
'after:!left-1/2 after:-ml-1': props.direction == 'top' || props.direction == 'bottom', | ||
'after:top-full after:!border-t-tooltip': props.direction == 'top', | ||
'after:bottom-full after:!border-b-tooltip': props.direction == 'bottom', | ||
'after:left-full after:!border-l-tooltip': props.direction == 'left', | ||
'after:right-full after:!border-r-tooltip': props.direction == 'right' | ||
}" | ||
> | ||
<slot name="tooltip"></slot> | ||
</span> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { ToolTipDirection } from '@/model/ui/ToolTip' | ||
import { computed, type PropType, type StyleValue } from 'vue' | ||
import { computed, ref, type PropType, type Ref, type StyleValue } from 'vue' | ||
|
||
const props = defineProps({ | ||
direction: { | ||
type: String as PropType<ToolTipDirection>, | ||
required: false, | ||
default: 'top' | ||
}, | ||
/** Sometimes the absolute div is centered horizontally on the content. Set this to true if that is the case. */ | ||
toolTipContainerWillBeCentered: { | ||
type: Boolean, | ||
required: false, | ||
default: false | ||
} | ||
}) | ||
|
||
const opacity = 0.8 | ||
const contentRef: Ref<HTMLElement | null> = ref(null) | ||
const tooltipRef: Ref<HTMLElement | null> = ref(null) | ||
const arrowOffset = 4 | ||
|
||
const tooltipPosition = computed(() => { | ||
const style: StyleValue = {} | ||
|
||
if (props.direction == 'left' || props.direction == 'right') { | ||
style.top = '50%' | ||
style.transform = 'translateY(-50%)' | ||
if (props.direction == 'left') { | ||
style.right = '105%' | ||
} else { | ||
style.left = '105%' | ||
} | ||
} else { | ||
style.left = '50%' | ||
style.transform = 'translateX(-50%)' | ||
if (props.direction == 'top') { | ||
style.bottom = '105%' | ||
} else { | ||
style.top = '105%' | ||
} | ||
const contentDiv = contentRef.value | ||
const tooltipDiv = tooltipRef.value | ||
if (!contentDiv || !tooltipDiv) { | ||
return style | ||
} | ||
style.backgroundColor = `rgba(0,0,0,${opacity})` | ||
|
||
return style | ||
}) | ||
|
||
const arrowStyle = computed(() => { | ||
const style: StyleValue = {} | ||
style.content = ' ' | ||
|
||
style.borderColor = '' | ||
for (const dir of ['top', 'right', 'bottom', 'left']) { | ||
style.borderColor += dir == props.direction ? `rgba(0,0,0,${opacity}) ` : 'transparent ' | ||
// zeros the tooltip on the topleft of the content | ||
let top = -contentDiv.offsetHeight | ||
let left = props.toolTipContainerWillBeCentered ? -contentDiv.offsetWidth / 2 : 0 | ||
if (props.direction == 'right' || props.direction == 'left') { | ||
top += (contentDiv.offsetHeight - tooltipDiv.offsetHeight) / 2 | ||
} else { | ||
left -= (tooltipDiv.offsetWidth - contentDiv.offsetWidth) / 2 | ||
} | ||
|
||
if (props.direction == 'left' || props.direction == 'right') { | ||
style.top = '50%' | ||
style.marginTop = '-4px' | ||
if (props.direction == 'right') { | ||
left += contentDiv.offsetWidth + arrowOffset | ||
} else if (props.direction == 'left') { | ||
left -= tooltipDiv.offsetWidth + arrowOffset | ||
} else if (props.direction == 'bottom') { | ||
top += contentDiv.offsetHeight + arrowOffset | ||
} else { | ||
style.left = '50%' | ||
style.marginLeft = '-4px' | ||
top -= tooltipDiv.offsetHeight + arrowOffset | ||
} | ||
|
||
style[props.direction] = '100%' | ||
|
||
style.top = top + 'px' | ||
style.left = left + 'px' | ||
return style | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.arrowBase::after { | ||
content: ' '; | ||
} | ||
</style> |
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsaglam Maybe we should think about splitting up the Match class in the future. For now I would keep it as is, so we don't break our API more than necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking the same, already have made a card for that on the board
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. We could just do I class for token subsequences, and a match just takes two subsequences.