mirror of
https://github.com/penpot/penpot.git
synced 2025-06-08 18:31:40 +02:00
♻️ Replace tab switcher on viewer
This commit is contained in:
parent
129b7afda9
commit
63ffa704f5
6 changed files with 51 additions and 31 deletions
|
@ -99,3 +99,9 @@
|
||||||
.tab-text-and-icon {
|
.tab-text-and-icon {
|
||||||
padding-inline: var(--sp-xxs);
|
padding-inline: var(--sp-xxs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-panel {
|
||||||
|
display: grid;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: $s-16;
|
gap: $s-16;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: calc(100vh - #{$s-128}); // TODO: Fix this hardcoded value
|
||||||
padding-top: $s-8;
|
padding-top: $s-8;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
scrollbar-gutter: stable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
.element-options {
|
.element-options {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: calc(100vh - #{$s-128}); // TODO: Fix this hardcoded value
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding-bottom: $s-16;
|
padding-bottom: $s-16;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
scrollbar-gutter: stable;
|
||||||
}
|
}
|
||||||
|
|
||||||
.download-button {
|
.download-button {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.ui.components.shape-icon :as sir]
|
[app.main.ui.components.shape-icon :as sir]
|
||||||
[app.main.ui.components.tab-container :refer [tab-container tab-element]]
|
[app.main.ui.ds.tab-switcher :refer [tab-switcher*]]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.viewer.inspect.attributes :refer [attributes]]
|
[app.main.ui.viewer.inspect.attributes :refer [attributes]]
|
||||||
[app.main.ui.viewer.inspect.code :refer [code]]
|
[app.main.ui.viewer.inspect.code :refer [code]]
|
||||||
|
@ -61,9 +61,9 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps from on-change-section)
|
(mf/deps from on-change-section)
|
||||||
(fn [new-section]
|
(fn [new-section]
|
||||||
(reset! section new-section)
|
(reset! section (keyword new-section))
|
||||||
(when on-change-section
|
(when on-change-section
|
||||||
(on-change-section new-section))))
|
(on-change-section (keyword new-section)))))
|
||||||
|
|
||||||
handle-expand
|
handle-expand
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -74,7 +74,33 @@
|
||||||
navigate-to-help
|
navigate-to-help
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
(dom/open-new-window "https://help.penpot.app/user-guide/inspect/")))]
|
(dom/open-new-window "https://help.penpot.app/user-guide/inspect/")))
|
||||||
|
|
||||||
|
info-content
|
||||||
|
(mf/html [:& attributes {:page-id page-id
|
||||||
|
:objects objects
|
||||||
|
:file-id file-id
|
||||||
|
:frame frame
|
||||||
|
:shapes shapes
|
||||||
|
:from from
|
||||||
|
:libraries libraries
|
||||||
|
:share-id share-id}])
|
||||||
|
|
||||||
|
code-content
|
||||||
|
(mf/html [:& code {:frame frame
|
||||||
|
:shapes shapes
|
||||||
|
:on-expand handle-expand
|
||||||
|
:from from}])
|
||||||
|
|
||||||
|
tabs
|
||||||
|
#js [#js {:label (tr "inspect.tabs.info")
|
||||||
|
:id "info"
|
||||||
|
:content info-content}
|
||||||
|
|
||||||
|
#js {:label (tr "inspect.tabs.code")
|
||||||
|
:data-testid "code"
|
||||||
|
:id "code"
|
||||||
|
:content code-content}]]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps shapes handle-change-tab)
|
(mf/deps shapes handle-change-tab)
|
||||||
|
@ -108,25 +134,11 @@
|
||||||
;; (tr "inspect.tabs.code.selected.text")
|
;; (tr "inspect.tabs.code.selected.text")
|
||||||
[:span {:class (stl/css :layer-title)} (:name first-shape)]])]
|
[:span {:class (stl/css :layer-title)} (:name first-shape)]])]
|
||||||
[:div {:class (stl/css :inspect-content)}
|
[:div {:class (stl/css :inspect-content)}
|
||||||
[:& tab-container {:on-change-tab handle-change-tab
|
|
||||||
:selected @section
|
|
||||||
:content-class (stl/css :tab-content)
|
|
||||||
:header-class (stl/css :tab-header)}
|
|
||||||
[:& tab-element {:id :info :title (tr "inspect.tabs.info")}
|
|
||||||
[:& attributes {:page-id page-id
|
|
||||||
:objects objects
|
|
||||||
:file-id file-id
|
|
||||||
:frame frame
|
|
||||||
:shapes shapes
|
|
||||||
:from from
|
|
||||||
:libraries libraries
|
|
||||||
:share-id share-id}]]
|
|
||||||
|
|
||||||
[:& tab-element {:id :code :title (tr "inspect.tabs.code")}
|
[:> tab-switcher* {:tabs tabs
|
||||||
[:& code {:frame frame
|
:default-selected "info"
|
||||||
:shapes shapes
|
:on-change-tab handle-change-tab
|
||||||
:on-expand handle-expand
|
:class (stl/css :viewer-tab-switcher)}]]]
|
||||||
:from from}]]]]]
|
|
||||||
[:div {:class (stl/css :empty)}
|
[:div {:class (stl/css :empty)}
|
||||||
[:div {:class (stl/css :code-info)}
|
[:div {:class (stl/css :code-info)}
|
||||||
[:span {:class (stl/css :placeholder-icon)}
|
[:span {:class (stl/css :placeholder-icon)}
|
||||||
|
|
|
@ -97,10 +97,6 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-content {
|
.viewer-tab-switcher {
|
||||||
scrollbar-gutter: stable;
|
--tabs-nav-padding-inline-end: var(--sp-m);
|
||||||
}
|
|
||||||
|
|
||||||
.tab-header {
|
|
||||||
margin-right: $s-12;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue