diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.html b/src/core/features/mainmenu/components/user-menu/user-menu.html index bb4dab87c..b24ab93c7 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.html +++ b/src/core/features/mainmenu/components/user-menu/user-menu.html @@ -17,6 +17,9 @@ + +

diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.scss b/src/core/features/mainmenu/components/user-menu/user-menu.scss index 924139eef..a42d797cd 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.scss +++ b/src/core/features/mainmenu/components/user-menu/user-menu.scss @@ -8,6 +8,10 @@ } .core-usermenu-siteinfo { + text-align: center; + ion-label { + margin: 0; + } --padding-top: 10px; --padding-bottom: 10px; } @@ -19,9 +23,21 @@ } .core-usermenu-sitename { - font-size: 16px; + font-weight: bold; + font-size: 20px; + line-height: 24px; } +img.core-usermenu-site-logo { + margin-bottom: 8px; + max-height: var(--core-user-menu-site-logo-max-height); +} + +img.image-not-found { + display: none; +} + + @if ($core-user-hide-sitename) { .core-usermenu-sitename { display: none; diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.ts b/src/core/features/mainmenu/components/user-menu/user-menu.ts index 1ec0e39ad..2ac460e3e 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.ts +++ b/src/core/features/mainmenu/components/user-menu/user-menu.ts @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { CoreConstants } from '@/core/constants'; import { Component, OnDestroy, OnInit } from '@angular/core'; -import { CoreSiteInfo } from '@classes/site'; +import { CoreSite, CoreSiteInfo } from '@classes/site'; import { CoreLoginSitesComponent } from '@features/login/components/sites/sites'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; @@ -36,12 +37,13 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { siteInfo?: CoreSiteInfo; siteName?: string; + siteLogo?: string; + siteLogoLoaded = false; siteUrl?: string; handlers: CoreUserProfileHandlerData[] = []; handlersLoaded = false; loaded = false; user?: CoreUserProfile; - moreSites = false; protected subscription!: Subscription; @@ -49,10 +51,6 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { * @inheritdoc */ async ngOnInit(): Promise { - // Check if there are more sites to switch. - const sites = await CoreSites.getSites(); - this.moreSites = sites.length > 1; - const currentSite = CoreSites.getRequiredCurrentSite(); this.siteInfo = currentSite.getInfo(); this.siteName = currentSite.getSiteName(); @@ -60,6 +58,8 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { this.loaded = true; + this.loadSiteLogo(currentSite); + // Load the handlers. if (this.siteInfo) { this.user = await CoreUser.getProfile(this.siteInfo.userid); @@ -82,6 +82,31 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { } } + /** + * Load site logo from current site public config. + * + * @param currentSite Current site object. + * @return Promise resolved when done. + */ + protected async loadSiteLogo(currentSite: CoreSite): Promise { + if (CoreConstants.CONFIG.forceLoginLogo) { + this.siteLogo = 'assets/img/login_logo.png'; + this.siteLogoLoaded = true; + + return; + } + + try { + const siteConfig = await currentSite.getPublicConfig(); + + this.siteLogo = CoreLoginHelper.getLogoUrl(siteConfig); + } catch { + // Ignore errors. + } finally { + this.siteLogoLoaded = true; + } + } + /** * Opens User profile page. * diff --git a/src/theme/theme.light.scss b/src/theme/theme.light.scss index 908669935..93f62f078 100644 --- a/src/theme/theme.light.scss +++ b/src/theme/theme.light.scss @@ -264,6 +264,8 @@ --core-course-module-navigation-max-height: 56px; --core-course-module-navigation-background: var(--contrast-background); + --core-user-menu-site-logo-max-height: 32px; + --addon-calendar-event-category-color: var(--purple); --addon-calendar-event-course-color: var(--red); --addon-calendar-event-group-color: var(--yellow);