Add page transition

pull/645/head
Tienson Qin 2020-05-01 08:36:05 +08:00
parent a1d0a4c483
commit b1f4c6b96f
2 changed files with 23 additions and 5 deletions

View File

@ -215,7 +215,7 @@
:options {:href (str "/file/" (util/url-encode config/config-file))}} :options {:href (str "/file/" (util/url-encode config/config-file))}}
{:title "Sign out" {:title "Sign out"
:options {:on-click handler/sign-out!}}])]]] :options {:on-click handler/sign-out!}}])]]]
[:main.flex-1.relative.z-0.overflow-y-auto.py-6.focus:outline-none [:main.flex-1.relative.z-0.overflow-y-scroll.py-6.focus:outline-none
{:tabIndex "0"} {:tabIndex "0"}
[:div.flex.justify-center [:div.flex.justify-center
[:div.flex-1.m-6 {:style {:position "relative" [:div.flex-1.m-6 {:style {:position "relative"

View File

@ -1,13 +1,31 @@
(ns frontend.page (ns frontend.page
(:require [rum.core :as rum] (:require [rum.core :as rum]
[frontend.state :as state] [frontend.state :as state]
[frontend.components.sidebar :as sidebar])) [frontend.components.sidebar :as sidebar]
[frontend.ui :as ui]))
(rum/defc route-view
[view route-match]
(view route-match))
(rum/defc current-page < rum/reactive (rum/defc current-page < rum/reactive
[] []
(let [route-match (state/sub :route-match)] (let [route-match (state/sub :route-match)]
(if route-match (if route-match
(when-let [view (:view (:data route-match))] (let [route-name (get-in route-match [:data :name])
(sidebar/sidebar route-match no-animate? (contains? #{:repos :repo-add :file}
(view route-match))) route-name)]
(when-let [view (:view (:data route-match))]
(sidebar/sidebar
route-match
(if no-animate?
(route-view view route-match)
(ui/transition-group
{:class-name "router-wrapper"}
(ui/css-transition
{:class-names "pageChange"
:key route-name
:timeout {:enter 300
:exit 200}}
(route-view view route-match)))))))
[:div "404 Page"]))) [:div "404 Page"])))