Skip to content

Commit 7042f39

Browse files
committed
Fmt
1 parent e45d265 commit 7042f39

1 file changed

Lines changed: 86 additions & 97 deletions

File tree

src/app/header.rs

Lines changed: 86 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,8 @@ fn MobileFloatingButton(on_click: impl Fn() + 'static) -> impl IntoView {
3636
>
3737
// Always-visible directional caret, but refined
3838
<div class="absolute -top-4 left-1/2 transform -translate-x-1/2">
39-
<svg
40-
width="22"
41-
height="14"
42-
viewBox="0 0 22 14"
43-
fill="none"
44-
class="text-cyan/70"
45-
>
46-
<path
47-
d="M11 2L4 9L6 11L11 6L16 11L18 9L11 2Z"
48-
fill="currentColor"
49-
/>
39+
<svg width="22" height="14" viewBox="0 0 22 14" fill="none" class="text-cyan/70">
40+
<path d="M11 2L4 9L6 11L11 6L16 11L18 9L11 2Z" fill="currentColor" />
5041
</svg>
5142
</div>
5243

@@ -115,20 +106,14 @@ fn InputSection(
115106
}
116107
on:keyup=move |_| {
117108
if let Some(input_el) = input_ref.get_untracked() {
118-
if let Some(pos) = input_el
119-
.selection_start()
120-
.unwrap_or(None)
121-
{
109+
if let Some(pos) = input_el.selection_start().unwrap_or(None) {
122110
set_cursor_position.set(pos as usize);
123111
}
124112
}
125113
}
126114
on:click=move |_| {
127115
if let Some(input_el) = input_ref.get_untracked() {
128-
if let Some(pos) = input_el
129-
.selection_start()
130-
.unwrap_or(None)
131-
{
116+
if let Some(pos) = input_el.selection_start().unwrap_or(None) {
132117
set_cursor_position.set(pos as usize);
133118
}
134119
}
@@ -863,31 +848,29 @@ pub fn Header() -> impl IntoView {
863848

864849
view! {
865850
<>
866-
<header
867-
node_ref=header_ref
868-
class="shadow-lg border-b border-muted/30"
869-
>
870-
<div class="mx-auto px-3 sm:px-4 md:px-6 lg:px-8 py-3 sm:py-4">
871-
{move || {
872-
let history = output_history.get();
873-
let views = {
874-
let history = history.lock().expect("should be able to acquire lock");
875-
history.iter().map(|s| s()).collect_view()
876-
};
877-
if views.is_empty() {
878-
None
879-
} else {
880-
Some(
881-
view! {
882-
<div class="flex flex-col-reverse max-h-[480px] overflow-y-auto mb-2 p-3 rounded-md bg-black/20 border border-muted/30 backdrop-blur-sm">
883-
<pre class="whitespace-pre-wrap terminal-output leading-tight">
884-
{views}
885-
</pre>
886-
</div>
887-
},
888-
)
889-
}
890-
}} <InputSection
851+
<header node_ref=header_ref class="shadow-lg border-b border-muted/30">
852+
<div class="mx-auto px-3 sm:px-4 md:px-6 lg:px-8 py-3 sm:py-4">
853+
{move || {
854+
let history = output_history.get();
855+
let views = {
856+
let history = history.lock().expect("should be able to acquire lock");
857+
history.iter().map(|s| s()).collect_view()
858+
};
859+
if views.is_empty() {
860+
None
861+
} else {
862+
Some(
863+
view! {
864+
<div class="flex flex-col-reverse max-h-[480px] overflow-y-auto mb-2 p-3 rounded-md bg-black/20 border border-muted/30 backdrop-blur-sm">
865+
<pre class="whitespace-pre-wrap terminal-output leading-tight">
866+
{views}
867+
</pre>
868+
</div>
869+
},
870+
)
871+
}
872+
}}
873+
<InputSection
891874
input_ref=input_ref
892875
input_value=input_value
893876
set_input_value=set_input_value
@@ -900,75 +883,81 @@ pub fn Header() -> impl IntoView {
900883
submit_handler=shared_submit_handler
901884
aria_describedby="terminal-help"
902885
/>
903-
{move || {
904-
let tab_state = tab_state.get();
905-
tab_state
906-
.map(|ts| {
907-
let selected = ts
908-
.opts
909-
.iter()
910-
.enumerate()
911-
.find_map(|(vi, item)| {
912-
if Some(vi) == ts.index { Some(item.to_owned()) } else { None }
913-
});
914-
let render_func = move |item: DirContentItem| {
915-
let is_sel = selected.as_ref().map(|s| &s.0) == Some(&item.0);
916-
auto_comp_item(&item, is_sel).into_any()
917-
};
918-
view! {
919-
<div class="mt-2 p-3 rounded-md bg-black/30 border border-muted/40 backdrop-blur-sm">
920-
<pre class="whitespace-pre-wrap terminal-output">
921-
<ColumnarView items=ts.opts.to_vec() render_func />
922-
</pre>
923-
</div>
924-
}
925-
})
926-
}}
927-
</div>
886+
{move || {
887+
let tab_state = tab_state.get();
888+
tab_state
889+
.map(|ts| {
890+
let selected = ts
891+
.opts
892+
.iter()
893+
.enumerate()
894+
.find_map(|(vi, item)| {
895+
if Some(vi) == ts.index {
896+
Some(item.to_owned())
897+
} else {
898+
None
899+
}
900+
});
901+
let render_func = move |item: DirContentItem| {
902+
let is_sel = selected.as_ref().map(|s| &s.0) == Some(&item.0);
903+
auto_comp_item(&item, is_sel).into_any()
904+
};
905+
view! {
906+
<div class="mt-2 p-3 rounded-md bg-black/30 border border-muted/40 backdrop-blur-sm">
907+
<pre class="whitespace-pre-wrap terminal-output">
908+
<ColumnarView items=ts.opts.to_vec() render_func />
909+
</pre>
910+
</div>
911+
}
912+
})
913+
}}
914+
</div>
928915
</header>
929916

930917
// Floating overlay - mobile button or desktop header
931918
{move || {
932919
let sticky = is_sticky.get();
933920
let mobile = is_mobile.get();
934-
935921
if !sticky {
936-
// Not scrolled, don't show anything
937922
EitherOf3::A(())
938923
} else if mobile {
939-
// Mobile: show floating button
940-
EitherOf3::B(view! {
941-
<MobileFloatingButton
942-
on_click=move || {
924+
EitherOf3::B(
925+
926+
// Not scrolled, don't show anything
927+
// Mobile: show floating button
928+
view! {
929+
<MobileFloatingButton on_click=move || {
943930
scroll_to_top();
944931
#[cfg(feature = "hydrate")]
945932
if let Some(static_input) = input_ref.get_untracked() {
946933
let _ = static_input.focus();
947934
}
948-
}
949-
/>
950-
})
935+
} />
936+
},
937+
)
951938
} else {
952-
// Desktop: show full floating header
953-
EitherOf3::C(view! {
954-
<div class="fixed top-0 left-0 right-0 z-50 bg-background/95 backdrop-blur-md shadow-lg border-b border-muted/30">
955-
<div class="mx-auto px-3 sm:px-4 md:px-6 lg:px-8 py-3 sm:py-4">
956-
<InputSection
957-
input_ref=floating_input_ref
958-
input_value=input_value
959-
set_input_value=set_input_value
960-
cursor_position=cursor_position
961-
set_cursor_position=set_cursor_position
962-
ghost_text=ghost_text
963-
is_err=is_err
964-
keydown_handler=keydown_handler
965-
input_handler=input_handler
966-
submit_handler=floating_submit_handler
967-
aria_describedby="terminal-help-floating"
968-
/>
939+
EitherOf3::C(
940+
// Desktop: show full floating header
941+
view! {
942+
<div class="fixed top-0 left-0 right-0 z-50 bg-background/95 backdrop-blur-md shadow-lg border-b border-muted/30">
943+
<div class="mx-auto px-3 sm:px-4 md:px-6 lg:px-8 py-3 sm:py-4">
944+
<InputSection
945+
input_ref=floating_input_ref
946+
input_value=input_value
947+
set_input_value=set_input_value
948+
cursor_position=cursor_position
949+
set_cursor_position=set_cursor_position
950+
ghost_text=ghost_text
951+
is_err=is_err
952+
keydown_handler=keydown_handler
953+
input_handler=input_handler
954+
submit_handler=floating_submit_handler
955+
aria_describedby="terminal-help-floating"
956+
/>
957+
</div>
969958
</div>
970-
</div>
971-
})
959+
},
960+
)
972961
}
973962
}}
974963
</>

0 commit comments

Comments
 (0)