Skip to content

Commit

Permalink
improve(ux): WIP support place fold arrow on the right of block conta…
Browse files Browse the repository at this point in the history
…iner
  • Loading branch information
xyhp915 committed Nov 24, 2022
1 parent 66e7a80 commit b3a6ed2
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 21 deletions.
34 changes: 18 additions & 16 deletions src/main/frontend/components/block.cljs
Expand Up @@ -1707,7 +1707,7 @@
(every? #(= % ["Horizontal_Rule"]) body)))

(rum/defcs block-control < rum/reactive
[state config block uuid block-id collapsed? *control-show? edit?]
[state config block uuid block-id collapsed? *control-show? edit? has-child?]
(let [doc-mode? (state/sub :document/mode?)
control-show? (util/react *control-show?)
ref? (:ref? config)
Expand All @@ -1717,20 +1717,22 @@
:margin-top 0
:float "left"}}

[:a.block-control
{:id (str "control-" uuid)
:on-click (fn [event]
(util/stop event)
(state/clear-edit!)
(if ref?
(state/toggle-collapsed-block! uuid)
(if collapsed?
(editor-handler/expand-block! uuid)
(editor-handler/collapse-block! uuid))))}
[:span {:class (if (and control-show?
(or collapsed?
(editor-handler/collapsable? uuid {:semantic? true}))) "control-show cursor-pointer" "control-hide")}
(ui/rotating-arrow collapsed?)]]
(when has-child?
[:a.block-control
{:id (str "control-" uuid)
:on-click (fn [event]
(util/stop event)
(state/clear-edit!)
(if ref?
(state/toggle-collapsed-block! uuid)
(if collapsed?
(editor-handler/expand-block! uuid)
(editor-handler/collapse-block! uuid))))}
[:span {:class (if (and control-show?
(or collapsed?
(editor-handler/collapsable? uuid {:semantic? true}))) "control-show cursor-pointer" "control-hide")}
(ui/rotating-arrow collapsed?)]])

(let [bullet [:a {:on-click (fn [event]
(bullet-on-click event block uuid))}
[:span.bullet-container.cursor
Expand Down Expand Up @@ -2761,7 +2763,7 @@
:on-mouse-leave (fn [e]
(block-mouse-leave e *control-show? block-id doc-mode?))}
(when (not slide?)
(block-control config block uuid block-id collapsed? *control-show? edit?))
(block-control config block uuid block-id collapsed? *control-show? edit? has-child?))

(when @*show-left-menu?
(block-left-menu config block))
Expand Down
8 changes: 7 additions & 1 deletion src/main/frontend/components/block.css
@@ -1,4 +1,6 @@
.block-content-wrapper {
@apply border border-red-400;

/* 38px is the width of block-control */
width: calc(100% - 22px);

Expand All @@ -9,6 +11,8 @@
}

.block-content {
@apply border border-blue-400;

min-height: 24px;
max-width: 100%;
overflow: initial;
Expand Down Expand Up @@ -323,6 +327,8 @@
}

.ls-block {
@apply border border-dashed border-green-600;

position: relative;
min-height: 24px;
padding: 2px 0;
Expand Down Expand Up @@ -648,4 +654,4 @@ html.is-mac {
cursor: pointer;
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/frontend/components/sidebar.cljs
Expand Up @@ -732,6 +732,7 @@
edit? (:editor/editing? @state/state)
default-home (get-default-home-if-valid)
logged? (user-handler/logged-in?)
fold-arrow-on-right? (state/sub :mobile/fold-arrow-on-right-enabled?)
show-action-bar? (state/sub :mobile/show-action-bar?)
show-recording-bar? (state/sub :mobile/show-recording-bar?)
preferred-language (state/sub [:preferred-language])]
Expand All @@ -757,6 +758,7 @@
{:class (util/classnames [{:ls-left-sidebar-open left-sidebar-open?
:ls-right-sidebar-open sidebar-open?
:ls-wide-mode wide-mode?
:ls-fold-arrow-on-right (and (util/sm-breakpoint?) fold-arrow-on-right?)
:ls-hl-colored ls-block-hl-colored?}])}

[:button#skip-to-main
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/components/sidebar.css
Expand Up @@ -361,7 +361,7 @@
}

&.is-touching {
width: 100%;
width: 100% !important;
transition: none;

.left-sidebar-inner {
Expand All @@ -375,7 +375,7 @@
}

&.is-open {
width: 100%;
width: 100% !important;

.left-sidebar-inner {
transform: translate3d(0, 0, 0);
Expand Down
34 changes: 32 additions & 2 deletions src/main/frontend/components/theme.css
@@ -1,7 +1,6 @@
:root {
scrollbar-width: thin;
scrollbar-color: var(--ls-scrollbar-foreground-color)
var(--ls-scrollbar-background-color);
scrollbar-color: var(--ls-scrollbar-foreground-color) var(--ls-scrollbar-background-color);

--ls-z-index-level-0: 0;
--ls-z-index-level-1: 9;
Expand Down Expand Up @@ -114,3 +113,34 @@ html.is-resizing-buf {
}
}
}

main.ls-fold-arrow-on-right {
#main-content-container {
padding: 0 15px;


.page-blocks-inner {
margin-left: 0 !important;
}
}

.cp__sidebar-left-layout {
width: 16px;
}

.ls-block {
.block-control {
@apply absolute -right-2 top-1 bottom-1 bg-yellow-300;

.rotating-arrow.collapsed svg {
transform: rotate(180deg);
}
}

&[haschild="true"] {
.control-hide {
display: block !important;
}
}
}
}
1 change: 1 addition & 0 deletions src/main/frontend/state.cljs
Expand Up @@ -166,6 +166,7 @@
:assets/alias-dirs (or (storage/get :assets/alias-dirs) [])

;; mobile
:mobile/fold-arrow-on-right-enabled? true
:mobile/container-urls nil
:mobile/show-action-bar? false
:mobile/actioned-block nil
Expand Down

0 comments on commit b3a6ed2

Please sign in to comment.