fix tooltip shadow

This commit is contained in:
Alexander Wang 2022-12-28 15:15:38 -08:00
parent 255d7724ef
commit e7aa4f8d19
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
4 changed files with 18 additions and 10 deletions

View file

@ -169,8 +169,10 @@ func generateTooltipLine(i, y int, text string, ruler *textmeasure.Ruler) (strin
dims := d2graph.GetTextDimensions(nil, ruler, mtext, nil) dims := d2graph.GetTextDimensions(nil, ruler, mtext, nil)
// TODO box-shadow: 0px 0px 32px rgba(31, 36, 58, 0.1); // filter: drop-shadow(0px 0px 32px #4444dd);
line := fmt.Sprintf(`<g transform="translate(%d %d)">%s</g>`, // filter: drop-shadow(0px 0px 32px rgba(31, 36, 58, 0.1));
// TODO box-shadow: 0px 0px 32px rgba(31 36 58 0.1);
line := fmt.Sprintf(`<g transform="translate(%d %d)" class="tooltip-icon">%s</g>`,
0, y, generateNumberedIcon(i, 0, 0)) 0, y, generateNumberedIcon(i, 0, 0))
line += fmt.Sprintf(`<text class="text" x="%d" y="%d" style="font-size: %dpx;">%s</text>`, line += fmt.Sprintf(`<text class="text" x="%d" y="%d" style="font-size: %dpx;">%s</text>`,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 803 KiB

After

Width:  |  Height:  |  Size: 803 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 650 KiB

After

Width:  |  Height:  |  Size: 650 KiB

View file

@ -842,7 +842,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske
} }
if targetShape.Tooltip != "" { if targetShape.Tooltip != "" {
fmt.Fprintf(writer, `<g transform="translate(%d %d)">%s</g>`, fmt.Fprintf(writer, `<g transform="translate(%d %d)" class="tooltip-icon">%s</g>`,
targetShape.Pos.X+targetShape.Width-tooltipIconRadius, targetShape.Pos.X+targetShape.Width-tooltipIconRadius,
targetShape.Pos.Y-tooltipIconRadius, targetShape.Pos.Y-tooltipIconRadius,
TooltipIcon, TooltipIcon,
@ -959,7 +959,7 @@ func embedFonts(buf *bytes.Buffer, fontFamily *d2fonts.FontFamily) {
if strings.Contains(content, t) { if strings.Contains(content, t) {
buf.WriteString(` buf.WriteString(`
.tooltip-icon { .tooltip-icon {
box-shadow: 0px 0px 32px rgba(31, 36, 58, 0.1); filter: drop-shadow(0px 0px 32px rgba(31, 36, 58, 0.1));
}`) }`)
break break
} }