Skip to content

Commit

Permalink
prompt-buffer: Improve source heading buttons.
Browse files Browse the repository at this point in the history
Change button glypsh for `next-source`, `previous-source`
and `toggle-attributes-display`. Move `toggle-attributes-source` to the right.
Mute next/previous source arrow when next/previous source is unavailable.
Add hover effect to show keybinding and change background color.
Change layout to flexbox.
  • Loading branch information
hgluka authored and aadcg committed Oct 31, 2023
1 parent 6738931 commit 366d06f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 34 deletions.
3 changes: 3 additions & 0 deletions assets/glyphs/down-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/glyphs/down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/glyphs/plus-minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/glyphs/up-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/glyphs/up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 59 additions & 34 deletions source/prompt-buffer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ See `nyxt::attribute-widths'.")
:opacity 0.6)
`((:and .button (:or :visited :active))
:color ,theme:background)
`(".button.inactive svg path"
:stroke ,theme:secondary-)
`("#input"
:height "28px"
:margin-top "0"
Expand All @@ -159,12 +161,27 @@ See `nyxt::attribute-widths'.")
`(".source"
:margin-left "10px"
:margin-top "15px")
`(".source-name"
`(".source-heading"
:background-color ,theme:secondary
:color ,theme:on-secondary
:padding-left "5px"
:display "flex"
:justify-content "space-between"
:align-items "stretch"
:line-height "24px"
:border-radius "3px 0 0 0")
`(".source-heading > div"
:display "flex"
:justify-content "space-between"
:align-items "center")
`(".source-heading > div > button"
:padding "5px 6px 5px 6px"
:min-height "100%")
`(".source-heading > div > #down-arrow"
:margin-right "-2px")
`(".source-heading > div > #up-arrow"
:margin-left "-2px")
`(".source-heading > div > button:hover"
:background-color ,theme:secondary+)
`("#suggestions"
:background-color ,theme:background
:color ,theme:on-background
Expand Down Expand Up @@ -503,38 +520,46 @@ This does not redraw the whole prompt buffer, use `prompt-render' for that."
(last-source-index (1- (length sources))))
(flet ((source->html (source)
(spinneret:with-html-string
(:div :class "source"
(:div :class "source-name"
:style (if (and (hide-single-source-header-p prompt-buffer)
(sera:single sources))
"display:none;"
"display:revert")
(:nbutton
:text ""
:title "Next source"
:buffer prompt-buffer
'(funcall (sym:resolve-symbol :next-source :command)))
(:nbutton
:text ""
:title "Previous source"
:buffer prompt-buffer
'(funcall (sym:resolve-symbol :previous-source :command)))
(:nbutton
:text ""
:title "Toggle attributes display"
:buffer prompt-buffer
`(funcall (sym:resolve-symbol :toggle-attributes-display :command)
:source ,source))
(prompter:name source)
(if (prompter:hide-suggestion-count-p source)
""
(suggestion-and-mark-count prompt-buffer
(prompter:suggestions source)
(prompter:marks source)
:enable-marks-p (prompter:enable-marks-p source)))
(if (prompter:ready-p source)
""
"(In progress...)"))
(:div.source
(:div.source-heading
:style (when (and (hide-single-source-header-p prompt-buffer)
(sera:single sources))
"display:none")
(:div
(:nbutton
:class (unless (prompter:adjacent-source prompt-buffer :source source) "inactive")
:id "down-arrow"
:text (:raw (gethash "down-arrow.svg" *static-data*))
:title (format nil "Next source (~a)" (binding-keys (sym:resolve-symbol :next-source :command)
:modes (modes prompt-buffer)))
:buffer prompt-buffer
'(funcall (sym:resolve-symbol :next-source :command)))
(:nbutton
:class (unless (prompter:adjacent-source prompt-buffer :steps -1 :source source) "inactive")
:id "up-arrow"
:text (:raw (gethash "up-arrow.svg" *static-data*))
:title (format nil "Previous source (~a)" (binding-keys (sym:resolve-symbol :previous-source :command)
:modes (modes prompt-buffer)))
:buffer prompt-buffer
'(funcall (sym:resolve-symbol :previous-source :command)))
(prompter:name source)
(if (prompter:hide-suggestion-count-p source)
""
(suggestion-and-mark-count prompt-buffer
(prompter:suggestions source)
(prompter:marks source)
:enable-marks-p (prompter:enable-marks-p source)))
(if (prompter:ready-p source)
""
"(In progress...)"))
(:div
(:nbutton
:text (:raw (gethash "plus-minus.svg" *static-data*))
:title (format nil "Toggle attributes display (~a)" (binding-keys (sym:resolve-symbol 'toggle-attributes-display :command)
:modes (modes prompt-buffer)))
:buffer prompt-buffer
`(funcall (sym:resolve-symbol :toggle-attributes-display :command)
:source ,source))))
(:raw (render-attributes source prompt-buffer))))))
(ps-eval :buffer prompt-buffer
(setf (ps:@ (nyxt/ps:qs document "#suggestions") |innerHTML|)
Expand Down

0 comments on commit 366d06f

Please sign in to comment.