11use leptos:: { html:: * , * } ;
2-
3- use crate :: {
4- footer, query_editor, query_table, sidebar,
5- store:: { self , editor:: EditorStore } ,
2+ use thaw:: {
3+ Button ,
4+ Tab ,
5+ //TabProps,
6+ Tabs ,
7+ // TabsProps
68} ;
79
10+ use crate :: { footer, query_editor, query_table, sidebar, store:: tabs} ;
11+
812pub fn component ( ) -> impl IntoView {
9- let tabs = use_context :: < store:: tabs:: Tabs > ( ) . unwrap ( ) ;
10- let mut editors = use_context :: < EditorStore > ( ) . unwrap ( ) ;
13+ let tabs = use_context :: < tabs:: Tabs > ( ) . unwrap ( ) ;
1114
1215 div ( )
1316 . classes ( "flex h-screen" )
@@ -19,39 +22,55 @@ pub fn component() -> impl IntoView {
1922 main ( )
2023 . classes ( "flex-1 overflow-y-scroll" )
2124 . child (
22- div ( )
23- . classes ( "flex" )
24- . child ( For ( ForProps {
25- each : move || ( 0 ..tabs. active_tabs . get ( ) ) ,
26- key : |index| * index,
27- children : move |index| {
28- button ( )
29- . classes ( "px-8 h-10 hover:bg-gray-200 border-b-2" )
30- . class ( "border-indigo-500" , move || {
31- index == tabs. selected_tab . get ( )
32- } )
33- . on ( ev:: click, move |_| {
34- tabs. selected_tab . update ( |prev| * prev = index) ;
35- } )
36- . child ( ( index + 1 ) . to_string ( ) )
37- } ,
38- } ) )
39- . child (
40- button ( )
41- . classes ( "px-8 h-10 border-b-2 hover:bg-gray-200" )
42- . on ( ev:: click, move |_| {
43- tabs. active_tabs . update ( |prev| * prev += 1 ) ;
44- tabs. selected_tab . update ( |prev| * prev += 1 ) ;
45- editors. add_editor ( ) ;
46- } )
47- . child ( "+" ) ,
48- ) ,
49- )
50- . child (
51- div ( )
52- . child ( query_editor:: component ( move || tabs. selected_tab . get ( ) ) )
53- . child ( query_table:: component ( ) ) ,
54- ) ,
25+ view ! {
26+ <Tabs value=tabs. selected_tab>
27+ <For each=move || ( 0 ..tabs. active_tabs. get( ) ) key=|index| index. to_string( ) let : index>
28+ <Tab key=index. to_string( ) label=( index + 1 ) . to_string( ) >
29+ { query_editor:: component( ) }
30+ { query_table:: component( ) }
31+ </Tab >
32+ </For >
33+ </Tabs >
34+ <Button on_click=move |_| {
35+ tabs. active_tabs. update( |prev| * prev += 1 ) ;
36+ tabs. selected_tab. update( |prev| * prev = ( tabs. active_tabs. get( ) - 1 ) . to_string( ) ) ;
37+ } >"+1" </Button >
38+ } ) ,
39+ // .child(Tabs(TabsProps {
40+ // value: tabs.selected_tab,
41+ // class: MaybeSignal::Static(String::new()),
42+ // children: Children::to_children(move || {
43+ // Fragment::new(vec![
44+ // For(ForProps {
45+ // each: move || (0..tabs.active_tabs.get()),
46+ // key: |index| index.to_string(),
47+ // children: move |index| {
48+ // Tab(TabProps {
49+ // class: MaybeSignal::Static(String::new()),
50+ // key: index.to_string(),
51+ // label: (index + 1).to_string(),
52+ // children: Children::to_children(move || {
53+ // Fragment::new(vec![
54+ // query_editor::component().into_view(),
55+ // query_table::component().into_view(),
56+ // ])
57+ // }),
58+ // })
59+ // },
60+ // })
61+ // .into_view(),
62+ // button()
63+ // .on(ev::click, move |_| {
64+ // tabs.active_tabs.update(|prev| *prev += 1);
65+ // tabs
66+ // .selected_tab
67+ // .update(|prev| *prev = (tabs.active_tabs.get() - 1).to_string());
68+ // })
69+ // .child("+")
70+ // .into_view(),
71+ // ])
72+ // }),
73+ // })),
5574 )
5675 . child ( footer:: component ( ) ) ,
5776 )
0 commit comments