11use crate :: components:: { HeaderBar , OutputLog , PromptLine } ;
22use crate :: types:: TermLine ;
3- use web_sys:: window;
43use yew:: prelude:: * ;
54
6- const DARK_MODE_ICON : & str = include_str ! ( "../icons/dark_mode.svg" ) ;
7- const LIGHT_MODE_ICON : & str = include_str ! ( "../icons/light_mode.svg" ) ;
8-
95#[ derive( Properties , PartialEq ) ]
106pub struct TerminalWindowProps {
117 pub lines : Vec < TermLine > ,
@@ -18,35 +14,6 @@ pub struct TerminalWindowProps {
1814
1915#[ function_component( TerminalWindow ) ]
2016pub fn terminal_window ( props : & TerminalWindowProps ) -> Html {
21- let is_dark_icon = use_state ( || true ) ;
22-
23- let toggle_icon = {
24- let is_dark_icon = is_dark_icon. clone ( ) ;
25- Callback :: from ( move |_| is_dark_icon. set ( !* is_dark_icon) )
26- } ;
27-
28- {
29- let is_dark_icon = is_dark_icon. clone ( ) ;
30- use_effect_with ( is_dark_icon, move |is_dark| {
31- if let Some ( document) = window ( ) . and_then ( |w| w. document ( ) ) {
32- if let Some ( root) = document. document_element ( ) {
33- let _ = if * * is_dark {
34- root. class_list ( ) . add_1 ( "theme-dark" )
35- } else {
36- root. class_list ( ) . remove_1 ( "theme-dark" )
37- } ;
38- }
39- }
40- || ( )
41- } ) ;
42- }
43-
44- let icon_svg = if * is_dark_icon {
45- DARK_MODE_ICON
46- } else {
47- LIGHT_MODE_ICON
48- } ;
49- let icon = Html :: from_html_unchecked ( AttrValue :: from ( icon_svg) ) ;
5017 let body = html ! {
5118 <>
5219 <OutputLog lines={ props. lines. clone( ) } />
@@ -61,15 +28,6 @@ pub fn terminal_window(props: &TerminalWindowProps) -> Html {
6128
6229 html ! {
6330 <div class="min-h-[100svh] bg-page text-text flex items-start sm:items-center justify-center px-4 pt-16 pb-6 sm:p-6 overflow-y-auto" >
64- <button
65- type ="button"
66- class="fixed top-4 right-4 sm:top-6 sm:right-6 h-9 w-9 sm:h-10 sm:w-10 flex items-center justify-center rounded-full text-border hover:bg-hover transition-colors"
67- aria-label="Toggle theme"
68- onclick={ toggle_icon}
69- >
70- { icon }
71- </button>
72-
7331 {
7432 if !props. show_window {
7533 html! {
0 commit comments