diff --git a/src/quo2/components/code/common/style.cljs b/src/quo2/components/code/common/style.cljs index 0f623e717638..018494006a89 100644 --- a/src/quo2/components/code/common/style.cljs +++ b/src/quo2/components/code/common/style.cljs @@ -18,7 +18,7 @@ nil)) (defn text-style - [class-names] + [class-names preview?] (let [text-color (->> class-names (map keyword) (some (fn [class-name] @@ -26,6 +26,7 @@ text-color))))] (cond-> {:flex-shrink 1 :line-height 18} + preview? (assoc :color colors/white) text-color (assoc :color text-color)))) (defn border-color @@ -37,7 +38,7 @@ (if preview? {:overflow :hidden :width 108 - :background-color (colors/theme-colors colors/neutral-20 colors/neutral-80 theme) + :background-color (colors/theme-colors colors/neutral-20 colors/neutral-80 :dark) :border-radius 8} {:overflow :hidden :padding 8 @@ -64,7 +65,7 @@ :width (+ line-number-width 8 7) :background-color (colors/theme-colors colors/neutral-5 colors/neutral-80)} preview? (assoc :width 20 - :background-color (colors/theme-colors colors/neutral-10 colors/neutral-70 theme)))) + :background-color (colors/theme-colors colors/neutral-10 colors/neutral-70 :dark)))) (defn divider [line-number-width] diff --git a/src/quo2/components/code/common/view.cljs b/src/quo2/components/code/common/view.cljs index 8007ac950a17..af4290448b0e 100644 --- a/src/quo2/components/code/common/view.cljs +++ b/src/quo2/components/code/common/view.cljs @@ -10,15 +10,15 @@ [reagent.core :as reagent])) (defn- render-nodes - [nodes] + [nodes preview?] (map (fn [{:keys [children value last-line?] :as node}] (if children (into [text/text (cond-> {:weight :code :size :paragraph-2 - :style (style/text-style (get-in node [:properties :className]))} + :style (style/text-style (get-in node [:properties :className]) preview?)} last-line? (assoc :number-of-lines 1))] - (render-nodes children)) + (render-nodes children preview?)) ;; Remove newlines as we already render each line separately. (string/trim-newline value))) nodes)) @@ -28,7 +28,7 @@ [rn/view {:style style/line} [rn/view {:style (style/line-number line-number-width preview?)} [text/text - {:style (style/text-style ["line-number"]) + {:style (style/text-style ["line-number"] preview?) :weight :code :size :paragraph-2} line-number]] @@ -38,8 +38,8 @@ (defn- code-block [{:keys [rows line-number-width preview?]}] [rn/view - (->> rows - (render-nodes) + (->> preview? + (render-nodes ,, rows) (map-indexed (fn [idx row-content] [line {:line-number (inc idx)