-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1292 from jplag/report-viewer/tooltips
Tooltips in report viewer
- Loading branch information
Showing
12 changed files
with
445 additions
and
110 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
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 was deleted.
Oops, something went wrong.
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,73 @@ | ||
<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" | ||
> | ||
<slot name="tooltip"></slot> | ||
<div class="absolute border-4 border-solid" :style="arrowStyle"><!-- Arrow --></div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, type PropType, type StyleValue } from 'vue' | ||
const props = defineProps({ | ||
direction: { | ||
type: String as PropType<'top' | 'bottom' | 'left' | 'right'>, | ||
required: false, | ||
default: 'top' | ||
} | ||
}) | ||
const opacity = 0.8 | ||
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%' | ||
} | ||
} | ||
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 ' | ||
} | ||
if (props.direction == 'left' || props.direction == 'right') { | ||
style.top = '50%' | ||
style.marginTop = '-4px' | ||
} else { | ||
style.left = '50%' | ||
style.marginLeft = '-4px' | ||
} | ||
style[props.direction] = '100%' | ||
return style | ||
}) | ||
</script> |
40 changes: 40 additions & 0 deletions
40
report-viewer/src/components/optionsSelectors/MetricSelector.vue
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,40 @@ | ||
<template> | ||
<OptionsSelectorComponent | ||
:title="title" | ||
:labels="labels" | ||
@selection-changed="(i) => $emit('selectionChanged', metrics[i])" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, type PropType, type Ref } from 'vue' | ||
import OptionsSelectorComponent from './OptionsSelectorComponent.vue' | ||
import { MetricType, metricToolTips } from '@/model/MetricType' | ||
const props = defineProps({ | ||
metrics: { | ||
type: Array<MetricType>, | ||
required: false, | ||
default: [MetricType.AVERAGE, MetricType.MAXIMUM] | ||
}, | ||
title: { | ||
type: String, | ||
required: false, | ||
default: '' | ||
}, | ||
defaultSelection: { | ||
type: String as PropType<MetricType>, | ||
required: false, | ||
default: MetricType.AVERAGE | ||
} | ||
}) | ||
defineEmits(['selectionChanged']) | ||
const labels: Ref<{ displayValue: string; tooltip: string }[]> = computed(() => | ||
props.metrics.map((metric) => ({ | ||
displayValue: metricToolTips[metric].longName, | ||
tooltip: metricToolTips[metric].tooltip | ||
})) | ||
) | ||
</script> |
27 changes: 27 additions & 0 deletions
27
report-viewer/src/components/optionsSelectors/OptionComponent.vue
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,27 @@ | ||
<template> | ||
<Interactable | ||
class="mr-2 box-border flex h-6 w-fit items-center justify-center whitespace-nowrap !rounded-2xl px-[12px] text-center hover:!border-[2px] hover:px-[11px]" | ||
:class="{ '!border-accent-dark !bg-accent !bg-opacity-40': selected }" | ||
@click="$emit('click')" | ||
> | ||
{{ label }} | ||
</Interactable> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Interactable from '../InteractableComponent.vue' | ||
defineProps({ | ||
label: { | ||
type: String, | ||
required: true | ||
}, | ||
selected: { | ||
type: Boolean, | ||
required: false, | ||
default: false | ||
} | ||
}) | ||
defineEmits(['click']) | ||
</script> |
76 changes: 76 additions & 0 deletions
76
report-viewer/src/components/optionsSelectors/OptionsSelectorComponent.vue
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,76 @@ | ||
<!-- | ||
Component for selecting one of multiple options. | ||
--> | ||
<template> | ||
<div class="flex h-fit flex-row items-center text-center text-xs"> | ||
<div v-if="title != ''" class="mr-3 text-base"> | ||
{{ title }} | ||
</div> | ||
<div v-for="[index, label] in labels.entries()" :key="index"> | ||
<ToolTipComponent v-if="(label as ToolTipLabel).displayValue !== undefined" direction="right"> | ||
<template #default> | ||
<OptionComponent | ||
:label="(label as ToolTipLabel).displayValue" | ||
:selected="index == getSelected()" | ||
@click="select(index)" | ||
/> | ||
</template> | ||
|
||
<template #tooltip> | ||
<p class="whitespace-pre text-sm"> | ||
{{ (label as ToolTipLabel).tooltip }} | ||
</p> | ||
</template> | ||
</ToolTipComponent> | ||
<OptionComponent | ||
v-else | ||
:label="label as string" | ||
:selected="index == getSelected()" | ||
@click="select(index)" | ||
/> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import ToolTipComponent from '../ToolTipComponent.vue' | ||
import OptionComponent from './OptionComponent.vue' | ||
|
||
type ToolTipLabel = { | ||
displayValue: string | ||
tooltip: string | ||
} | ||
|
||
const props = defineProps({ | ||
title: { | ||
type: String, | ||
required: false, | ||
default: '' | ||
}, | ||
labels: { | ||
type: Array<string | ToolTipLabel>, | ||
required: true | ||
}, | ||
defaultSelected: { | ||
type: Number, | ||
required: false, | ||
default: 0 | ||
} | ||
}) | ||
|
||
const emit = defineEmits(['selectionChanged']) | ||
const selected = ref(-1) | ||
|
||
function getSelected() { | ||
if (selected.value == -1) { | ||
return props.defaultSelected | ||
} | ||
return selected.value | ||
} | ||
|
||
function select(index: number) { | ||
emit('selectionChanged', index) | ||
selected.value = index | ||
} | ||
</script> |
Oops, something went wrong.