From feef74282685c976688a42e5670d47e05ed6ae55 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Mon, 19 Jun 2023 13:37:33 +0200 Subject: [PATCH] Remove on hover highlight for annotations --- .../annotations/annotation_marker.ts | 17 ++++---------- .../annotations/machine_annotation.ts | 4 +--- .../components/annotations/thread.ts | 5 +--- app/assets/javascripts/state/Annotations.ts | 23 ------------------- 4 files changed, 6 insertions(+), 43 deletions(-) diff --git a/app/assets/javascripts/components/annotations/annotation_marker.ts b/app/assets/javascripts/components/annotations/annotation_marker.ts index c35321797d..55de405ced 100644 --- a/app/assets/javascripts/components/annotations/annotation_marker.ts +++ b/app/assets/javascripts/components/annotations/annotation_marker.ts @@ -31,11 +31,10 @@ export class AnnotationMarker extends LitElement { static getStyle(annotation: AnnotationData): string { if (["error", "warning", "info"].includes(annotation.type)) { - return `text-decoration: wavy underline ${AnnotationMarker.colors[annotation.type]} ${annotationState.isHovered(annotation) ? 2 : 1}px;`; + return `text-decoration: wavy underline ${AnnotationMarker.colors[annotation.type]} 1px;`; } else { - const colorKey = annotationState.isHovered(annotation) ? `${annotation.type}-intense` : annotation.type; return ` - background: ${AnnotationMarker.colors[colorKey]}; + background: ${AnnotationMarker.colors[annotation.type]}; padding-top: 2px; padding-bottom: 2px; margin-top: -2px; @@ -96,20 +95,12 @@ export class AnnotationMarker extends LitElement { } get sortedAnnotations(): AnnotationData[] { - return this.annotations.sort( (a, b) => { - if (annotationState.isHovered(a)) { - return -1; - } else if (annotationState.isHovered(b)) { - return 1; - } else { - return compareAnnotationOrders(a, b); - } - }); + return this.annotations.sort( compareAnnotationOrders ); } get machineAnnotationMarkerSVG(): TemplateResult | undefined { const firstMachineAnnotation = this.sortedAnnotations.find(a => !isUserAnnotation(a)); - const size = annotationState.isHovered(firstMachineAnnotation) ? 20 : 14; + const size = 14; return firstMachineAnnotation && html` `; diff --git a/app/assets/javascripts/components/annotations/machine_annotation.ts b/app/assets/javascripts/components/annotations/machine_annotation.ts index 2020e0bad4..d4a9ffa002 100644 --- a/app/assets/javascripts/components/annotations/machine_annotation.ts +++ b/app/assets/javascripts/components/annotations/machine_annotation.ts @@ -30,9 +30,7 @@ export class MachineAnnotation extends ShadowlessLitElement { render(): TemplateResult { return html` -
+
${I18n.t(`js.annotation.type.${this.data.type}`)} diff --git a/app/assets/javascripts/components/annotations/thread.ts b/app/assets/javascripts/components/annotations/thread.ts index cd8481cb5b..fa681d26de 100644 --- a/app/assets/javascripts/components/annotations/thread.ts +++ b/app/assets/javascripts/components/annotations/thread.ts @@ -87,10 +87,7 @@ export class Thread extends i18nMixin(ShadowlessLitElement) { render(): TemplateResult { return this.data ? html` -
+
${this.data.responses.map(response => html` diff --git a/app/assets/javascripts/state/Annotations.ts b/app/assets/javascripts/state/Annotations.ts index 2169dd72f5..6a847ea795 100644 --- a/app/assets/javascripts/state/Annotations.ts +++ b/app/assets/javascripts/state/Annotations.ts @@ -26,29 +26,6 @@ export function isUserAnnotation(annotation: AnnotationData): annotation is User class AnnotationState extends State { @stateProperty visibility: AnnotationVisibilityOptions = "all"; @stateProperty isQuestionMode = false; - readonly isHoveredByKey = new StateMap(); - - private getKeyFromAnnotation(annotation: AnnotationData): string { - if (annotation === undefined || annotation === null) { - return ""; - } - - if (isUserAnnotation(annotation)) { - return `${annotation.id}`; - } - - return `${annotation.row}-${annotation.column}-${annotation.type}-${annotation.text}`; - } - - setHovered(annotation: AnnotationData, hovered: boolean): void { - const key = this.getKeyFromAnnotation(annotation); - this.isHoveredByKey.set(key, hovered); - } - - isHovered = (annotation: AnnotationData): boolean => { - const key = this.getKeyFromAnnotation(annotation); - return this.isHoveredByKey.get(key) ?? false; - }; isVisible(annotation: AnnotationData): boolean { if (this.visibility === "none") {