Skip to content

Commit

Permalink
Better tooltip positioning for single lettered content
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Jul 26, 2024
1 parent f45bd6c commit 480c1c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/Code/Syntax/SyntaxSegment.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Code.HashQualified as HQ
import Code.Syntax.Linked exposing (Linked(..))
import Code.Syntax.SyntaxSegmentHelp as SyntaxSegmentHelp
import Html exposing (Html, span, text)
import Html.Attributes exposing (class)
import Html.Attributes exposing (class, classList)
import Html.Events exposing (onMouseEnter, onMouseLeave)
import Json.Decode as Decode exposing (andThen, at, field)
import Json.Decode.Extra exposing (when)
Expand Down Expand Up @@ -329,7 +329,14 @@ view linked ((SyntaxSegment sType sText) as segment) =
in
Tooltip.view
(span
[ class "syntax-help", class className ]
[ class "syntax-help"
, class className
, classList
[ ( "single-letter"
, String.length (String.trim sText) == 1
)
]
]
[ c ]
)
tooltip
Expand Down
8 changes: 7 additions & 1 deletion src/css/code/syntax.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ code a:active .tooltip-trigger.tooltip_show .tooltip {
}

.tooltip-trigger:has(> .syntax-help) .tooltip {
margin-left: -1rem;
font-family: var(--font-sans-serif);
}
.tooltip-trigger:has(> .syntax-help) .tooltip {
margin-left: -0.5rem;
}

.tooltip-trigger:has(> .syntax-help.single-letter) .tooltip {
margin-left: -15px;
}

.tooltip-trigger:has(> .syntax-help) .tooltip code {
display: inline-block;
Expand Down

0 comments on commit 480c1c9

Please sign in to comment.