mirror of
https://github.com/penpot/penpot.git
synced 2025-05-05 07:15:54 +02:00
✨ Add new file creation button on placeholder
This commit is contained in:
parent
1174502cb8
commit
1eede8442d
6 changed files with 48 additions and 46 deletions
|
@ -321,29 +321,34 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-empty-placeholder {
|
.grid-empty-placeholder {
|
||||||
align-items: center;
|
|
||||||
border: 1px dashed $color-gray-20;
|
|
||||||
border-radius: $br-small;
|
border-radius: $br-small;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-start;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
margin: $size-4;
|
margin: $size-4;
|
||||||
padding: 3rem;
|
padding: 24px;
|
||||||
justify-content: center;
|
background-image: url("data:image/svg+xml,%3csvg width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' fill='none' stroke='%23E3E3E3FF' stroke-width='3' stroke-dasharray='8%2c 16' stroke-dashoffset='0' stroke-linecap='square'/%3e%3c/svg%3e");
|
||||||
|
|
||||||
&.drafts {
|
.create-new {
|
||||||
background-image: url("/images/ph-left.svg"), url("/images/ph-right.svg");
|
background-color: transparent;
|
||||||
background-position: 15% bottom, 85% top;
|
border: 2px solid $color-gray-10;
|
||||||
background-repeat: no-repeat;
|
width: 200px;
|
||||||
.text {
|
height: 100%;
|
||||||
p {
|
cursor: pointer;
|
||||||
max-width: 360px;
|
color: $color-gray-30;
|
||||||
text-align: center;
|
border-radius: 3px;
|
||||||
font-size: $fs16;
|
&:hover {
|
||||||
}
|
color: $color-primary-dark;
|
||||||
|
border: 2px solid $color-primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.search {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
|
@ -355,9 +360,4 @@
|
||||||
color: $color-gray-30;
|
color: $color-gray-30;
|
||||||
font-size: $fs16;
|
font-size: $fs16;
|
||||||
}
|
}
|
||||||
|
|
||||||
img.ph-files {
|
|
||||||
height: 150px;
|
|
||||||
margin-right: calc(100% - 148px);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc header
|
(mf/defc header
|
||||||
[{:keys [project] :as props}]
|
[{:keys [project on-create-clicked] :as props}]
|
||||||
(let [local (mf/use-state {:menu-open false
|
(let [local (mf/use-state {:menu-open false
|
||||||
:edition false})
|
:edition false})
|
||||||
on-menu-click
|
on-menu-click
|
||||||
|
@ -41,13 +41,6 @@
|
||||||
(mf/deps project)
|
(mf/deps project)
|
||||||
#(st/emit! (dd/toggle-project-pin project)))
|
#(st/emit! (dd/toggle-project-pin project)))
|
||||||
|
|
||||||
on-create-clicked
|
|
||||||
(mf/use-callback
|
|
||||||
(mf/deps project)
|
|
||||||
(fn [event]
|
|
||||||
(dom/prevent-default event)
|
|
||||||
(st/emit! (dd/create-file {:project-id (:id project)}))))
|
|
||||||
|
|
||||||
on-import
|
on-import
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps (:id project))
|
(mf/deps (:id project))
|
||||||
|
@ -82,7 +75,7 @@
|
||||||
:on-import on-import}]
|
:on-import on-import}]
|
||||||
|
|
||||||
[:div.dashboard-header-actions
|
[:div.dashboard-header-actions
|
||||||
[:a.btn-secondary.btn-small {:on-click on-create-clicked :data-test "new-file"}
|
[:a.btn-secondary.btn-small {:on-click (partial on-create-clicked project) :data-test "new-file"}
|
||||||
(tr "dashboard.new-file")]
|
(tr "dashboard.new-file")]
|
||||||
|
|
||||||
(when-not (:is-default project)
|
(when-not (:is-default project)
|
||||||
|
@ -103,7 +96,13 @@
|
||||||
files (->> (vals files-map)
|
files (->> (vals files-map)
|
||||||
(filter #(= (:id project) (:project-id %)))
|
(filter #(= (:id project) (:project-id %)))
|
||||||
(sort-by :modified-at)
|
(sort-by :modified-at)
|
||||||
(reverse))]
|
(reverse))
|
||||||
|
|
||||||
|
on-create-clicked
|
||||||
|
(mf/use-callback
|
||||||
|
(fn [project event]
|
||||||
|
(dom/prevent-default event)
|
||||||
|
(st/emit! (dd/create-file {:project-id (:id project)}))))]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps project)
|
(mf/deps project)
|
||||||
|
@ -121,8 +120,11 @@
|
||||||
(dd/clear-selected-files))))
|
(dd/clear-selected-files))))
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:& header {:team team :project project}]
|
[:& header {:team team
|
||||||
|
:project project
|
||||||
|
:on-create-clicked on-create-clicked}]
|
||||||
[:section.dashboard-container
|
[:section.dashboard-container
|
||||||
[:& grid {:project project
|
[:& grid {:project project
|
||||||
:files files}]]]))
|
:files files
|
||||||
|
:on-create-clicked on-create-clicked}]]]))
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@
|
||||||
:on-menu-close on-menu-close}])]]]))
|
:on-menu-close on-menu-close}])]]]))
|
||||||
|
|
||||||
(mf/defc grid
|
(mf/defc grid
|
||||||
[{:keys [files project] :as props}]
|
[{:keys [files project on-create-clicked] :as props}]
|
||||||
(let [dragging? (mf/use-state false)
|
(let [dragging? (mf/use-state false)
|
||||||
project-id (:id project)
|
project-id (:id project)
|
||||||
|
|
||||||
|
@ -268,7 +268,9 @@
|
||||||
:navigate? true}])]
|
:navigate? true}])]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& empty-placeholder {:default? (:is-default project)}])]))
|
[:& empty-placeholder {:default? (:is-default project)
|
||||||
|
:on-create-clicked on-create-clicked
|
||||||
|
:project project}])]))
|
||||||
|
|
||||||
(mf/defc line-grid-row
|
(mf/defc line-grid-row
|
||||||
[{:keys [files selected-files on-load-more dragging?] :as props}]
|
[{:keys [files selected-files on-load-more dragging?] :as props}]
|
||||||
|
@ -326,7 +328,7 @@
|
||||||
(tr "dashboard.show-all-files")]])]))
|
(tr "dashboard.show-all-files")]])]))
|
||||||
|
|
||||||
(mf/defc line-grid
|
(mf/defc line-grid
|
||||||
[{:keys [project team files on-load-more] :as props}]
|
[{:keys [project team files on-load-more on-create-clicked] :as props}]
|
||||||
(let [dragging? (mf/use-state false)
|
(let [dragging? (mf/use-state false)
|
||||||
project-id (:id project)
|
project-id (:id project)
|
||||||
team-id (:id team)
|
team-id (:id team)
|
||||||
|
@ -414,5 +416,6 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& empty-placeholder {:dragging? @dragging?
|
[:& empty-placeholder {:dragging? @dragging?
|
||||||
:default? (:is-default project)}])]))
|
:default? (:is-default project)
|
||||||
|
:on-create-clicked on-create-clicked}])]))
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,16 @@
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc empty-placeholder
|
(mf/defc empty-placeholder
|
||||||
[{:keys [dragging? default?] :as props}]
|
[{:keys [dragging? on-create-clicked project] :as props}]
|
||||||
(cond
|
(cond
|
||||||
(true? dragging?)
|
(true? dragging?)
|
||||||
[:div.grid-row.no-wrap
|
[:div.grid-row.no-wrap
|
||||||
[:div.grid-item]]
|
[:div.grid-item]]
|
||||||
|
|
||||||
(true? default?)
|
|
||||||
[:div.grid-empty-placeholder.drafts {:data-test "empty-placeholder"}
|
|
||||||
[:div.text
|
|
||||||
[:& i18n/tr-html {:label "dashboard.empty-placeholder-drafts"}]]]
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:div.grid-empty-placeholder
|
[:div.grid-empty-placeholder
|
||||||
[:img.ph-files {:src "images/ph-file.svg"}]]))
|
[:button.create-new {:on-click (partial on-create-clicked project)}
|
||||||
|
(tr "dashboard.new-file")]]))
|
||||||
|
|
||||||
(mf/defc loading-placeholder
|
(mf/defc loading-placeholder
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -151,7 +151,8 @@
|
||||||
{:project project
|
{:project project
|
||||||
:team team
|
:team team
|
||||||
:on-load-more on-nav
|
:on-load-more on-nav
|
||||||
:files files}]]))
|
:files files
|
||||||
|
:on-create-clicked create-file}]]))
|
||||||
|
|
||||||
|
|
||||||
(def recent-files-ref
|
(def recent-files-ref
|
||||||
|
|
|
@ -42,17 +42,17 @@
|
||||||
[:section.dashboard-container.search
|
[:section.dashboard-container.search
|
||||||
(cond
|
(cond
|
||||||
(empty? search-term)
|
(empty? search-term)
|
||||||
[:div.grid-empty-placeholder
|
[:div.grid-empty-placeholder.search
|
||||||
[:div.icon i/search]
|
[:div.icon i/search]
|
||||||
[:div.text (tr "dashboard.type-something")]]
|
[:div.text (tr "dashboard.type-something")]]
|
||||||
|
|
||||||
(nil? result)
|
(nil? result)
|
||||||
[:div.grid-empty-placeholder
|
[:div.grid-empty-placeholder.search
|
||||||
[:div.icon i/search]
|
[:div.icon i/search]
|
||||||
[:div.text (tr "dashboard.searching-for" search-term)]]
|
[:div.text (tr "dashboard.searching-for" search-term)]]
|
||||||
|
|
||||||
(empty? result)
|
(empty? result)
|
||||||
[:div.grid-empty-placeholder
|
[:div.grid-empty-placeholder.search
|
||||||
[:div.icon i/search]
|
[:div.icon i/search]
|
||||||
[:div.text (tr "dashboard.no-matches-for" search-term)]]
|
[:div.text (tr "dashboard.no-matches-for" search-term)]]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue