Skip to content

Commit

Permalink
Added height-based underline offset handling
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-danylchenko committed Jul 1, 2024
1 parent 36958ad commit a12404d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/text-annotator/src/highlight/span/spansRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ViewportState } from '@annotorious/core';
import { colord } from 'colord';
import { dequal } from 'dequal/lite';
import type { Rect, TextAnnotatorState } from '../../state';
import { paint, type HighlightPainter } from '../HighlightPainter';
import { type HighlightPainter, paint } from '../HighlightPainter';
import type { ViewportBounds } from '../viewport';
import { createBaseRenderer, type RendererImplementation } from '../baseRenderer';
import type { Highlight } from '../Highlight';
Expand Down Expand Up @@ -71,12 +71,10 @@ const createRenderer = (container: HTMLElement): RendererImplementation => {
span.style.width = `${rect.width}px`;
span.style.height = `${rect.height}px`;

const backgroundColor = colord(style?.fill || DEFAULT_STYLE.fill)
span.style.backgroundColor = colord(style?.fill || DEFAULT_STYLE.fill)
.alpha(style?.fillOpacity === undefined ? DEFAULT_STYLE.fillOpacity : style.fillOpacity)
.toHex();

span.style.backgroundColor = backgroundColor;

if (style.underlineStyle)
span.style.borderStyle = style.underlineStyle;

Expand All @@ -87,7 +85,7 @@ const createRenderer = (container: HTMLElement): RendererImplementation => {
span.style.borderBottomWidth = `${style.underlineThickness}px`;

if (style.underlineOffset)
span.style.paddingBottom = `${style.underlineOffset}px`;
span.style.height = `${rect.height + style.underlineOffset}px`

highlightLayer.appendChild(span);
}
Expand Down

0 comments on commit a12404d

Please sign in to comment.