0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 04:49:03 -05:00

Move sidebar ns to correct location

This commit is contained in:
Andrey Antukh 2023-05-24 23:52:31 +02:00 committed by Alejandro Alonso
parent da5209001b
commit 5d892d14d5
4 changed files with 72 additions and 69 deletions

View file

@ -28,7 +28,7 @@
[app.main.ui.workspace.palette :refer [palette]] [app.main.ui.workspace.palette :refer [palette]]
[app.main.ui.workspace.sidebar.collapsable-button :refer [collapsed-button]] [app.main.ui.workspace.sidebar.collapsable-button :refer [collapsed-button]]
[app.main.ui.workspace.sidebar.history :refer [history-toolbox]] [app.main.ui.workspace.sidebar.history :refer [history-toolbox]]
[app.main.ui.workspace.sidebar.sidebar :refer [left-sidebar right-sidebar]] [app.main.ui.workspace.sidebar :refer [left-sidebar right-sidebar]]
[app.main.ui.workspace.textpalette :refer [textpalette]] [app.main.ui.workspace.textpalette :refer [textpalette]]
[app.main.ui.workspace.viewport :refer [viewport]] [app.main.ui.workspace.viewport :refer [viewport]]
[app.util.dom :as dom] [app.util.dom :as dom]

View file

