♻️ Update spacing on assets tab

This commit is contained in:
Eva 2024-02-07 11:26:23 +01:00 committed by Andrey Antukh
parent de7c61e5ca
commit d91b3d4fb6
19 changed files with 152 additions and 114 deletions

View file

@ -231,7 +231,7 @@
--assets-item-border-color: var(--color-accent-primary); --assets-item-border-color: var(--color-accent-primary);
--assets-item-background-color-drag: transparent; --assets-item-background-color-drag: transparent;
--assets-item-border-color-drag: var(--color-accent-primary-muted); --assets-item-border-color-drag: var(--color-accent-primary-muted);
--assets-component-background-color: var(--app-white); // TODO: review this token --assets-component-background-color: var(--color-foreground-secondary);
--assets-component-background-color-disabled: var(--df-secondary;); --assets-component-background-color-disabled: var(--df-secondary;);
--assets-component-border-color: var(--color-background-tertiary); --assets-component-border-color: var(--color-background-tertiary);
--assets-component-border-selected: var(--color-accent-tertiary); --assets-component-border-selected: var(--color-accent-tertiary);

View file

@ -71,6 +71,8 @@
local (mf/use-state {:offset-y 0 local (mf/use-state {:offset-y 0
:offset-x 0 :offset-x 0
:levels nil}) :levels nil})
width (gobj/get props "width" "initial")
on-local-close on-local-close
(mf/use-callback (mf/use-callback
@ -204,6 +206,7 @@
(let [level (-> @local :levels peek)] (let [level (-> @local :levels peek)]
[:ul {:class (stl/css-case :min-width min-width? [:ul {:class (stl/css-case :min-width min-width?
:context-menu-items true) :context-menu-items true)
:style {:width width}
:role "menu" :role "menu"
:ref check-menu-offscreen} :ref check-menu-offscreen}
(when-let [parent-option (:parent-option level)] (when-let [parent-option (:parent-option level)]

View file

@ -377,12 +377,14 @@
"Calculates the style properties for the given coordinates and position" "Calculates the style properties for the given coordinates and position"
[{vh :height} position x y] [{vh :height} position x y]
(let [;; picker height in pixels (let [;; picker height in pixels
h 510 h 510
;; Checks for overflow outside the viewport height ;; Checks for overflow outside the viewport height
max-y (- vh h) max-y (- vh h)
rulers? (mf/deref refs/rulers?)
left-offset (if rulers? 40 18)
x-pos 325] x-pos 400]
(cond (cond
(or (nil? x) (nil? y)) {:left "auto" :right "16rem" :top "4rem"} (or (nil? x) (nil? y)) {:left "auto" :right "16rem" :top "4rem"}
(= position :left) (= position :left)
@ -391,8 +393,11 @@
:bottom "1rem"} :bottom "1rem"}
{:left (str (- x x-pos) "px") {:left (str (- x x-pos) "px")
:top (str (- y 70) "px")}) :top (str (- y 70) "px")})
:else {:left (str (+ x 80) "px") :else (if (> y max-y)
:top (str (- y 70) "px")}))) {:left (str (+ x left-offset) "px")
:bottom "1rem"}
{:left (str (+ x left-offset) "px")
:top (str (- y 70) "px")}))))
(mf/defc colorpicker-modal (mf/defc colorpicker-modal
{::mf/register modal/components {::mf/register modal/components
@ -401,7 +406,9 @@
disable-gradient disable-gradient
disable-opacity disable-opacity
disable-image disable-image
on-change on-close on-accept] :as props}] on-change
on-close
on-accept] :as props}]
(let [vport (mf/deref viewport) (let [vport (mf/deref viewport)
dirty? (mf/use-var false) dirty? (mf/use-var false)
last-change (mf/use-var nil) last-change (mf/use-var nil)

View file

@ -9,13 +9,15 @@
.workspace-header-left { .workspace-header-left {
display: flex; display: flex;
align-items: center; align-items: center;
padding: $s-8 $s-8 $s-4 $s-8; padding: $s-12 $s-12 $s-8 $s-12;
min-height: $s-52;
} }
.main-icon { .main-icon {
@include flexCenter; @include flexCenter;
width: $s-32; width: $s-32;
height: $s-32; height: $s-32;
min-height: $s-32;
margin-right: $s-4; margin-right: $s-4;
svg { svg {
min-height: $s-32; min-height: $s-32;
@ -27,6 +29,8 @@
.project-tree { .project-tree {
position: relative; position: relative;
flex-grow: 1; flex-grow: 1;
height: $s-32;
min-height: $s-32;
max-width: calc(100% - $s-64); max-width: calc(100% - $s-64);
} }

View file

@ -116,7 +116,7 @@
(when-not ^boolean mode-inspect? (when-not ^boolean mode-inspect?
[:& tab-element {:id :assets [:& tab-element {:id :assets
:title (tr "workspace.toolbar.assets")} :title (tr "workspace.toolbar.assets")}
[:& assets-toolbox]])]])]])) [:& assets-toolbox {:size (- size 58)}]])]])]]))
;; --- Right Sidebar (Component) ;; --- Right Sidebar (Component)

