mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 19:16:38 +02:00
Merge remote-tracking branch 'origin/feature-grid' into develop
This commit is contained in:
commit
00a7b4fda8
5 changed files with 24 additions and 31 deletions
|
@ -88,7 +88,7 @@
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(keep
|
(keep
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(when-let [data (or (:metadata shape) (:fill-image shape))]
|
(when-let [data (or (:metadata shape) (:fill-image shape) (-> shape :fills first :fill-image))]
|
||||||
[(:id shape) (cfg/resolve-file-media data)])))))
|
[(:id shape) (cfg/resolve-file-media data)])))))
|
||||||
|
|
||||||
(defn replace-map
|
(defn replace-map
|
||||||
|
@ -104,8 +104,7 @@
|
||||||
embed-images? (replace-map images-data))
|
embed-images? (replace-map images-data))
|
||||||
|
|
||||||
style-code (cond-> style-code
|
style-code (cond-> style-code
|
||||||
remove-localhost?
|
embed-images? (replace-map images-data))]
|
||||||
(str/replace "http://localhost:3449" ""))]
|
|
||||||
(str/format page-template style-code markup-code)))
|
(str/format page-template style-code markup-code)))
|
||||||
|
|
||||||
(mf/defc code
|
(mf/defc code
|
||||||
|
@ -145,7 +144,6 @@
|
||||||
|
|
||||||
images-urls (-> (shapes->images all-children)
|
images-urls (-> (shapes->images all-children)
|
||||||
(hooks/use-equal-memo))
|
(hooks/use-equal-memo))
|
||||||
|
|
||||||
style-code
|
style-code
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
(mf/deps fontfaces-css style-type all-children cg/generate-style-code)
|
(mf/deps fontfaces-css style-type all-children cg/generate-style-code)
|
||||||
|
@ -270,7 +268,7 @@
|
||||||
:on-click on-expand}
|
:on-click on-expand}
|
||||||
i/code-refactor]
|
i/code-refactor]
|
||||||
|
|
||||||
[:& copy-button {:data style-code
|
[:& copy-button {:data #(replace-map style-code images-data)
|
||||||
:on-copied on-style-copied}]]]
|
:on-copied on-style-copied}]]]
|
||||||
|
|
||||||
(when-not collapsed-css?
|
(when-not collapsed-css?
|
||||||
|
@ -339,7 +337,7 @@
|
||||||
{:on-click on-expand}
|
{:on-click on-expand}
|
||||||
i/full-screen]
|
i/full-screen]
|
||||||
|
|
||||||
[:& copy-button {:data style-code
|
[:& copy-button {:data #(replace-map style-code images-data)
|
||||||
:on-copied on-style-copied}]]
|
:on-copied on-style-copied}]]
|
||||||
|
|
||||||
[:div.code-row-display {:style #js {"--code-height" (str (or style-size 400) "px")}}
|
[:div.code-row-display {:style #js {"--code-height" (str (or style-size 400) "px")}}
|
||||||
|
|
|
@ -49,6 +49,9 @@
|
||||||
(or (d/not-empty? (:shadow shape))
|
(or (d/not-empty? (:shadow shape))
|
||||||
(d/not-empty? (:strokes shape))))
|
(d/not-empty? (:strokes shape))))
|
||||||
|
|
||||||
|
;; When a shape has several fills
|
||||||
|
(> (count (:fills shape)) 1)
|
||||||
|
|
||||||
;; When a shape has several strokes or the stroke is not a "border"
|
;; When a shape has several strokes or the stroke is not a "border"
|
||||||
(or (> (count (:strokes shape)) 1)
|
(or (> (count (:strokes shape)) 1)
|
||||||
(and (= (count (:strokes shape)) 1)
|
(and (= (count (:strokes shape)) 1)
|
||||||
|
|
|
@ -71,8 +71,6 @@ body {
|
||||||
:height
|
:height
|
||||||
:transform
|
:transform
|
||||||
:background
|
:background
|
||||||
:background-color
|
|
||||||
:background-image
|
|
||||||
:border
|
:border
|
||||||
:border-radius
|
:border-radius
|
||||||
:box-shadow
|
:box-shadow
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.config :as cfg]
|
||||||
[app.main.ui.formats :as fmt]
|
[app.main.ui.formats :as fmt]
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
@ -20,8 +21,6 @@
|
||||||
:min-width :size
|
:min-width :size
|
||||||
:min-height :size
|
:min-height :size
|
||||||
:background :color
|
:background :color
|
||||||
:background-color :color
|
|
||||||
:background-image :color-array
|
|
||||||
:border :border
|
:border :border
|
||||||
:border-radius :string-or-size-array
|
:border-radius :string-or-size-array
|
||||||
:box-shadow :shadows
|
:box-shadow :shadows
|
||||||
|
@ -55,6 +54,17 @@
|
||||||
(defn format-color
|
(defn format-color
|
||||||
[value _options]
|
[value _options]
|
||||||
(cond
|
(cond
|
||||||
|
(:image value)
|
||||||
|
(let [image-url (cfg/resolve-file-media (:image value))
|
||||||
|
opacity-color (when (not= (:opacity value) 1)
|
||||||
|
(uc/gradient->css {:type :linear
|
||||||
|
:stops [{:color "#FFFFFF" :opacity (:opacity value)}
|
||||||
|
{:color "#FFFFFF" :opacity (:opacity value)}]}))]
|
||||||
|
(if opacity-color
|
||||||
|
;; CSS doesn't allow setting directly opacity to background image, we should add a dummy gradient to get it
|
||||||
|
(dm/fmt "%, url(%) no-repeat center center / cover" opacity-color image-url)
|
||||||
|
(dm/fmt "url(%) no-repeat center center / cover" image-url)))
|
||||||
|
|
||||||
(not= (:opacity value) 1)
|
(not= (:opacity value) 1)
|
||||||
(uc/color->background value)
|
(uc/color->background value)
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,11 @@
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(defn fill->color
|
(defn fill->color
|
||||||
[{:keys [fill-color fill-opacity fill-color-gradient]}]
|
[{:keys [fill-color fill-opacity fill-color-gradient fill-image]}]
|
||||||
{:color fill-color
|
{:color fill-color
|
||||||
:opacity fill-opacity
|
:opacity fill-opacity
|
||||||
:gradient fill-color-gradient})
|
:gradient fill-color-gradient
|
||||||
|
:image fill-image})
|
||||||
|
|
||||||
(defmulti get-value
|
(defmulti get-value
|
||||||
(fn [property _shape _objects] property))
|
(fn [property _shape _objects] property))
|
||||||
|
@ -145,25 +146,8 @@
|
||||||
|
|
||||||
(defmethod get-value :background
|
(defmethod get-value :background
|
||||||
[_ {:keys [fills] :as shape} _]
|
[_ {:keys [fills] :as shape} _]
|
||||||
(let [single-fill? (= (count fills) 1)
|
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)))
|
||||||
ffill (first fills)
|
(fill->color (first fills))))
|
||||||
gradient? (some? (:fill-color-gradient ffill))]
|
|
||||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? gradient?)
|
|
||||||
(fill->color ffill))))
|
|
||||||
|
|
||||||
(defmethod get-value :background-color
|
|
||||||
[_ {:keys [fills] :as shape} _]
|
|
||||||
(let [single-fill? (= (count fills) 1)
|
|
||||||
ffill (first fills)
|
|
||||||
gradient? (some? (:fill-color-gradient ffill))]
|
|
||||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? (not gradient?))
|
|
||||||
(fill->color ffill))))
|
|
||||||
|
|
||||||
(defmethod get-value :background-image
|
|
||||||
[_ {:keys [fills] :as shape} _]
|
|
||||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) (> (count fills) 1))
|
|
||||||
(->> fills
|
|
||||||
(map fill->color))))
|
|
||||||
|
|
||||||
(defn get-stroke-data
|
(defn get-stroke-data
|
||||||
[stroke]
|
[stroke]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue