Skip to content

Commit

Permalink
refactor: rename "page emoji" to "page icons" (logseq#3081)
Browse files Browse the repository at this point in the history
Co-authored-by: Tienson Qin <[email protected]>
  • Loading branch information
devonzuegel and tiensonqin committed Nov 9, 2021
1 parent fbbc1a1 commit eb414bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions resources/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -850,12 +850,12 @@ h1.title {
font-weight: 600;
}

.title .page-emoji {
.title .page-icon {
margin-right: 12px;
}

.left-sidebar-inner .recent .page-emoji,
.left-sidebar-inner .favorites .page-emoji {
.left-sidebar-inner .recent .page-icon,
.left-sidebar-inner .favorites .page-icon {
margin-right: 8px;
width: 1.1em;
text-align: center;
Expand Down
12 changes: 6 additions & 6 deletions src/main/frontend/components/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
{:will-update (fn [state]
(assoc state ::title-value (atom (nth (:rum/args state) 2))))}
(rum/local false ::edit?)
[state page-name emoji title format fmt-journal?]
[state page-name icon title format fmt-journal?]
(when title
(let [*title-value (get state ::title-value)
*edit? (get state ::edit?)
Expand Down Expand Up @@ -253,8 +253,8 @@
(when (and (not hls-file?) (not fmt-journal?))
(reset! *edit? true))))}
[:h1.title {:style {:margin-left -2}}
(when (not= emoji "") [:span.page-emoji emoji])
title-element]]))))
(when (not= icon "") [:span.page-icon icon])
title]]))))

;; A page is just a logical block
(rum/defcs page < rum/reactive
Expand Down Expand Up @@ -284,11 +284,11 @@
(let [m (format-block/page-name->map path-page-name true)]
(db/transact! repo [m])))
(db/pull [:block/name page-name])))
{:keys [title emoji] :as properties} (:block/properties page)
{:keys [title icon] :as properties} (:block/properties page)
page-name (:block/name page)
page-original-name (:block/original-name page)
title (or title page-original-name page-name)
emoji (or emoji "")
icon (or icon "")
today? (and
journal?
(= page-name (string/lower-case (date/journal-name))))
Expand All @@ -308,7 +308,7 @@
(not block?))
[:div.flex.flex-row.space-between
[:div.flex-1.flex-row
(page-title page-name emoji title format fmt-journal?)]
(page-title page-name icon title format fmt-journal?)]
(when (not config/publishing?)
[:div.flex.flex-row
(when plugin-handler/lsp-enabled?
Expand Down
22 changes: 11 additions & 11 deletions src/main/frontend/components/sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
(< delta 14)))

(rum/defc page-name
[name emoji]
[name icon]
(let [original-name (db-model/get-page-original-name name)]
[:a {:on-click (fn [e]
(let [name (util/safe-lower-case name)]
Expand All @@ -94,20 +94,20 @@
:page
{:page page-entity}))
(route-handler/redirect-to-page! name))))}
[:span.page-emoji emoji]
[:span.page-icon icon]
(pdf-assets/fix-local-asset-filename original-name)]))

(defn get-page-emoji [page-entity]
(let [default-emoji ""
from-properties (get-in (into {} page-entity) [:block/properties :emoji])]
(defn get-page-icon [page-entity]
(let [default-icon ""
from-properties (get-in (into {} page-entity) [:block/properties :icon])]
(or
(when (not= from-properties "") from-properties)
default-emoji))) ;; Fall back to default if emoji is undefined or empty
default-icon))) ;; Fall back to default if icon is undefined or empty

(rum/defcs favorite-item <
(rum/local nil ::up?)
(rum/local nil ::dragging-over)
[state t name emoji]
[state t name icon]
(let [up? (get state ::up?)
dragging-over (get state ::dragging-over)
target (state/sub :favorites/dragging)]
Expand All @@ -131,7 +131,7 @@
:up? (move-up? e)})
(reset! up? nil)
(reset! dragging-over nil))}
(page-name name emoji)]))
(page-name name icon)]))

(rum/defc favorites < rum/reactive
[t]
Expand All @@ -155,8 +155,8 @@
(for [name favorites]
(when-not (string/blank? name)
(when-let [entity (db/entity [:block/name (util/safe-lower-case name)])]
(let [emoji (get-page-emoji entity)]
(favorite-item t name emoji)))))]))))
(let [icon (get-page-icon entity)]
(favorite-item t name icon)))))]))))

(rum/defc recent-pages
< rum/reactive db-mixins/query
Expand All @@ -176,7 +176,7 @@
(for [name pages]
(when-let [entity (db/entity [:block/name (util/safe-lower-case name)])]
[:li.recent-item {:key name}
(page-name name (get-page-emoji entity))]))]))) ;; TODO: pass in the real emoji
(page-name name (get-page-icon entity))]))])))

(rum/defcs flashcards < db-mixins/query rum/reactive
{:did-mount (fn [state]
Expand Down

0 comments on commit eb414bb

Please sign in to comment.