                            :on-click remove-fn}
          [bootstrap/glyph {:glyph :remove}] " Remove"]]]]
      [:div
-      [package-total-view (reagent/current-component) packages]
+      [package-total-view (reagent/current-component) packages on-click-fn]
       (when-not (and count (>= 1 count))
         [:h2 "⨉" count])]]
     [:div.preview

         ^{:key (:id item)}
         [trolley-item item
          (partial remove-item-from-trolley trolley-state (:id item))
          #(swap! trolley-state update-in [:items] conj item)])
       (group-items (:items @trolley-state))))]])

(defn trolley-preview
  [trolley-state]
  (let [items (:items @trolley-state)
        packages (reduce (fn [all item]
                           (concat all (map #(assoc % :item item) (:packages item))))
                         [] items)

                  (* (count packages) 2)))
        max-width (* scale (apply max (map (fn [{:keys [width height length]}] (max width height length)) packages)))]
    [:svg {:width "100%" :height "80%"
           :view-box (clojure.string/join " " [0 0 max-width (+ 2 total-height)])}
     [:g {:stroke :black
          :stroke-width (* scale 1)}
      (:rects
       (reduce
        (fn [{:keys [offset] :as m} {:keys [width height length item] :as package}]
          (let [box-height (* scale (min width height length))
                box-width (* scale (max width height length))]
            (-> m
                (update :rects conj
                        [:rect {:key (hash package)
                                :x 0
                                :y offset
                                :height box-height
                                :width box-width
                                :fill (if (= (:id item) selected-flatpack-item) :black :transparent)}])
                (update :offset - (* scale 1) box-height))))
        {:offset total-height :rects nil}
        packages))]]))

(defn select-items-view
