Skip to content

Commit

Permalink
Merge branch 'upgrade-playwright' of github.com:oraluben/logseq into …
Browse files Browse the repository at this point in the history
…upgrade-playwright
  • Loading branch information
oraluben committed Feb 23, 2023
2 parents e89126c + abf092e commit 9f60909
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/main/frontend/components/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,30 @@

(rum/defc absolute-modal < rum/static
[cp modal-name set-default-width? {:keys [top left rect]}]
(let [vw-width js/window.innerWidth
(let [MAX-HEIGHT 700
MAX-HEIGHT' 600
MAX-WIDTH 600
SM-MAX-WIDTH 300
Y-BOUNDARY-HEIGHT 150
vw-width js/window.innerWidth
vw-height js/window.innerHeight
vw-max-width (- vw-width (:left rect))
vw-max-height (- vw-height (:top rect))
vw-max-height' (:top rect)
sm? (< vw-width 415)
max-height (min (- vw-max-height 20) 800)
max-width (if sm? 300 (min (max 400 (/ vw-max-width 2)) 600))
max-height (min (- vw-max-height 20) MAX-HEIGHT)
max-height' (min (- vw-max-height' 70) MAX-HEIGHT')
max-width (if sm? SM-MAX-WIDTH (min (max 400 (/ vw-max-width 2)) MAX-WIDTH))
offset-top 24
to-max-height (if (and (seq rect) (> vw-height max-height))
(let [delta-height (- vw-height (+ (:top rect) top offset-top))]
(if (< delta-height max-height)
(- (max (* 2 offset-top) delta-height) 16)
max-height))
max-height)
to-max-height (cond-> (if (and (seq rect) (> vw-height max-height))
(let [delta-height (- vw-height (+ (:top rect) top offset-top))]
(if (< delta-height max-height)
(- (max (* 2 offset-top) delta-height) 16)
max-height))
max-height)

(= modal-name "commands")
(min 500))
right-sidebar? (:ui/sidebar-open? @state/state)
editing-key (first (keys (:editor/editing? @state/state)))
*el (rum/use-ref nil)
Expand All @@ -367,8 +377,9 @@
(when (> ofx 0)
(set! (.-transform (.-style el)) (str "translateX(-" (+ ofx 20) "px)")))))))
[right-sidebar? editing-key])
y-overflow-vh? (< to-max-height 130)
to-max-height (if y-overflow-vh? max-height to-max-height)
y-overflow-vh? (or (< to-max-height Y-BOUNDARY-HEIGHT)
(> (- max-height' to-max-height) Y-BOUNDARY-HEIGHT))
to-max-height (if y-overflow-vh? max-height' to-max-height)
pos-rect (when (and (seq rect) editing-key)
(:rect (cursor/get-caret-pos (state/get-input))))
y-diff (when pos-rect (- (:height pos-rect) (:height rect)))
Expand Down
5 changes: 5 additions & 0 deletions src/main/frontend/components/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
&.is-overflow-vh-y {
transform: translateY(calc(-100% - 2rem));
}

&[data-modal-name="commands"] {
width: 380px !important;
max-width: 90vw !important;
}
}

.is-mobile {
Expand Down

0 comments on commit 9f60909

Please sign in to comment.