|
1 | 1 | (ns re-com.nested-grid |
| 2 | + (:require-macros |
| 3 | + [re-com.core :refer [handler-fn]]) |
2 | 4 | (:require |
3 | 5 | [clojure.string :as str] |
4 | 6 | [re-com.util :as u :refer [px deref-or-value]] |
|
502 | 504 | (defn cell [{:keys [value]}] |
503 | 505 | (str value)) |
504 | 506 |
|
505 | | -(defn cell-wrapper [{:keys [column-path row-path theme children]}] |
| 507 | +(defn debug-click [event props] |
| 508 | + (when (.-altKey event) |
| 509 | + (js/console.log (pr-str (select-keys props [:column-path :row-path]))))) |
| 510 | + |
| 511 | +(defn cell-wrapper [{:keys [column-path row-path theme children] :as props}] |
506 | 512 | (into |
507 | 513 | [:div |
508 | | - (-> {:style {:grid-column (path->grid-line-name column-path) |
| 514 | + (-> {:on-click (when debug? (handler-fn (debug-click event props))) |
| 515 | + :style {:grid-column (path->grid-line-name column-path) |
509 | 516 | :grid-row (path->grid-line-name row-path)}} |
510 | 517 | (theme/apply {:part ::cell-wrapper} theme))] |
511 | 518 | children)) |
|
521 | 528 | (merge props {:children [(header-label props)]})]) |
522 | 529 |
|
523 | 530 | (defn row-header [props] |
524 | | - [u/default-part |
525 | | - (merge props {:children [(header-label props)]})]) |
| 531 | + [u/default-part |
| 532 | + (merge props {:children [(header-label props)]})]) |
526 | 533 |
|
527 | 534 | (def level count) |
528 | 535 |
|
|
612 | 619 | (let [grid-style {:grid-column (inc x) |
613 | 620 | :grid-row (inc y)}] |
614 | 621 | [:div (theme/apply |
615 | | - {:style grid-style} |
| 622 | + {:style grid-style |
| 623 | + :on-click (when debug? (handler-fn (debug-click event props)))} |
616 | 624 | {:state {:edge edge} :part ::header-spacer-wrapper} |
617 | 625 | theme) |
618 | 626 | (u/part header-spacer |
|
931 | 939 | (u/part column-header-wrapper |
932 | 940 | (-> props |
933 | 941 | (merge {:children children}) |
| 942 | + (merge (when debug? {:attr {:on-click (handler-fn (debug-click event props))}})) |
934 | 943 | (theme/apply {:part ::column-header-wrapper} theme))) |
935 | 944 | (when (and resize-columns? show?) |
936 | 945 | [resize-button (merge props {:mouse-down-x mouse-down-x |
|
979 | 988 | (u/part row-header-wrapper |
980 | 989 | (-> props |
981 | 990 | (merge {:children children}) |
| 991 | + (merge (when debug? {:attr {:on-click (handler-fn (debug-click event props))}})) |
982 | 992 | (theme/apply {:part ::row-header-wrapper} theme))) |
983 | 993 | (when (and resize-rows? show?) |
984 | 994 | [resize-button (merge props {:mouse-down-x mouse-down-x |
|
0 commit comments