@@ -10,52 +10,60 @@ use crate::{
1010 navigation:: navigate_to,
1111} ;
1212
13- #[ island]
14- pub ( super ) fn OrgSelectorPopover ( user : AuthUser ) -> impl IntoView {
15- const CONTAINER_CLASS : & str = "transition hover:bg-base-3 active:bg-base-4 \
16- cursor-pointer px-2 py-1 rounded flex \
17- flex-col gap leading-none items-end gap-0";
18-
13+ #[ component]
14+ fn OrgSelectorTrigger ( ) -> impl IntoView {
1915 let active_org_hook = OrgHook :: new_active ( ) ;
2016 let active_org_descriptor = active_org_hook. descriptor ( ) ;
21- let user_name = Signal :: stored ( user. name . to_string ( ) ) ;
2217
18+ const CLASS : & str = "transition hover:bg-base-3 active:bg-base-4 \
19+ cursor-pointer px-2 py-1 rounded flex flex-col gap-0.5 \
20+ text-sm leading-none items-end gap-0";
21+
22+ view ! {
23+ <div class=CLASS >
24+ <p class="text-base/[1] text-base-12" >
25+ <Suspense fallback=|| "[loading]" >
26+ { move || Suspend :: new( active_org_descriptor) }
27+ </Suspense >
28+ </p>
29+ <div class="flex flex-row items-end gap-0.5" >
30+ <p>"Switch Orgs" </p>
31+ <ChevronDownHeroIcon { ..} class="size-3 stroke-[3.0] stroke-base-11" />
32+ </div>
33+ </div>
34+ }
35+ }
36+
37+ #[ island]
38+ pub ( super ) fn OrgSelector ( ) -> impl IntoView {
2339 view ! {
2440 <Popover >
2541 <PopoverTrigger slot>
26- <div class=CONTAINER_CLASS >
27- <span class="text-base-12 text-sm" >{ user_name } </span>
28- <div class="flex flex-row items-center gap-0" >
29- <span class="text-sm" >
30- <Suspense fallback=|| "[loading]" >
31- { move || Suspend :: new( active_org_descriptor) }
32- </Suspense >
33- </span>
34- <ChevronDownHeroIcon { ..} class="size-3 stroke-[3.0] stroke-base-11" />
35- </div>
36- </div>
42+ <OrgSelectorTrigger />
3743 </PopoverTrigger >
3844
3945 <PopoverContents slot>
40- <OrgSelector user=user />
46+ <OrgSelectorMenu />
4147 </PopoverContents >
4248 </Popover >
4349 }
4450}
4551
4652#[ component]
47- fn OrgSelector ( user : AuthUser ) -> impl IntoView {
53+ fn OrgSelectorMenu ( ) -> impl IntoView {
54+ let auth_user = expect_context :: < AuthUser > ( ) ;
55+
4856 const POPOVER_CLASS : & str =
49- "absolute left -0 top-[calc(100%+(var(--spacing)*2 ))] min-w-56 \
57+ "absolute right -0 top-[calc(100%+(var(--spacing)*4 ))] min-w-56 \
5058 elevation-lv1 p-2 flex flex-col gap-1 leading-none";
5159
5260 let org_hooks = Signal :: stored (
53- user
61+ auth_user
5462 . iter_orgs ( )
5563 . map ( |o| ( o, OrgHook :: new ( move || o) ) )
5664 . collect :: < Vec < _ > > ( ) ,
5765 ) ;
58- let active_org = user . active_org ( ) ;
66+ let active_org = auth_user . active_org ( ) ;
5967
6068 let action = ServerAction :: < SwitchActiveOrg > :: new ( ) ;
6169 let selected = RwSignal :: new ( None :: < RecordId < Org > > ) ;
@@ -97,9 +105,9 @@ fn OrgSelector(user: AuthUser) -> impl IntoView {
97105
98106 view ! {
99107 <div
100- class="rounded p-2 flex flex-row gap-2 items-center"
101- class=( "text-base-12 font-semibold " , id == active_org)
102- class=( "cursor-pointer hover:bg-base-3 active:bg-base-4 " , id != active_org)
108+ class="rounded p-2 flex flex-row gap-2 items-center transition-colors text-base-12 "
109+ class=( "font-bold " , id == active_org)
110+ class=( "cursor-pointer btn-link-secondary " , id != active_org)
103111 on: click=handler
104112 >
105113 { icon_element }
@@ -128,7 +136,8 @@ fn OrgSelector(user: AuthUser) -> impl IntoView {
128136#[ component]
129137fn CreateOrgRow ( ) -> impl IntoView {
130138 const CLASS : & str = "rounded p-2 flex flex-row gap-2 items-center \
131- cursor-pointer hover:bg-base-3 active-bg-base-4";
139+ cursor-pointer btn-link-secondary transition-colors \
140+ text-base-12";
132141
133142 view ! {
134143 <a href="/org/create_org" class=CLASS >
0 commit comments