View file

@ -14,8 +14,9 @@ $width-settings-bar-max: $s-500;
grid-template-areas: grid-template-areas:
"header header" "header header"
"content resize"; "content resize";
grid-template-rows: $s-48 1fr; grid-template-rows: $s-52 1fr;
grid-template-columns: 1fr 0; grid-template-columns: 1fr 0;
gap: $s-8 0;
position: relative; position: relative;
grid-area: left-sidebar; grid-area: left-sidebar;
min-width: $width-settings-bar; min-width: $width-settings-bar;
@ -54,7 +55,7 @@ $width-settings-bar-max: $s-500;
} }
.tab-spacing { .tab-spacing {
margin-inline: $s-8; margin-inline: $s-12;
} }
.right-settings-bar { .right-settings-bar {

View file

@ -67,7 +67,7 @@
(mf/defc assets-toolbox (mf/defc assets-toolbox
{::mf/wrap [mf/memo] {::mf/wrap [mf/memo]
::mf/wrap-props false} ::mf/wrap-props false}
[] [{:keys [size]}]
(let [components-v2 (mf/use-ctx ctx/components-v2) (let [components-v2 (mf/use-ctx ctx/components-v2)
read-only? (mf/use-ctx ctx/workspace-read-only?) read-only? (mf/use-ctx ctx/workspace-read-only?)
filters* (mf/use-state filters* (mf/use-state
@ -178,7 +178,8 @@
:show menu-open? :show menu-open?
:fixed? true :fixed? true
:min-width? true :min-width? true
:top 152 :width size
:top 158
:left 18 :left 18
:options options :options options
:workspace? true}] :workspace? true}]

View file

@ -12,16 +12,19 @@
grid-auto-rows: max-content; grid-auto-rows: max-content;
// TODO: ugly hack :( Fix this! we shouldn't be hardcoding this height // TODO: ugly hack :( Fix this! we shouldn't be hardcoding this height
max-height: calc(100vh - $s-80); max-height: calc(100vh - $s-80);
scrollbar-gutter: stable;
overflow-y: auto;
padding-top: $s-8;
} }
.libraries-button { .libraries-button {
@include tabTitleTipography;
@extend .button-secondary; @extend .button-secondary;
@include tabTitleTipography;
gap: $s-2; gap: $s-2;
height: $s-32; height: $s-32;
width: 100%; width: 100%;
border-radius: $s-8;
margin-bottom: $s-4; margin-bottom: $s-4;
border-radius: $s-8;
.libraries-icon { .libraries-icon {
@include flexCenter; @include flexCenter;
width: $s-24; width: $s-24;
@ -124,7 +127,7 @@
} }
.assets-header { .assets-header {
padding: $s-8 $s-12 $s-12 $s-12; padding: 0 0 $s-24 $s-12;
} }
.search-wrapper { .search-wrapper {
@ -133,7 +136,7 @@
} }
.sort-button { .sort-button {
@extend .button-secondary; @extend .button-tertiary;
width: $s-32; width: $s-32;
border-radius: $br-8; border-radius: $br-8;
svg { svg {

View file

@ -386,17 +386,23 @@
(mf/use-fn (mf/use-fn
(mf/deps file-id) (mf/deps file-id)
(fn [event] (fn [event]
(st/emit! (dw/set-assets-section-open file-id :colors true) (let [bounding-rect (-> event
(ptk/event ::ev/event {::ev/name "add-asset-to-library" (dom/get-current-target)
:asset-type "color"})) (dom/get-bounding-rect))
;; FIXME: replace interop with dom helpers x-position (:right bounding-rect)
(modal/show! :colorpicker y-position (:top bounding-rect)]
{:x (.-clientX event)
:y (.-clientY event) (st/emit! (dw/set-assets-section-open file-id :colors true)
:on-accept add-color (ptk/event ::ev/event {::ev/name "add-asset-to-library"
:data {:color "#406280" :asset-type "color"}))
:opacity 1} ;; FIXME: replace interop with dom helpers
:position :right}))) (modal/show! :colorpicker
{:x x-position
:y y-position
:on-accept add-color
:data {:color "#406280"
:opacity 1}
:position :right}))))
create-group create-group
(mf/use-fn (mf/use-fn

View file

@ -74,13 +74,13 @@
overflow: hidden; overflow: hidden;
.default-name-only, .default-name-only,
.name { .name {
color: var(--assets-item-name-foreground-color-hover); color: var(--assets-item-name-foreground-color);
margin-right: $s-6; margin-right: $s-6;
@include textEllipsis; @include textEllipsis;
} }
.default-name { .default-name {
min-width: 0; min-width: 0;
color: var(--assets-item-name-foreground-color); color: var(--assets-item-name-foreground-color-rest);
} }
} }

View file

@ -144,7 +144,8 @@
(mf/use-fn (mf/use-fn
(mf/deps file-id section open?) (mf/deps file-id section open?)
(fn [_] (fn [_]
(st/emit! (dw/set-assets-section-open file-id section (not open?))))) (when (< 0 assets-count)
(st/emit! (dw/set-assets-section-open file-id section (not open?))))))
title title
(mf/html (mf/html
@ -157,13 +158,15 @@
[:span {:class (stl/css :num-assets)} [:span {:class (stl/css :num-assets)}
assets-count]])] assets-count]])]
[:div {:class (stl/css :asset-section)} [:div {:class (stl/css-case :asset-section true
:opened (and (< 0 assets-count)
open?))}
[:& title-bar [:& title-bar
{:collapsable true {:collapsable (< 0 assets-count)
:collapsed (not open?) :collapsed (not open?)
:all-clickable true :all-clickable true
:on-collapsed on-collapsed :on-collapsed on-collapsed
:class (stl/css :title-spacing) :class (stl/css-case :title-spacing open?)
:title title} :title title}
buttons] buttons]
(when ^boolean open? content)])) (when ^boolean open? content)]))

View file

@ -41,3 +41,7 @@
.title-spacing { .title-spacing {
margin-bottom: $s-4; margin-bottom: $s-4;
} }
.asset-section.opened {
margin-bottom: $s-12;
}

View file

@ -238,7 +238,7 @@
(when group-open? (when group-open?
[:* [:*
(let [components (get groups "" [])] (when-let [components (not-empty (get groups "" []))]
[:div {:class-name (stl/css-case :asset-grid listing-thumbs? [:div {:class-name (stl/css-case :asset-grid listing-thumbs?
:asset-enum (not listing-thumbs?) :asset-enum (not listing-thumbs?)
:drop-space (and :drop-space (and
@ -512,27 +512,26 @@
:assets-count (count components) :assets-count (count components)
:open? open?} :open? open?}
[:& cmm/asset-section-block {:role :title-button} [:& cmm/asset-section-block {:role :title-button}
[:* (when ^boolean open?
(when open? [:div {:class (stl/css :listing-options)}
[:div {:class (stl/css :listing-options)} [:& radio-buttons {:selected (if listing-thumbs? "grid" "list")
[:& radio-buttons {:selected (if listing-thumbs? "grid" "list") :on-change toggle-list-style
:on-change toggle-list-style :name "listing-style"}
:name "listing-style"} [:& radio-button {:icon i/view-as-list-refactor
[:& radio-button {:icon i/view-as-list-refactor :value "list"
:value "list" :id "opt-list"}]
:id "opt-list"}] [:& radio-button {:icon i/flex-grid-refactor
[:& radio-button {:icon i/flex-grid-refactor :value "grid"
:value "grid" :id "opt-grid"}]]])
:id "opt-grid"}]]])
(when (and components-v2 (not read-only?) local?) (when (and components-v2 (not read-only?) local?)
[:div {:on-click add-component [:div {:on-click add-component
:class (stl/css :add-component)} :class (stl/css :add-component)}
i/add-refactor i/add-refactor
[:& file-uploader {:accept cm/str-image-types [:& file-uploader {:accept cm/str-image-types
:multi true :multi true
:ref input-ref :ref input-ref
:on-selected on-file-selected}]])]] :on-selected on-file-selected}]])]
[:& cmm/asset-section-block {:role :content} [:& cmm/asset-section-block {:role :content}
(when ^boolean open? (when ^boolean open?

View file

@ -9,10 +9,10 @@
.drop-space { .drop-space {
height: $s-12; height: $s-12;
} }
.asset-grid { .asset-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax($s-96, 1fr)); grid-template-columns: repeat(auto-fill, minmax($s-96, 1fr));
grid-auto-rows: $s-112;
max-width: 100%; max-width: 100%;
gap: $s-4; gap: $s-4;
margin-inline: $s-8; margin-inline: $s-8;
@ -21,6 +21,7 @@
.grid-cell { .grid-cell {
@include flexCenter; @include flexCenter;
position: relative; position: relative;
aspect-ratio: 1 / 1;
padding: $s-8; padding: $s-8;
border-radius: $br-8; border-radius: $br-8;
background-color: var(--assets-component-background-color); background-color: var(--assets-component-background-color);
@ -63,7 +64,6 @@
} }
&:hover { &:hover {
background-color: var(--assets-item-background-color-hover);
.cell-name { .cell-name {
display: block; display: block;
} }
@ -74,6 +74,12 @@
} }
} }
.component-group {
display: grid;
grid-template-columns: 1fr;
gap: $s-4;
}
.thumbnail { .thumbnail {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -89,23 +95,22 @@
border: $s-2 solid var(--assets-item-border-color-drag); border: $s-2 solid var(--assets-item-border-color-drag);
} }
.asset-enum {
margin: 0 $s-12;
}
.enum-item { .enum-item {
position: relative; position: relative;
display: grid; display: grid;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
align-items: center; align-items: center;
column-gap: $s-8; column-gap: $s-8;
height: $s-36; height: $s-44;
margin-bottom: $s-4;
padding: $s-2; padding: $s-2;
border-radius: $br-8; border-radius: $br-8;
background-color: var(--assets-item-background-color); background-color: var(--assets-item-background-color);
cursor: pointer; cursor: pointer;
&:not(:last-child) {
margin-bottom: $s-4;
}
&:hover { &:hover {
background-color: var(--assets-item-background-color-hover); background-color: var(--assets-item-background-color-hover);
.item-name { .item-name {
@ -159,8 +164,8 @@
@include flexCenter; @include flexCenter;
flex-shrink: 0; flex-shrink: 0;
padding: $s-2; padding: $s-2;
height: $s-32; height: $s-36;
width: $s-32; width: $s-36;
border-radius: $br-6; border-radius: $br-6;
background-color: var(--assets-component-background-color); background-color: var(--assets-component-background-color);
} }

View file

@ -51,7 +51,8 @@
(mf/deps file-id open?) (mf/deps file-id open?)
(fn [] (fn []
(st/emit! (dw/set-assets-section-open file-id :library (not open?)))))] (st/emit! (dw/set-assets-section-open file-id :library (not open?)))))]
[:div {:class (stl/css :library-title)} [:div {:class (stl/css-case :library-title true
:open open?)}
[:& title-bar {:collapsable true [:& title-bar {:collapsable true
:collapsed (not open?) :collapsed (not open?)
:all-clickable true :all-clickable true

View file

@ -6,14 +6,10 @@
@import "refactor/common-refactor.scss"; @import "refactor/common-refactor.scss";
.tool-window { .tool-window {
padding-inline-start: $s-12; padding: 0 0 $s-24 $s-12;
overflow-y: auto;
display: grid; display: grid;
grid-auto-rows: max-content; grid-auto-rows: max-content;
scrollbar-gutter: stable; gap: $s-4;
&:last-child {
margin-block-end: $s-24;
}
height: 100%; height: 100%;
} }
@ -47,6 +43,9 @@
.library-content { .library-content {
width: 100%; width: 100%;
display: grid;
grid-auto-rows: max-content;
gap: $s-4;
} }
.asset-title { .asset-title {

View file

@ -87,8 +87,7 @@
} }
} }
.asset-enum { .asset-enum {
margin: 0 $s-12; padding-bottom: $s-4;
.enum-item { .enum-item {
position: relative; position: relative;
display: flex; display: flex;

View file

@ -264,7 +264,7 @@
font-size: $s-12; font-size: $s-12;
cursor: pointer; cursor: pointer;
width: 100%; width: 100%;
height: $s-36; height: $s-44;
border-radius: $br-8; border-radius: $br-8;
background-color: var(--assets-item-background-color); background-color: var(--assets-item-background-color);
color: var(--assets-item-name-foreground-color); color: var(--assets-item-name-foreground-color);
@ -278,8 +278,8 @@
img { img {
background-color: var(--assets-component-background-color); background-color: var(--assets-component-background-color);
border-radius: $br-8; border-radius: $br-8;
height: $s-32; height: $s-36;
width: $s-32; width: $s-36;
margin: $s-2 $s-8 $s-2 $s-2; margin: $s-2 $s-8 $s-2 $s-2;
} }

View file

@ -21,43 +21,6 @@
color: var(--assets-item-name-foreground-color-hover); color: var(--assets-item-name-foreground-color-hover);
} }
.typography-selection-wrapper {
display: grid;
grid-template-columns: $s-24 auto 1fr;
flex: 1;
height: 100%;
width: 100%;
padding: 0 $s-12;
&.is-selectable {
cursor: pointer;
}
.typography-sample {
@include flexCenter;
min-width: $s-24;
height: $s-32;
color: var(--assets-item-name-foreground-color-hover);
}
.typography-name,
.typography-font {
@include titleTipography;
@include textEllipsis;
display: flex;
align-items: center;
justify-content: flex-start;
margin-left: $s-6;
color: var(--assets-item-name-foreground-color-hover);
}
.typography-font {
display: flex;
align-items: center;
justify-content: flex-start;
min-width: 0;
color: var(--assets-item-name-foreground-color);
}
}
&.selected { &.selected {
border: $s-1 solid var(--assets-item-border-color); border: $s-1 solid var(--assets-item-border-color);
} }
@ -78,6 +41,7 @@
} }
} }
} }
&:hover { &:hover {
background-color: var(--assets-item-background-color-hover); background-color: var(--assets-item-background-color-hover);
.element-set-actions { .element-set-actions {
@ -86,6 +50,45 @@
} }
} }
.typography-selection-wrapper {
display: grid;
grid-template-columns: $s-24 auto 1fr;
flex: 1;
height: 100%;
width: 100%;
padding: 0 $s-12;
&.is-selectable {
cursor: pointer;
}
}
.typography-sample {
@include flexCenter;
min-width: $s-24;
height: $s-32;
color: var(--assets-item-name-foreground-color);
}
.typography-name,
.typography-font {
@include titleTipography;
@include textEllipsis;
display: flex;
align-items: center;
justify-content: flex-start;
margin-left: $s-6;
color: var(--assets-item-name-foreground-color);
}
.typography-font {
display: flex;
align-items: center;
justify-content: flex-start;
min-width: 0;
color: var(--assets-item-name-foreground-color-rest);
}
.font-name-wrapper { .font-name-wrapper {
@include titleTipography; @include titleTipography;
display: flex; display: flex;