mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
enhance: display date property value as today/yesterday/tomorrow
if possible
This commit is contained in:
@@ -2700,7 +2700,7 @@
|
||||
[:div.positioned-properties.block-below.flex.flex-row.gap-2.item-center.flex-wrap.text-sm.overflow-x-hidden
|
||||
(for [pid properties]
|
||||
(let [property (db/entity pid)]
|
||||
[:div.flex.flex-row.items-center.opacity-50.hover:opacity-100.transition-opacity.duration-300.ease-in.gap-1
|
||||
[:div.flex.flex-row.items-center.gap-1
|
||||
[:div.flex.flex-row.items-center
|
||||
(property-component/property-key-cp block property opts)
|
||||
[:div.select-none ":"]]
|
||||
|
||||
@@ -961,6 +961,10 @@ html.is-mac {
|
||||
.block-content.inline {
|
||||
@apply flex;
|
||||
}
|
||||
|
||||
.property-k {
|
||||
color: var(--ls-primary-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.block-tags {
|
||||
|
||||
@@ -257,7 +257,7 @@
|
||||
(reset! *show-new-property-config? false)))))))
|
||||
|
||||
(rum/defc property-key-title
|
||||
[block property class-schema?]
|
||||
[block property class-schema? property-position]
|
||||
(let [block-container (state/get-component :block/container)]
|
||||
(shui/trigger-as
|
||||
:a
|
||||
@@ -284,10 +284,12 @@
|
||||
(.focus input)))}
|
||||
:align "start"
|
||||
:as-dropdown? true})))}
|
||||
(block-container {:property? true} property))))
|
||||
(if (= :block-below property-position)
|
||||
(:block/title property)
|
||||
(block-container {:property? true} property)))))
|
||||
|
||||
(rum/defc property-key-cp < rum/static
|
||||
[block property {:keys [other-position? class-schema?]}]
|
||||
[block property {:keys [other-position? class-schema? property-position]}]
|
||||
(let [icon (:logseq.property/icon property)]
|
||||
[:div.property-key-inner.jtrigger-view
|
||||
;; icon picker
|
||||
@@ -323,7 +325,7 @@
|
||||
[:a.property-k.flex.select-none.jtrigger
|
||||
{:on-click #(route-handler/redirect-to-page! (:block/uuid property))}
|
||||
(:block/title property)]
|
||||
(property-key-title block property class-schema?))]))
|
||||
(property-key-title block property class-schema? property-position))]))
|
||||
|
||||
(rum/defcs property-input < rum/reactive
|
||||
(rum/local nil ::ref)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns frontend.components.property.value
|
||||
(:require [cljs-time.coerce :as tc]
|
||||
(:require [cljs-time.core :as t]
|
||||
[cljs-time.coerce :as tc]
|
||||
[clojure.string :as string]
|
||||
[datascript.impl.entity :as de]
|
||||
[dommy.core :as d]
|
||||
@@ -329,6 +330,40 @@
|
||||
(when datetime?
|
||||
(repeat-setting block property value))]))
|
||||
|
||||
(rum/defc datetime-value
|
||||
[value]
|
||||
(when-let [date (js/Date. value)]
|
||||
[:div.flex.flex-row.gap-1.items-center
|
||||
(when-let [page-cp (state/get-component :block/page-cp)]
|
||||
(let [date' (date/js-date->goog-date date)
|
||||
page-title (date/journal-name date')
|
||||
today (t/today)
|
||||
label (cond
|
||||
(and (or (t/after? date' today)
|
||||
(t/equal? date' today))
|
||||
(t/before? date' (t/plus today (t/days 1))))
|
||||
"Today"
|
||||
(and (or (t/equal? date' (t/plus today (t/days 1)))
|
||||
(t/after? date' (t/plus today (t/days 1))))
|
||||
(t/before? date' (t/plus today (t/days 2))))
|
||||
"Tomorrow"
|
||||
(and (or (t/equal? date' (t/minus today (t/days 1)))
|
||||
(t/after? date' (t/minus today (t/days 1))))
|
||||
(t/before? date' today))
|
||||
"Yesterday"
|
||||
:else
|
||||
nil)]
|
||||
(rum/with-key
|
||||
(page-cp {:disable-preview? true
|
||||
:show-non-exists-page? true
|
||||
:label label}
|
||||
{:block/name page-title})
|
||||
page-title)))
|
||||
[:span
|
||||
(str (util/zero-pad (.getHours date))
|
||||
":"
|
||||
(util/zero-pad (.getMinutes date)))]]))
|
||||
|
||||
(rum/defc date-picker
|
||||
[value {:keys [block property datetime? on-change on-delete del-btn? editing? multiple-values? other-position?]}]
|
||||
(let [*trigger-ref (rum/use-ref nil)
|
||||
@@ -377,19 +412,7 @@
|
||||
(:db/id value)))
|
||||
|
||||
(number? value)
|
||||
(when-let [date (js/Date. value)]
|
||||
[:div.flex.flex-row.gap-1.items-center
|
||||
(when-let [page-cp (state/get-component :block/page-cp)]
|
||||
(let [page-title (date/journal-name (date/js-date->goog-date date))]
|
||||
(rum/with-key
|
||||
(page-cp {:disable-preview? true
|
||||
:show-non-exists-page? true}
|
||||
{:block/name page-title})
|
||||
page-title)))
|
||||
[:span.opacity-50
|
||||
(str (util/zero-pad (.getHours date))
|
||||
":"
|
||||
(util/zero-pad (.getMinutes date)))]])
|
||||
(datetime-value value)
|
||||
|
||||
:else
|
||||
(property-empty-btn-value nil))))))
|
||||
|
||||
Reference in New Issue
Block a user