33 [reagent.dom :as rdom]
44 [scittle.pyodide.pyodide-bridge :as pyodide]))
55
6+ ; ; ============================================================================
7+ ; ; Dark Mode Helpers
8+ ; ; ============================================================================
9+
10+ (defn dark-mode?
11+ " Check if dark mode is currently active by looking for 'quarto-dark' class on body"
12+ []
13+ (when-let [body (js/document.querySelector " body" )]
14+ (.contains (.-classList body) " quarto-dark" )))
15+
16+ (defn get-color
17+ " Get appropriate color based on dark mode state"
18+ [light-color dark-color]
19+ (if (dark-mode? ) dark-color light-color))
20+
621; ; ============================================================================
722; ; Matplotlib Data Visualization Demo
823; ; ============================================================================
@@ -134,20 +149,24 @@ plt.axis('equal')"})
134149 [:h2 {:style {:font-size " 28px"
135150 :font-weight " bold"
136151 :margin-bottom " 8px"
137- :color " #111827" }}
152+ :color ( get-color " #111827" " #F3F4F6 " ) }}
138153 " 📊 Data Visualization with Matplotlib" ]
139- [:p {:style {:color " #6B7280"
154+ [:p {:style {:color ( get-color " #6B7280" " #9CA3AF " )
140155 :margin-bottom " 24px"
141156 :font-size " 16px" }}
142157 " Create beautiful charts and visualizations using Python's matplotlib library, running entirely in your browser!" ]
143158 ; ; Info banner
144- [:div {:style {:background-color (if @matplotlib-loaded? " #D1FAE5" " #DBEAFE" )
159+ [:div {:style {:background-color (if @matplotlib-loaded?
160+ (get-color " #D1FAE5" " #064E3B" )
161+ (get-color " #DBEAFE" " #1E3A8A" ))
145162 :border-left (str " 4px solid " (if @matplotlib-loaded? " #10B981" " #3B82F6" ))
146163 :padding " 16px"
147164 :margin-bottom " 24px"
148165 :border-radius " 4px" }}
149166 [:p {:style {:font-size " 14px"
150- :color (if @matplotlib-loaded? " #065F46" " #1E40AF" )
167+ :color (if @matplotlib-loaded?
168+ (get-color " #065F46" " #6EE7B7" )
169+ (get-color " #1E40AF" " #93C5FD" ))
151170 :margin " 0" }}
152171 (if @matplotlib-loaded?
153172 " ✓ Matplotlib is loaded and ready!"
@@ -158,45 +177,45 @@ plt.axis('equal')"})
158177 :font-size " 14px"
159178 :font-weight " 600"
160179 :margin-bottom " 8px"
161- :color " #374151" }}
180+ :color ( get-color " #374151" " #D1D5DB " ) }}
162181 " Quick Examples:" ]
163182 [:div {:style {:display " flex"
164183 :gap " 8px"
165184 :flex-wrap " wrap" }}
166185 [:button {:style {:padding " 8px 16px"
167- :background-color " #F3F4F6"
168- :color " #374151"
169- :border " 1px solid #D1D5DB"
186+ :background-color ( get-color " #F3F4F6" " #374151 " )
187+ :color ( get-color " #374151" " #E5E7EB " )
188+ :border ( str " 1px solid " ( get-color " #D1D5DB" " #6B7280 " ))
170189 :border-radius " 6px"
171190 :font-size " 14px"
172191 :cursor " pointer"
173192 :font-weight " 500" }
174193 :on-click #(load-example! :line-chart )}
175194 " 📈 Line Chart" ]
176195 [:button {:style {:padding " 8px 16px"
177- :background-color " #F3F4F6"
178- :color " #374151"
179- :border " 1px solid #D1D5DB"
196+ :background-color ( get-color " #F3F4F6" " #374151 " )
197+ :color ( get-color " #374151" " #E5E7EB " )
198+ :border ( str " 1px solid " ( get-color " #D1D5DB" " #6B7280 " ))
180199 :border-radius " 6px"
181200 :font-size " 14px"
182201 :cursor " pointer"
183202 :font-weight " 500" }
184203 :on-click #(load-example! :bar-chart )}
185204 " 📊 Bar Chart" ]
186205 [:button {:style {:padding " 8px 16px"
187- :background-color " #F3F4F6"
188- :color " #374151"
189- :border " 1px solid #D1D5DB"
206+ :background-color ( get-color " #F3F4F6" " #374151 " )
207+ :color ( get-color " #374151" " #E5E7EB " )
208+ :border ( str " 1px solid " ( get-color " #D1D5DB" " #6B7280 " ))
190209 :border-radius " 6px"
191210 :font-size " 14px"
192211 :cursor " pointer"
193212 :font-weight " 500" }
194213 :on-click #(load-example! :scatter-plot )}
195214 " ⚫ Scatter Plot" ]
196215 [:button {:style {:padding " 8px 16px"
197- :background-color " #F3F4F6"
198- :color " #374151"
199- :border " 1px solid #D1D5DB"
216+ :background-color ( get-color " #F3F4F6" " #374151 " )
217+ :color ( get-color " #374151" " #E5E7EB " )
218+ :border ( str " 1px solid " ( get-color " #D1D5DB" " #6B7280 " ))
200219 :border-radius " 6px"
201220 :font-size " 14px"
202221 :cursor " pointer"
@@ -209,7 +228,7 @@ plt.axis('equal')"})
209228 :font-size " 14px"
210229 :font-weight " 600"
211230 :margin-bottom " 8px"
212- :color " #374151" }}
231+ :color ( get-color " #374151" " #D1D5DB " ) }}
213232 " Python Code (Matplotlib):" ]
214233 [:textarea {:value @code
215234 :on-change #(reset! code (.. % -target -value))
@@ -218,11 +237,11 @@ plt.axis('equal')"})
218237 :padding " 12px"
219238 :font-family " monospace"
220239 :font-size " 14px"
221- :border " 2px solid #D1D5DB"
240+ :border ( str " 2px solid " ( get-color " #D1D5DB" " #4B5563 " ))
222241 :border-radius " 6px"
223242 :resize " vertical"
224- :background-color " #FFFFFF"
225- :color " #111827" }}]]
243+ :background-color ( get-color " #FFFFFF" " #1F2937 " )
244+ :color ( get-color " #111827" " #F3F4F6 " ) }}]]
226245 ; ; Generate button
227246 [:button {:style {:width " 100%"
228247 :padding " 14px 24px"
@@ -246,16 +265,16 @@ plt.axis('equal')"})
246265 (not @matplotlib-loaded?) " Loading Matplotlib..."
247266 :else " 📊 Generate Chart" )]
248267 ; ; Output area
249- [:div {:style {:background-color " #FFFFFF"
250- :border " 2px solid #E5E7EB"
268+ [:div {:style {:background-color ( get-color " #FFFFFF" " #1F2937 " )
269+ :border ( str " 2px solid " ( get-color " #E5E7EB" " #4B5563 " ))
251270 :border-radius " 8px"
252271 :padding " 20px"
253272 :min-height " 400px" }}
254273 [:label {:style {:display " block"
255274 :font-size " 14px"
256275 :font-weight " 600"
257276 :margin-bottom " 12px"
258- :color " #374151" }}
277+ :color ( get-color " #374151" " #D1D5DB " ) }}
259278 " Visualization Output:" ]
260279 (if @output-image
261280 [:div {:style {:text-align " center" }}
@@ -267,7 +286,7 @@ plt.axis('equal')"})
267286 :box-shadow " 0 2px 8px rgba(0,0,0,0.1)" }}]]
268287 [:div {:style {:padding " 40px"
269288 :text-align " center"
270- :color " #6B7280"
289+ :color ( get-color " #6B7280" " #9CA3AF " )
271290 :font-size " 14px" }}
272291 [:p {:style {:margin " 0" }} @output-text]])]])
273292
0 commit comments