@ -4,9 +4,10 @@
;; ;;
;; Copyright (c) KALEIDOS INC ;; Copyright (c) KALEIDOS INC
(ns app.main.ui.workspace.sidebar.sidebar (ns app.main.ui.workspace.sidebar
(:require-macros [app.main.style :refer [css]]) (:require-macros [app.main.style :refer [css]])
(:require (:require
[app.common.data.macros :as dm]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
@ -30,64 +31,69 @@
;; --- Left Sidebar (Component) ;; --- Left Sidebar (Component)
(mf/defc left-sidebar (mf/defc left-sidebar
{:wrap [mf/memo]} {::mf/wrap [mf/memo]
::mf/wrap-props false}
[{:keys [layout] :as props}] [{:keys [layout] :as props}]
(let [options-mode (mf/deref refs/options-mode-global) (let [options-mode (mf/deref refs/options-mode-global)
mode-inspect? (= options-mode :inspect) mode-inspect? (= options-mode :inspect)
section (cond (or mode-inspect? (contains? layout :layers)) :layers section (cond (or mode-inspect? (contains? layout :layers)) :layers
(contains? layout :assets) :assets) (contains? layout :assets) :assets)
shortcuts? (contains? layout :shortcuts) shortcuts? (contains? layout :shortcuts)
show-debug? (contains? layout :debug-panel) show-debug? (contains? layout :debug-panel)
new-css-system (mf/use-ctx ctx/new-css-system) new-css? (mf/use-ctx ctx/new-css-system)
{:keys [on-pointer-down on-lost-pointer-capture on-pointer-move parent-ref size]} {:keys [on-pointer-down on-lost-pointer-capture on-pointer-move parent-ref size]}
(use-resize-hook :left-sidebar 255 255 500 :x false :left) (use-resize-hook :left-sidebar 255 255 500 :x false :left)
handle-collapse handle-collapse
(fn [] (mf/use-fn #(st/emit! (dw/toggle-layout-flag :collapse-left-sidebar)))
(st/emit! (dw/toggle-layout-flag :collapse-left-sidebar)))]
on-tab-change
(mf/use-fn #(st/emit! (dw/go-to-layout %)))
]
[:aside {:ref parent-ref [:aside {:ref parent-ref
:class (if new-css-system :class (if ^boolean new-css?
(dom/classnames (css :left-settings-bar) true) (dom/classnames (css :left-settings-bar) true)
(dom/classnames :settings-bar true (dom/classnames :settings-bar true
:settings-bar-left true :settings-bar-left true
:two-row (<= size 300) :two-row (<= size 300)
:three-row (and (> size 300) (<= size 400)) :three-row (and (> size 300) (<= size 400))
:four-row (> size 400))) :four-row (> size 400)))
:style #js {"--width" (str size "px")}} :style #js {"--width" (dm/str size "px")}}
[:div {:on-pointer-down on-pointer-down [:div {:on-pointer-down on-pointer-down
:on-lost-pointer-capture on-lost-pointer-capture :on-lost-pointer-capture on-lost-pointer-capture
:on-pointer-move on-pointer-move :on-pointer-move on-pointer-move
:class (if new-css-system :class (if ^boolean new-css?
(dom/classnames (css :resize-area) true) (dom/classnames (css :resize-area) true)
(dom/classnames :resize-area true))}] (dom/classnames :resize-area true))}]
[:div {:class (if new-css-system [:div {:class (if ^boolean new-css?
(dom/classnames (css :settings-bar-inside) true) (dom/classnames (css :settings-bar-inside) true)
(dom/classnames :settings-bar-inside true))} (dom/classnames :settings-bar-inside true))}
(cond (cond
shortcuts? (true? shortcuts?)
[:& shortcuts-container] [:& shortcuts-container]
show-debug? (true? show-debug?)
[:& debug-panel] [:& debug-panel]
:else :else
[:* (if ^boolean new-css?
[:& tab-container
(if new-css-system {:on-change-tab on-tab-change
[:& tab-container {:on-change-tab #(st/emit! (dw/go-to-layout %))
:selected section :selected section
:shortcuts? shortcuts? :shortcuts? shortcuts?
:collapsable? true :collapsable? true
:handle-collapse handle-collapse} :handle-collapse handle-collapse}
[:& tab-element {:id :layers
:title (tr "workspace.sidebar.layers")} [:& tab-element {:id :layers :title (tr "workspace.sidebar.layers")}
[:div {:class (dom/classnames (css :layers-tab) true)} [:div {:class (dom/classnames (css :layers-tab) true)}
[:& sitemap {:layout layout}] [:& sitemap {:layout layout}]
[:& layers-toolbox {:size-parent size}]]] [:& layers-toolbox {:size-parent size}]]]
(when-not mode-inspect? (when-not ^boolean mode-inspect?
[:& tab-element {:id :assets :title (tr "workspace.toolbar.assets")} [:& tab-element {:id :assets :title (tr "workspace.toolbar.assets")}
[:& assets-toolbox]])] [:& assets-toolbox]])]
@ -96,54 +102,51 @@
{:on-click handle-collapse {:on-click handle-collapse
:aria-label (tr "workspace.sidebar.collapse")} :aria-label (tr "workspace.sidebar.collapse")}
i/arrow-slide] i/arrow-slide]
[:& tab-container {:on-change-tab #(st/emit! (dw/go-to-layout %))
[:& tab-container
{:on-change-tab on-tab-change
:selected section :selected section
:shortcuts? shortcuts? :shortcuts? shortcuts?
:collapsable? true :collapsable? true
:handle-collapse handle-collapse} :handle-collapse handle-collapse}
[:& tab-element {:id :layers
:title (tr "workspace.sidebar.layers")} [:& tab-element {:id :layers :title (tr "workspace.sidebar.layers")}
[:div {:class (dom/classnames :layers-tab true)} [:div {:class (dom/classnames :layers-tab true)}
[:& sitemap {:layout layout}] [:& sitemap {:layout layout}]
[:& layers-toolbox {:size-parent size}]]] [:& layers-toolbox {:size-parent size}]]]
(when-not mode-inspect? (when-not ^boolean mode-inspect?
[:& tab-element {:id :assets :title (tr "workspace.toolbar.assets")} [:& tab-element {:id :assets :title (tr "workspace.toolbar.assets")}
[:& assets-toolbox]])]])])]])) [:& assets-toolbox]])]]))]]))
;; --- Right Sidebar (Component) ;; --- Right Sidebar (Component)
(mf/defc right-sidebar (mf/defc right-sidebar
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[props] [{:keys [layout section] :as props}]
(let [layout (obj/get props "layout") (let [drawing-tool (:tool (mf/deref refs/workspace-drawing))
section (obj/get props "section")
drawing-tool (:tool (mf/deref refs/workspace-drawing))
is-comments? (= drawing-tool :comments) is-comments? (= drawing-tool :comments)
is-history? (contains? layout :document-history) is-history? (contains? layout :document-history)
is-inspect? (= section :inspect) is-inspect? (= section :inspect)
expanded? (mf/deref refs/inspect-expanded) expanded? (mf/deref refs/inspect-expanded)
can-be-expanded? (and can-be-expanded? (and (not is-comments?)
(not is-comments?)
(not is-history?) (not is-history?)
is-inspect?)] is-inspect?)]
(mf/use-effect (mf/with-effect [can-be-expanded?]
(mf/deps can-be-expanded?)
(fn []
(when (not can-be-expanded?) (when (not can-be-expanded?)
(st/emit! (dw/set-inspect-expanded false))))) (st/emit! (dw/set-inspect-expanded false))))
[:aside.settings-bar.settings-bar-right {:class (when (and can-be-expanded? expanded?) "expanded")} [:aside.settings-bar.settings-bar-right {:class (when (and can-be-expanded? expanded?) "expanded")}
[:div.settings-bar-inside [:div.settings-bar-inside
(cond (cond
is-comments? (true? is-comments?)
[:& comments-sidebar] [:& comments-sidebar]
is-history? (true? is-history?)
[:& history-toolbox] [:& history-toolbox]
:else :else