Skip to content

Commit

Permalink
Revert "Try fixing cell text alignment"
Browse files Browse the repository at this point in the history
This reverts commit f859f29.
  • Loading branch information
prabhanshuguptagit committed Feb 26, 2024
1 parent 49d270b commit a04577f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
3 changes: 2 additions & 1 deletion public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ a {
z-index: 0;
background: var(--cell-background);
outline: 0.5px solid var(--sheet-border);
padding: 0 var(--cell-padding) 0 var(--cell-padding);
padding: var(--cell-padding);
padding-top: 6px;
font-family: "SpaceGrotesk";
overflow: hidden;
cursor: cell;
Expand Down
28 changes: 6 additions & 22 deletions src/bean/ui/views/sheet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,11 @@
(submit-cell-input)
(edit-cell move-to-cell sheet))))

(defn- center-text-v! [bitmap-text y h]
(let [text-h (.-height bitmap-text)]
(set! (.-y bitmap-text) (- (+ y (/ h 2)) text-h)))
bitmap-text)

(defn- center-text-h! [bitmap-text x w]
(let [text-w (.-width bitmap-text)]
(set! (.-x bitmap-text) (- (+ x (/ w 2)) (/ text-w 2))))
bitmap-text)

(defn- center-text! [bitmap-text x y h w]
(center-text-h! bitmap-text x w)
(center-text-v! bitmap-text y h)
(let [text-h (.-height bitmap-text)
text-w (.-width bitmap-text)]
(set! (.-x bitmap-text) (- (+ x (/ w 2)) (/ text-w 2)))
(set! (.-y bitmap-text) (- (+ y (/ h 2)) text-h)))
bitmap-text)

(defn- heading-text [text x y h w]
Expand Down Expand Up @@ -199,15 +191,7 @@
(set! (.-y bitmap) (+ y (:cell-padding styles/sizes)))
(-> mask (.beginFill 0xffffff) (.drawRect x y w h) .endFill)
(set! (.-mask bitmap) mask)
(if merged?
(center-text! bitmap
(+ x (:cell-padding styles/sizes))
(+ y (:cell-padding styles/sizes))
(- h (:cell-padding styles/sizes))
(- w (:cell-padding styles/sizes)))
(center-text-v! bitmap
(+ y (:cell-padding styles/sizes))
(- h (:cell-padding styles/sizes))))
(when merged? (center-text! bitmap x y h w))
(.addChild g mask)
(.addChild g bitmap)
g))
Expand Down Expand Up @@ -761,7 +745,7 @@
:minHeight (cell-h r cell row-heights)
:minWidth (cell-w c cell col-widths)
:text-align (when merged? :center)
:line-height (str (cell-h r cell row-heights) "px")
:line-height (str (- (cell-h r cell row-heights) 12) "px")
:background-color (when background (util/color-int->hex background))
:fontWeight (if bold? "bold" "normal")}
:on-pointer-down #(grid-selection-start
Expand Down

0 comments on commit a04577f

Please sign in to comment.