Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for adding profile picture#1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
levkk wants to merge1 commit intomaster
base:master
Choose a base branch
Loading
fromlevkk-profile-pic
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
use crate::components::{StaticNav, StaticNavLink};
use crate::models::User;
use crate::utils::config;
use pgml_components::component;
use sailfish::TemplateOnce;
Expand All@@ -9,14 +10,16 @@ pub struct WebApp {
pub standalone_dashboard: bool,
pub links: Vec<StaticNavLink>,
pub account_management_nav: StaticNav,
pub user: User,
}

impl WebApp {
pub fn new(links: Vec<StaticNavLink>, account_management_nav: StaticNav) -> WebApp {
pub fn new(links: Vec<StaticNavLink>, account_management_nav: StaticNav, user: User) -> WebApp {
WebApp {
standalone_dashboard: config::standalone_dashboard(),
links,
account_management_nav,
user,
}
}
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@

<!-- Button to toggle collapsed menu for less than lg screens -->
<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">
<%+ ProfileIcon::new() %>
<%+ ProfileIcon::new(user.profile_picture.clone()) %>
</button>
</div>

Expand DownExpand Up@@ -63,7 +63,7 @@
<li class="d-none d-lg-flex nav-item align-items-center">
<%+
Dropdown::nav(account_management_nav.links.clone())
.icon(ProfileIcon::new().into())
.icon(ProfileIcon::new(user.profile_picture.clone()).into())
.expandable()
%>
</li>
Expand Down
8 changes: 5 additions & 3 deletionspgml-dashboard/src/components/profile_icon/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,11 +3,13 @@ use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "profile_icon/template.html")]
pub struct ProfileIcon;
pub struct ProfileIcon {
pub profile_picture: Option<String>,
}

impl ProfileIcon {
pub fn new() -> ProfileIcon {
ProfileIcon
pub fn new(profile_picture: Option<String>) -> ProfileIcon {
ProfileIcon { profile_picture }
}
}

Expand Down
6 changes: 6 additions & 0 deletionspgml-dashboard/src/components/profile_icon/template.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
<% if let Some(profile_picture) = profile_picture { %>
<img src="<%- profile_picture %>" width="44" height="44" class="rounded-circle">
<% } else { %>

<svg class="rounded-circle" width="44" height="44" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<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"/>
</svg>

<% } %>
2 changes: 2 additions & 0 deletionspgml-dashboard/src/models.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -961,13 +961,15 @@ impl UploadedFile {
pub struct User {
pub id: i64,
pub email: String,
pub profile_picture: Option<String>,
}

impl Default for User {
fn default() -> User {
User {
id: -1,
email: "".to_string(),
profile_picture: None,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletionspgml-dashboard/src/templates/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -127,6 +127,7 @@ pub struct WebAppBase<'a> {
pub upper_left_nav: StaticNav,
pub lower_left_nav: StaticNav,
pub body_components: Vec<Component>,
pub user: models::User,
}

impl<'a> WebAppBase<'a> {
Expand All@@ -139,6 +140,7 @@ impl<'a> WebAppBase<'a> {
account_management_nav: context.account_management_nav.clone(),
upper_left_nav: context.upper_left_nav.clone(),
lower_left_nav: context.lower_left_nav.clone(),
user: context.user.clone(),
..Default::default()
}
}
Expand Down
4 changes: 2 additions & 2 deletionspgml-dashboard/static/css/scss/components/_icon.scss
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -110,13 +110,13 @@
color: #{$neon-tint-100};
}

svg {
svg,img {
border-color: #{$neon-tint-100};
}

}

svg {
svg,img {
border: 2px solid #{$gray-700};
background-color: #{$gray-500};
}
Expand Down
4 changes: 2 additions & 2 deletionspgml-dashboard/templates/content/playground.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,7 @@ <h3 class="h3">icons</h3>
<%+ GithubIcon::new() %>
</div>
<div class="mb-3">
<%+ ProfileIcon %>
<%+ ProfileIcon::new(None) %>
</div>

<h3 class="h3">Dropdowns</h3>
Expand All@@ -33,7 +33,7 @@ <h3 class="h3">Dropdowns</h3>
StaticNavLink::new("Starts Active".into(), "#test".into()).active(true)
]
).collapsable()
.icon(ProfileIcon::new().into()) %>
.icon(ProfileIcon::new(None).into()) %>
</div>
<div class="col-6" style="min-height: 400px;">
<%+ Dropdown::nav(
Expand Down
6 changes: 3 additions & 3 deletionspgml-dashboard/templates/layout/web_app_base.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,14 +24,14 @@
<main>
<div class="container-fluid p-0 min-vh-lg-100">
<div class="row gx-0 min-vh-lg-100 gy-0">
<%+ WebAppNavbar::new(left_nav_links, account_management_nav) %>
<%+ WebAppNavbar::new(left_nav_links, account_management_nav, user) %>

<div class="d-flex">
<%+ WebAppLeftNav::new(upper_left_nav, lower_left_nav, dropdown_nav) %>
<%+ WebAppLeftNav::new(upper_left_nav, lower_left_nav, dropdown_nav) %>

<div class="clear-from-under-navbar flex-grow-1 min-vw-0">
<div class="px-4 px-sm-5 py-3" style="position: absolute">
<%- Breadcrumbs::render(breadcrumbs) %>
<%- Breadcrumbs::render(breadcrumbs) %>
</div>

<div class="px-xs-2 px-md-5 overflow-hidden" style="padding-top: 57px;">
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp