File tree Expand file tree Collapse file tree 9 files changed +28
-13
lines changed
navigation/navbar/web_app
static/css/scss/components Expand file tree Collapse file tree 9 files changed +28
-13
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: components:: { StaticNav , StaticNavLink } ;
2
+ use crate :: models:: User ;
2
3
use crate :: utils:: config;
3
4
use pgml_components:: component;
4
5
use sailfish:: TemplateOnce ;
@@ -9,14 +10,16 @@ pub struct WebApp {
9
10
pub standalone_dashboard : bool ,
10
11
pub links : Vec < StaticNavLink > ,
11
12
pub account_management_nav : StaticNav ,
13
+ pub user : User ,
12
14
}
13
15
14
16
impl WebApp {
15
- pub fn new ( links : Vec < StaticNavLink > , account_management_nav : StaticNav ) -> WebApp {
17
+ pub fn new ( links : Vec < StaticNavLink > , account_management_nav : StaticNav , user : User ) -> WebApp {
16
18
WebApp {
17
19
standalone_dashboard : config:: standalone_dashboard ( ) ,
18
20
links,
19
21
account_management_nav,
22
+ user,
20
23
}
21
24
}
22
25
}
Original file line number Diff line number Diff line change 21
21
22
22
<!-- Button to toggle collapsed menu for less than lg screens -->
23
23
< button class ="navbar-toggler collapsed topnav-controlls " type ="button " data-bs-toggle ="collapse " data-bs-target ="#navbarSupportedContent " aria-controls ="navbarSupportedContent " aria-expanded ="false " aria-label ="Toggle navigation ">
24
- < %+ ProfileIcon::new() %>
24
+ < %+ ProfileIcon::new(user.profile_picture.clone() ) %>
25
25
</ button >
26
26
</ div >
27
27
63
63
< li class ="d-none d-lg-flex nav-item align-items-center ">
64
64
< %+
65
65
Dropdown::nav(account_management_nav.links.clone())
66
- .icon(ProfileIcon::new().into())
66
+ .icon(ProfileIcon::new(user.profile_picture.clone() ).into())
67
67
.expandable()
68
68
%>
69
69
</ li >
Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ use sailfish::TemplateOnce;
3
3
4
4
#[ derive( TemplateOnce , Default ) ]
5
5
#[ template( path = "profile_icon/template.html" ) ]
6
- pub struct ProfileIcon ;
6
+ pub struct ProfileIcon {
7
+ pub profile_picture : Option < String > ,
8
+ }
7
9
8
10
impl ProfileIcon {
9
- pub fn new ( ) -> ProfileIcon {
10
- ProfileIcon
11
+ pub fn new ( profile_picture : Option < String > ) -> ProfileIcon {
12
+ ProfileIcon { profile_picture }
11
13
}
12
14
}
13
15
Original file line number Diff line number Diff line change
1
+ < % if let Some(profile_picture) = profile_picture { %>
2
+ < img src ="<%- profile_picture %> " width ="44 " height ="44 " class ="rounded-circle ">
3
+ < % } else { %>
4
+
1
5
< svg class ="rounded-circle " width ="44 " height ="44 " viewBox ="0 0 24 24 " fill ="none " xmlns ="http://www.w3.org/2000/svg ">
2
6
< path d ="M5 20V19C5 16.2386 7.23858 14 10 14H14C16.7614 14 19 16.2386 19 19V20M16 7C16 9.20914 14.2091 11 12 11C9.79086 11 8 9.20914 8 7C8 4.79086 9.79086 3 12 3C14.2091 3 16 4.79086 16 7Z " stroke ="black " stroke-width ="1.5 " stroke-linecap ="round " stroke-linejoin ="round "/>
3
7
</ svg >
8
+
9
+ < % } %>
Original file line number Diff line number Diff line change @@ -961,13 +961,15 @@ impl UploadedFile {
961
961
pub struct User {
962
962
pub id : i64 ,
963
963
pub email : String ,
964
+ pub profile_picture : Option < String > ,
964
965
}
965
966
966
967
impl Default for User {
967
968
fn default ( ) -> User {
968
969
User {
969
970
id : -1 ,
970
971
email : "" . to_string ( ) ,
972
+ profile_picture : None ,
971
973
}
972
974
}
973
975
}
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ pub struct WebAppBase<'a> {
127
127
pub upper_left_nav : StaticNav ,
128
128
pub lower_left_nav : StaticNav ,
129
129
pub body_components : Vec < Component > ,
130
+ pub user : models:: User ,
130
131
}
131
132
132
133
impl < ' a > WebAppBase < ' a > {
@@ -139,6 +140,7 @@ impl<'a> WebAppBase<'a> {
139
140
account_management_nav : context. account_management_nav . clone ( ) ,
140
141
upper_left_nav : context. upper_left_nav . clone ( ) ,
141
142
lower_left_nav : context. lower_left_nav . clone ( ) ,
143
+ user : context. user . clone ( ) ,
142
144
..Default :: default ( )
143
145
}
144
146
}
Original file line number Diff line number Diff line change 110
110
color : #{$neon-tint-100 } ;
111
111
}
112
112
113
- svg {
113
+ svg , img {
114
114
border-color : #{$neon-tint-100 } ;
115
115
}
116
116
117
117
}
118
118
119
- svg {
119
+ svg , img {
120
120
border : 2px solid #{$gray-700 } ;
121
121
background-color : #{$gray-500 } ;
122
122
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ <h3 class="h3">icons</h3>
19
19
< %+ GithubIcon::new() %>
20
20
</ div >
21
21
< div class ="mb-3 ">
22
- < %+ ProfileIcon %>
22
+ < %+ ProfileIcon::new(None) %>
23
23
</ div >
24
24
25
25
< h3 class ="h3 "> Dropdowns</ h3 >
@@ -33,7 +33,7 @@ <h3 class="h3">Dropdowns</h3>
33
33
StaticNavLink::new("Starts Active".into(), "#test".into()).active(true)
34
34
]
35
35
).collapsable()
36
- .icon(ProfileIcon::new().into()) %>
36
+ .icon(ProfileIcon::new(None ).into()) %>
37
37
</ div >
38
38
< div class ="col-6 " style ="min-height: 400px; ">
39
39
< %+ Dropdown::nav(
Original file line number Diff line number Diff line change 24
24
< main >
25
25
< div class ="container-fluid p-0 min-vh-lg-100 ">
26
26
< div class ="row gx-0 min-vh-lg-100 gy-0 ">
27
- < %+ WebAppNavbar::new(left_nav_links, account_management_nav) %>
27
+ < %+ WebAppNavbar::new(left_nav_links, account_management_nav, user ) %>
28
28
29
29
< div class ="d-flex ">
30
- < %+ WebAppLeftNav::new( upper_left_nav, lower_left_nav, dropdown_nav ) %>
30
+ < %+ WebAppLeftNav::new(upper_left_nav, lower_left_nav, dropdown_nav) %>
31
31
32
32
< div class ="clear-from-under-navbar flex-grow-1 min-vw-0 ">
33
33
< div class ="px-4 px-sm-5 py-3 " style ="position: absolute ">
34
- < %- Breadcrumbs::render( breadcrumbs ) %>
34
+ < %- Breadcrumbs::render(breadcrumbs) %>
35
35
</ div >
36
36
37
37
< div class ="px-xs-2 px-md-5 overflow-hidden " style ="padding-top: 57px; ">
You can’t perform that action at this time.
0 commit comments