Repository: penpot/penpot
File: frontend/src/app/util/shape_icon.cljs (ClojureScript)

Code before:
        has-images? (cts/has-images? shape)
        has-mask? (:masked-group shape)]
    (if (ctk/instance-head? shape)
      (if main-instance?
        (if (ctk/is-variant? shape)
          "variant"
          "component")
        "component-copy")
      (case (:type shape)
        :frame (cond
                 (ctk/is-variant-container? shape)
                 "component"

                 (and flex-layout? col?)
                 "flex-horizontal"

                 (and flex-layout? row?)
                 "flex-vertical"

                 grid-layout?
                 "flex-grid"

                 :else
                 "board")
        :image "img"
        :line (if has-images?
                "img"
                "rectangle")
        :circle (if has-images?
                  "img"
                  "elipse")
        :path (if has-images?
                "img"
                "rectangle")
        :rect (if has-images?
                "img"
                "rectangle")
        :text "text"
        :group (if has-mask?
                 "mask"
                 "group")
        :bool (case (:bool-type shape)
                :difference   "boolean-difference"
                :exclude      "boolean-exclude"
                :intersection "boolean-intersection"
                ;; :default    "boolean-union" ;; Uncomment if needed
                nil)
        :svg-raw "img"
        nil))))

(defn get-shape-icon-by-type*

Review comment (performance):
This function is executed in a critical path of different parths of workspace, so we need to think on implement it in a more efficient way.

First of all, the type should be obtained with `(dm/get-prop shape :type)`
Also, all predicate execution on the let without knowing if we really need them are not very efficient. I suggest defining them only if we clearly know we need them. Per example `flex-layout?` is not used if shape is instance-head. 
I also can suggest defining a separate function for a shape type if it has enough logic (example the `:frame` shape and bool)

Code after:
    :intersection "boolean-intersection"
    nil))

(defn- get-frame-icon
  "Returns the icon for a frame shape"
  [shape]
  (cond
    (ctk/is-variant-container? shape)
    "component"

    (and (ctl/flex-layout? shape) (ctl/col? shape))
    "flex-horizontal"

    (and (ctl/flex-layout? shape) (ctl/row? shape))
    "flex-vertical"

    (ctl/grid-layout? shape)
    "flex-grid"

    :else
    "board"))

(defn get-shape-icon
  "Returns the icon for a shape based on its type and properties"
  [shape]
  (if (ctk/instance-head? shape)
    (if (ctk/main-instance? shape)
      (if (ctk/is-variant? shape)
        "variant"
        "component")
      "component-copy")
    (case (dm/get-prop shape :type)
      :frame (get-frame-icon shape)
      :image "img"
      :line (if (cts/has-images? shape)
              "img"
              "rectangle")
      :circle (if (cts/has-images? shape)
                "img"
                "elipse")
      :path (if (cts/has-images? shape)
              "img"
              "rectangle")
      :rect (if (cts/has-images? shape)
              "img"
              "rectangle")
      :text "text"
      :group (if (:masked-group shape)
               "mask"
               "group")
      :bool (get-bool-icon shape)