|
1 | 1 | (ns nextjournal.clerk.render
|
2 |
| - (:require ["framer-motion" :refer [m LazyMotion domAnimation]] |
| 2 | + (:require ["framer-motion" :refer [motion]] |
3 | 3 | ["react" :as react]
|
4 | 4 | ["react-dom/client" :as react-client]
|
5 | 5 | ["vh-sticky-table-header" :as sticky-table-header]
|
|
40 | 40 | [:button.text-slate-400.hover:text-slate-600.dark:hover:text-white.cursor-pointer
|
41 | 41 | {:on-click #(swap! !dark-mode? not)}
|
42 | 42 | (if @!dark-mode?
|
43 |
| - [:> (.-svg m) |
| 43 | + [:> (.-svg motion) |
44 | 44 | {:xmlns "http://www.w3.org/2000/svg"
|
45 | 45 | :class "w-5 h-5 md:w-4 md:h-4"
|
46 | 46 | :viewBox "0 0 50 50"
|
47 | 47 | :key "moon"}
|
48 |
| - [:> (.-path m) |
| 48 | + [:> (.-path motion) |
49 | 49 | {:d "M 43.81 29.354 C 43.688 28.958 43.413 28.626 43.046 28.432 C 42.679 28.238 42.251 28.198 41.854 28.321 C 36.161 29.886 30.067 28.272 25.894 24.096 C 21.722 19.92 20.113 13.824 21.683 8.133 C 21.848 7.582 21.697 6.985 21.29 6.578 C 20.884 6.172 20.287 6.022 19.736 6.187 C 10.659 8.728 4.691 17.389 5.55 26.776 C 6.408 36.163 13.847 43.598 23.235 44.451 C 32.622 45.304 41.28 39.332 43.816 30.253 C 43.902 29.96 43.9 29.647 43.81 29.354 Z"
|
50 | 50 | :fill "currentColor"
|
51 | 51 | :initial "initial"
|
52 | 52 | :animate "animate"
|
53 | 53 | :variants {:initial {:scale 0.6 :rotate 90}
|
54 | 54 | :animate {:scale 1 :rotate 0 :transition spring}}}]]
|
55 |
| - [:> (.-svg m) |
| 55 | + [:> (.-svg motion) |
56 | 56 | {:key "sun"
|
57 | 57 | :class "w-5 h-5 md:w-4 md:h-4"
|
58 | 58 | :viewBox "0 0 24 24"
|
59 | 59 | :fill "none"
|
60 | 60 | :xmlns "http://www.w3.org/2000/svg"}
|
61 |
| - [:> (.-circle m) |
| 61 | + [:> (.-circle motion) |
62 | 62 | {:cx "11.9998"
|
63 | 63 | :cy "11.9998"
|
64 | 64 | :r "5.75375"
|
|
67 | 67 | :animate "animate"
|
68 | 68 | :variants {:initial {:scale 1.5}
|
69 | 69 | :animate {:scale 1 :transition spring}}}]
|
70 |
| - [:> (.-g m) |
| 70 | + [:> (.-g motion) |
71 | 71 | {:initial "initial"
|
72 | 72 | :animate "animate"
|
73 | 73 | :variants {:initial {:rotate 45}
|
|
154 | 154 | (catch js/Error _
|
155 | 155 | (js/console.warn (str "Clerk render-notebook, invalid hash: "
|
156 | 156 | (.-hash js/location))))))]
|
157 |
| - (js/requestAnimationFrame #(.scrollIntoViewIfNeeded heading)))))] |
158 |
| - [:> LazyMotion {:features domAnimation} |
159 |
| - [:div.flex |
160 |
| - {:ref root-ref-fn} |
161 |
| - [:div.fixed.top-2.left-2.md:left-auto.md:right-2.z-10 |
162 |
| - [dark-mode-toggle !dark-mode?]] |
163 |
| - (when (and toc toc-visibility) |
164 |
| - [navbar/view toc (assoc render-opts :set-hash? (not bundle?) :toc-visibility toc-visibility)]) |
165 |
| - [:div.flex-auto.w-screen.scroll-container |
166 |
| - (into |
167 |
| - [:> (.-div m) |
168 |
| - (merge |
169 |
| - {:key "notebook-viewer" |
170 |
| - :class (cond-> (or doc-css-class [:flex :flex-col :items-center :notebook-viewer :flex-auto]) |
171 |
| - sidenotes? (conj :sidenotes-layout))} |
172 |
| - (when (and toc (not (navbar/mobile?))) |
173 |
| - (let [inset {:margin-left (if (and toc-visibility (:toc-open? @!expanded-at)) navbar/width 0)}] |
174 |
| - {:initial inset |
175 |
| - :animate inset |
176 |
| - :transition navbar/spring})))] |
177 |
| - ;; TODO: restore react keys via block-id |
178 |
| - ;; ^{:key (str processed-block-id "@" @!eval-counter)} |
179 |
| - (inspect-children render-opts) (concat (when header [header]) xs (when footer [footer])))]]])) |
| 157 | + (js/requestAnimationFrame #(.scrollIntoViewIfNeeded heading))))) |
| 158 | + _ (swap! !expanded-at merge (navbar/->toc-expanded-at toc toc-visibility))] |
| 159 | + [:div.flex |
| 160 | + {:ref root-ref-fn} |
| 161 | + [:div.fixed.top-2.left-2.md:left-auto.md:right-2.z-10 |
| 162 | + [dark-mode-toggle !dark-mode?]] |
| 163 | + (when (and toc toc-visibility) |
| 164 | + [navbar/view toc (assoc render-opts :set-hash? (not bundle?) :toc-visibility toc-visibility)]) |
| 165 | + [:div.flex-auto.w-screen.scroll-container |
| 166 | + (into |
| 167 | + [:> (.-div motion) |
| 168 | + (merge |
| 169 | + {:key "notebook-viewer" |
| 170 | + :class (cond-> (or doc-css-class [:flex :flex-col :items-center :notebook-viewer :flex-auto]) |
| 171 | + sidenotes? (conj :sidenotes-layout))} |
| 172 | + (when (and toc (not (navbar/mobile?))) |
| 173 | + (let [inset {:margin-left (if (and toc-visibility (:toc-open? @!expanded-at)) navbar/width 0)}] |
| 174 | + {:initial inset |
| 175 | + :animate inset |
| 176 | + :transition navbar/spring})))] |
| 177 | + ;; TODO: restore react keys via block-id |
| 178 | + ;; ^{:key (str processed-block-id "@" @!eval-counter)} |
| 179 | + (inspect-children render-opts) (concat (when header [header]) xs (when footer [footer])))]])) |
180 | 180 |
|
181 | 181 | (defn opts->query [opts]
|
182 | 182 | (->> opts
|
|
0 commit comments