Fixes the sidebar's jank
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
|
:class (fnil hh/add-class "") "space-y-1.5 max-h-0 transition transition-all overflow-hidden")
|
||||||
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
|
true (assoc ":class" (format "selected == '%s' ? 'py-0.5' : 'py-0'" (:selector params))
|
||||||
:x-ref "submenu"
|
:x-ref "submenu"
|
||||||
|
:style (cond-> {} (:active? params) (assoc "max-height" "400px"))
|
||||||
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
|
":style" (format "selected == '%s' ? 'max-height: ' + $refs.submenu.scrollHeight + 'px' : ''" (:selector params))))
|
||||||
(for [c children]
|
(for [c children]
|
||||||
[:li
|
[:li
|
||||||
@@ -51,6 +52,8 @@
|
|||||||
(hh/add-class (or c "") " flex items-center p-2 pl-11 w-full text-base font-normal rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")))])])
|
(hh/add-class (or c "") " flex items-center p-2 pl-11 w-full text-base font-normal rounded-lg transition duration-75 group hover:bg-gray-100 dark:text-white dark:hover:bg-gray-700")))])])
|
||||||
|
|
||||||
(defn left-aside- [{:keys [nav page-specific]} & children]
|
(defn left-aside- [{:keys [nav page-specific]} & children]
|
||||||
|
|
||||||
|
(Thread/sleep 500)
|
||||||
[:aside {:id "left-nav",
|
[:aside {:id "left-nav",
|
||||||
:class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform",
|
:class "fixed top-0 left-0 pt-16 z-20 w-64 h-screen transition-transform",
|
||||||
"x-transition:enter" "transition duration-500"
|
"x-transition:enter" "transition duration-500"
|
||||||
@@ -67,9 +70,9 @@
|
|||||||
[:template {:x-teleport "body"}
|
[:template {:x-teleport "body"}
|
||||||
|
|
||||||
[:div.fixed.inset-0.lg:hidden {:x-show "leftNavShow" :x-transition:enter "transition duration-500" :x-transition:enter-start "opacity-0" :x-transition:enter-end "opacity-100"
|
[:div.fixed.inset-0.lg:hidden {:x-show "leftNavShow" :x-transition:enter "transition duration-500" :x-transition:enter-start "opacity-0" :x-transition:enter-end "opacity-100"
|
||||||
:x-transition:leave "transition duration-500" :x-transition:leave-start "opacity-100" :x-transition:leave-end "opacity-0"
|
:x-transition:leave "transition duration-500" :x-transition:leave-start "opacity-100" :x-transition:leave-end "opacity-0"
|
||||||
"@click.capture.prevent" "leftNavShow=false"}
|
"@click.capture.prevent" "leftNavShow=false"}
|
||||||
[:div.fixed.inset-0.bg-gray-800.z-10.opacity-70 ]]]
|
[:div.fixed.inset-0.bg-gray-800.z-10.opacity-70]]]
|
||||||
|
|
||||||
[:div {:class "overflow-y-auto py-5 px-3 h-full bg-gray-50 border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
|
[:div {:class "overflow-y-auto py-5 px-3 h-full bg-gray-50 border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
|
||||||
nav
|
nav
|
||||||
@@ -80,158 +83,163 @@
|
|||||||
page-specific])]])
|
page-specific])]])
|
||||||
|
|
||||||
(defn main-aside-nav- [request]
|
(defn main-aside-nav- [request]
|
||||||
[:ul {:class "space-y-1"
|
(let [selected (cond
|
||||||
:x-data (hx/json {:selected
|
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page} (:matched-route request))
|
||||||
(cond
|
"invoices"
|
||||||
(#{::invoice-route/all-page ::invoice-route/unpaid-page ::invoice-route/voided-page ::invoice-route/paid-page} (:matched-route request))
|
|
||||||
"invoices"
|
|
||||||
|
|
||||||
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
|
(#{:pos-sales :pos-expected-deposits :pos-tenders :pos-refunds :pos-cash-drawer-shifts} (:matched-route request))
|
||||||
"sales"
|
"sales"
|
||||||
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page } (:matched-route request))
|
(#{::payment-routes/all-page ::payment-routes/pending-page ::payment-routes/cleared-page ::payment-routes/voided-page } (:matched-route request))
|
||||||
"payments"
|
"payments"
|
||||||
:else
|
:else
|
||||||
nil)})}
|
nil)]
|
||||||
|
[:ul {:class "space-y-1"
|
||||||
|
:x-data (hx/json {:selected selected})}
|
||||||
|
|
||||||
[:li
|
[:li
|
||||||
(menu-button- {:icon svg/pie
|
(menu-button- {:icon svg/pie
|
||||||
:href "/"}
|
:href "/"}
|
||||||
"Dashboard")]
|
"Dashboard")]
|
||||||
|
|
||||||
(menu-button- {"@click.prevent" "if (selected == 'invoices') {selected = null } else { selected = 'invoices'} "
|
(menu-button- {"@click.prevent" "if (selected == 'invoices') {selected = null } else { selected = 'invoices'} "
|
||||||
:icon svg/accounting-invoice-mail}
|
:icon svg/accounting-invoice-mail}
|
||||||
"Invoices")
|
"Invoices")
|
||||||
(sub-menu-
|
(sub-menu-
|
||||||
{:selector "invoices"}
|
{:selector "invoices"
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
:active? (= "invoices" selected)}
|
||||||
::invoice-route/all-page)
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
{:date-range "month"})
|
::invoice-route/all-page)
|
||||||
:active? (= ::invoice-route/all-page (:matched-route request))
|
{:date-range "month"})
|
||||||
:hx-boost true}
|
:active? (= ::invoice-route/all-page (:matched-route request))
|
||||||
|
:hx-boost "true"}
|
||||||
|
|
||||||
"All")
|
"All")
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
::invoice-route/paid-page)
|
::invoice-route/paid-page)
|
||||||
{:date-range "month"})
|
{:date-range "month"})
|
||||||
:active? (= ::invoice-route/paid-page (:matched-route request))
|
:active? (= ::invoice-route/paid-page (:matched-route request))
|
||||||
:hx-boost true}
|
:hx-boost "true"}
|
||||||
"Paid")
|
"Paid")
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
::invoice-route/unpaid-page)
|
::invoice-route/unpaid-page)
|
||||||
{:date-range "month"})
|
{:date-range "month"})
|
||||||
:active? (= ::invoice-route/unpaid-page (:matched-route request))
|
:active? (= ::invoice-route/unpaid-page (:matched-route request))
|
||||||
:hx-boost true}
|
:hx-boost "true"}
|
||||||
"Unpaid")
|
"Unpaid")
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
::invoice-route/voided-page)
|
::invoice-route/voided-page)
|
||||||
{:date-range "month"})
|
{:date-range "month"})
|
||||||
:active? (= ::invoice-route/voided-page (:matched-route request))
|
:active? (= ::invoice-route/voided-page (:matched-route request))
|
||||||
:hx-boost true}
|
:hx-boost "true"}
|
||||||
"Voided"))
|
"Voided"))
|
||||||
|
|
||||||
(menu-button- {:icon svg/receipt-register-1
|
(menu-button- {:icon svg/receipt-register-1
|
||||||
|
|
||||||
"@click.prevent" "if (selected == 'sales') {selected = null } else { selected = 'sales'} " }
|
"@click.prevent" "if (selected == 'sales') {selected = null } else { selected = 'sales'} "}
|
||||||
"Sales")
|
"Sales")
|
||||||
(sub-menu- {:selector "sales"}
|
(sub-menu- {:selector "sales"
|
||||||
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
:active? (= "sales" selected)}
|
||||||
:pos-sales)
|
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
"?date-range=week")
|
:pos-sales)
|
||||||
:active? (= :pos-sales (:matched-route request))
|
"?date-range=week")
|
||||||
:hx-boost true}
|
:active? (= :pos-sales (:matched-route request))
|
||||||
"Sales")
|
:hx-boost "true"}
|
||||||
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
"Sales")
|
||||||
:pos-expected-deposits)
|
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
"?date-range=week")
|
:pos-expected-deposits)
|
||||||
:active? (= :pos-expected-deposits (:matched-route request))
|
"?date-range=week")
|
||||||
:hx-boost true}
|
:active? (= :pos-expected-deposits (:matched-route request))
|
||||||
"Expected Deposits")
|
:hx-boost "true"}
|
||||||
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
"Expected Deposits")
|
||||||
:pos-tenders)
|
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
"?date-range=week")
|
:pos-tenders)
|
||||||
:active? (= :pos-tenders (:matched-route request))
|
"?date-range=week")
|
||||||
:hx-boost true}
|
:active? (= :pos-tenders (:matched-route request))
|
||||||
"Tenders")
|
:hx-boost "true"}
|
||||||
|
"Tenders")
|
||||||
|
|
||||||
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
:pos-refunds)
|
:pos-refunds)
|
||||||
"?date-range=week")
|
"?date-range=week")
|
||||||
:active? (= :pos-refunds (:matched-route request))
|
:active? (= :pos-refunds (:matched-route request))
|
||||||
:hx-boost true}
|
:hx-boost "true"}
|
||||||
|
|
||||||
"Refunds")
|
"Refunds")
|
||||||
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
:pos-cash-drawer-shifts)
|
:pos-cash-drawer-shifts)
|
||||||
"?date-range=week")
|
"?date-range=week")
|
||||||
:active? (= :cash-drawer-shifts (:matched-route request))
|
:active? (= :cash-drawer-shifts (:matched-route request))
|
||||||
:hx-boost true}
|
:hx-boost "true"}
|
||||||
"Cash drawer shifts"))
|
"Cash drawer shifts"))
|
||||||
;; TODO make specific routes for categories
|
;; TODO make specific routes for categories
|
||||||
;; TODO auto-apen sub menus
|
;; TODO auto-apen sub menus
|
||||||
|
|
||||||
|
(menu-button- {"@click.prevent" "if (selected == 'payments') {selected = null } else { selected = 'payments'} "
|
||||||
|
:icon svg/payments}
|
||||||
|
"Payments")
|
||||||
|
(sub-menu- {:selector "payments"
|
||||||
|
:active? (= "payments" selected)}
|
||||||
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
|
::payment-routes/all-page)
|
||||||
|
{:date-range "month"})
|
||||||
|
:active? (= ::payment-routes/all-page (:matched-route request))
|
||||||
|
:hx-boost "true"}
|
||||||
|
"All")
|
||||||
|
|
||||||
(menu-button- {"@click.prevent" "if (selected == 'payments') {selected = null } else { selected = 'payments'} "
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
:icon svg/payments}
|
::payment-routes/pending-page)
|
||||||
"Payments")
|
{:date-range "month"})
|
||||||
(sub-menu- {:selector "payments"}
|
:active? (= ::payment-routes/pending-page (:matched-route request))
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
:hx-boost "true"}
|
||||||
::payment-routes/all-page)
|
"Pending")
|
||||||
{:date-range "month"})
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
:active? (= ::payment-routes/all-page (:matched-route request))
|
::payment-routes/cleared-page)
|
||||||
:hx-boost true}
|
{:date-range "month"})
|
||||||
"All")
|
:active? (= ::payment-routes/cleared-page (:matched-route request))
|
||||||
|
:hx-boost "true"}
|
||||||
|
"Cleared")
|
||||||
|
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
||||||
|
::payment-routes/voided-page)
|
||||||
|
{:date-range "month"})
|
||||||
|
:active? (= ::payment-routes/voided-page (:matched-route request))
|
||||||
|
:hx-boost "true"}
|
||||||
|
"Voided"))
|
||||||
|
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
[:li {:x-data (hx/json {:open false})}
|
||||||
::payment-routes/pending-page)
|
(menu-button- {"@click.prevent" "if (selected == 'transactions') {selected = null } else { selected = 'transactions'} "
|
||||||
{ :date-range "month"})
|
:icon svg/bank}
|
||||||
:active? (= ::payment-routes/pending-page (:matched-route request))
|
"Transactions")
|
||||||
:hx-boost true}
|
|
||||||
"Pending")
|
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
|
||||||
::payment-routes/cleared-page)
|
|
||||||
{ :date-range "month"})
|
|
||||||
:active? (= ::payment-routes/cleared-page (:matched-route request))
|
|
||||||
:hx-boost true}
|
|
||||||
"Cleared")
|
|
||||||
(menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes
|
|
||||||
::payment-routes/voided-page)
|
|
||||||
{ :date-range "month" })
|
|
||||||
:active? (= ::payment-routes/voided-page (:matched-route request))
|
|
||||||
:hx-boost true}
|
|
||||||
"Voided"))
|
|
||||||
|
|
||||||
[:li {:x-data (hx/json {:open false})}
|
(sub-menu- {:selector "transactions"
|
||||||
(menu-button- {"@click.prevent" "if (selected == 'transactions') {selected = null } else { selected = 'transactions'} "
|
:active? (= "transactions" selected)}
|
||||||
:icon svg/bank}
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
"Transactions")
|
:transactions)} "All")
|
||||||
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
|
:unapproved-transactions)} "Unapproved")
|
||||||
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
|
:requires-feedback-transactions)} "Client Review")
|
||||||
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
|
:approved-transactions)} "Approved")
|
||||||
|
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
|
||||||
|
:transaction-insights)} "Insights"))]
|
||||||
|
|
||||||
(sub-menu- {:selector "transactions"}
|
(menu-button- {"@click.prevent" "if (selected == 'ledger') {selected = null } else { selected = 'ledger'} "
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
:icon svg/receipt}
|
||||||
:transactions)} "All")
|
"Ledger")
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
(sub-menu- {:selector "ledger"
|
||||||
:unapproved-transactions)} "Unapproved")
|
:active? (= "ledger" selected)}
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
:requires-feedback-transactions)} "Client Review")
|
:ledger)} "Register")
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
:approved-transactions)} "Approved")
|
:profit-and-loss)} "Profit & Loss")
|
||||||
(menu-button- {:href (bidi/path-for ssr-routes/only-routes
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
:transaction-insights)} "Insights"))]
|
:profit-and-loss-detail)} "Profit & Loss Detail")
|
||||||
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
(menu-button- {"@click.prevent" "if (selected == 'ledger') {selected = null } else { selected = 'ledger'} "
|
:cash-flows)} "Cash Flows")
|
||||||
:icon svg/receipt}
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
"Ledger")
|
:balance-sheet)} "Balance Sheet")
|
||||||
(sub-menu- {:selector "ledger"}
|
(menu-button- {:href (bidi/path-for client-routes/routes
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
:external-import-ledger)} "External Ledger Import"))]))
|
||||||
:ledger)} "Register")
|
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
|
||||||
:profit-and-loss)} "Profit & Loss")
|
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
|
||||||
:profit-and-loss-detail)} "Profit & Loss Detail")
|
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
|
||||||
:cash-flows)} "Cash Flows")
|
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
|
||||||
:balance-sheet)} "Balance Sheet")
|
|
||||||
(menu-button- {:href (bidi/path-for client-routes/routes
|
|
||||||
:external-import-ledger)} "External Ledger Import"))])
|
|
||||||
|
|
||||||
|
|
||||||
(defn company-aside-nav- [_]
|
(defn company-aside-nav- [_]
|
||||||
|
|||||||
@@ -84,10 +84,9 @@
|
|||||||
matching-count]))
|
matching-count]))
|
||||||
|
|
||||||
(def grid-page
|
(def grid-page
|
||||||
{}
|
(helper/build
|
||||||
#_(helper/build
|
|
||||||
{:id "cash-drawer-shift-table"
|
{:id "cash-drawer-shift-table"
|
||||||
:nav (com/main-aside-nav)
|
:nav com/main-aside-nav
|
||||||
:page-specific-nav filters
|
:page-specific-nav filters
|
||||||
:fetch-page fetch-page
|
:fetch-page fetch-page
|
||||||
:oob-render
|
:oob-render
|
||||||
|
|||||||
Reference in New Issue
Block a user