Skip to content

Commit

Permalink
add 'AI Prompt' tooltip to AI button at bottom-left
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianoFerrari committed Sep 25, 2024
1 parent 02a5537 commit 200ac80
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/elm/Doc/UI.elm
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,19 @@ viewAIPrompt ctrlOrCmd isWaiting promptInputMsg =
]


viewAIButton : msg -> Html msg
viewAIButton aiPromptMsg =
div [ id "ai-prompt-button", onClick aiPromptMsg ]
viewAIButton :
{ openAIPrompt : msg
, tooltipRequested : String -> TooltipPosition -> TranslationId -> msg
, tooltipClosed : msg
}
-> Html msg
viewAIButton msgs =
div
[ id "ai-prompt-button"
, onClick msgs.openAIPrompt
, onMouseEnter <| msgs.tooltipRequested "ai-prompt-button" RightTooltip TooltipAIPrompt
, onMouseLeave msgs.tooltipClosed
]
[ AntIcons.robotOutlined [ width 12, height 12 ] ]


Expand Down
12 changes: 10 additions & 2 deletions src/elm/Page/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1903,7 +1903,10 @@ applyParentMsg parentMsg ( prevModel, prevCmd ) =
( { prevModel | tooltip = Nothing }, prevCmd )

OpenAIPrompt ->
( { prevModel | modalState = AIPrompt False "" }
( { prevModel
| modalState = AIPrompt False ""
, tooltip = Nothing
}
, Cmd.batch
[ prevCmd
, Task.attempt (always NoOp) (Browser.Dom.focus "ai-prompt-textarea")
Expand Down Expand Up @@ -2360,7 +2363,12 @@ viewModal globalData session modalState =
case modalState of
NoModal ->
if Feature.enabled AIPromptFeature session then
[ UI.viewAIButton AIButtonClicked ]
[ UI.viewAIButton
{ openAIPrompt = AIButtonClicked
, tooltipRequested = TooltipRequested
, tooltipClosed = TooltipClosed
}
]

else
[]
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Page/Doc.elm
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ incoming incomingMsg model =
"mod+shift+down" ->
normalMode model (mergeDown activeId)

"mod+shift+k" ->
"mod+shift+k" ->
normalMode model (mergeUp activeId)

"mod+shift+up" ->
Expand Down
30 changes: 30 additions & 0 deletions src/elm/Translation.elm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type TranslationId
| InsertBelowTitle
| AddAboveAction
| AIFeatures
| TooltipAIPrompt
| ToOpenAIPrompt
| AIGenerateChildren
| AIGenerateBelow
Expand Down Expand Up @@ -3617,6 +3618,35 @@ tr lang trans =
, nb = "%nb:AIFeatures%"
}

TooltipAIPrompt ->
{ en = "AI Prompt"
, zh_hans = "%zh_hans:TooltipAIPrompt%"
, zh_hant = "%zh_hant:TooltipAIPrompt%"
, es = "%es:TooltipAIPrompt%"
, ar = "%ar:TooltipAIPrompt%"
, fr = "%fr:TooltipAIPrompt%"
, ru = "%ru:TooltipAIPrompt%"
, de = "%de:TooltipAIPrompt%"
, ja = "%ja:TooltipAIPrompt%"
, pes = "%pes:TooltipAIPrompt%"
, it = "%it:TooltipAIPrompt%"
, ro = "%ro:TooltipAIPrompt%"
, hr = "%hr:TooltipAIPrompt%"
, nl = "%nl:TooltipAIPrompt%"
, hu = "%hu:TooltipAIPrompt%"
, sv = "%sv:TooltipAIPrompt%"
, ca = "%ca:TooltipAIPrompt%"
, br = "%br:TooltipAIPrompt%"
, mr = "%mr:TooltipAIPrompt%"
, cs = "%cs:TooltipAIPrompt%"
, fa = "%fa:TooltipAIPrompt%"
, id = "%id:TooltipAIPrompt%"
, ko = "%ko:TooltipAIPrompt%"
, pl = "%pl:TooltipAIPrompt%"
, uk = "%uk:TooltipAIPrompt%"
, nb = "%nb:TooltipAIPrompt%"
}

ToOpenAIPrompt ->
{ en = "to open AI Prompt"
, zh_hans = "%zh_hans:ToOpenAIPrompt%"
Expand Down

0 comments on commit 200ac80

Please sign in to comment.