Skip to content

Commit

Permalink
Themed LangSwitchComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Sep 29, 2023
1 parent 9f2a1d0 commit f9b4460
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<nav role="navigation" [attr.aria-label]="'nav.user.description' | translate" class="navbar navbar-light navbar-expand-md flex-shrink-0 px-0">
<ds-themed-search-navbar></ds-themed-search-navbar>
<ds-lang-switch></ds-lang-switch>
<ds-themed-lang-switch></ds-themed-lang-switch>
<ds-context-help-toggle></ds-context-help-toggle>
<ds-themed-auth-nav-menu></ds-themed-auth-nav-menu>
<ds-impersonate-navbar></ds-impersonate-navbar>
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/lang-switch/lang-switch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class LangSwitchComponent implements OnInit {
this.activeLangs = environment.languages.filter((MyLangConfig) => MyLangConfig.active === true);
this.moreThanOneLanguage = (this.activeLangs.length > 1);
if (!this.moreThanOneLanguage) {
this.el.nativeElement.style.display = 'none';
this.el.nativeElement.parentElement.classList.add('d-none');
}
}

Expand Down
27 changes: 27 additions & 0 deletions src/app/shared/lang-switch/themed-lang-switch.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component } from '@angular/core';
import { ThemedComponent } from '../theme-support/themed.component';
import { LangSwitchComponent } from './lang-switch.component';

/**
* Themed wrapper for {@link LangSwitchComponent}
*/
@Component({
selector: 'ds-themed-lang-switch',
styleUrls: [],
templateUrl: '../theme-support/themed.component.html',
})
export class ThemedLangSwitchComponent extends ThemedComponent<LangSwitchComponent> {

protected getComponentName(): string {
return 'LangSwitchComponent';
}

protected importThemedComponent(themeName: string): Promise<any> {
return import(`../../../themes/${themeName}/app/shared/lang-switch/lang-switch.component`);
}

protected importUnthemedComponent(): Promise<any> {
return import(`./lang-switch.component`);
}

}
2 changes: 2 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ import {
} from '../item-page/simple/field-components/specific-field/title/themed-item-page-field.component';
import { BitstreamListItemComponent } from './object-list/bitstream-list-item/bitstream-list-item.component';
import { NgxPaginationModule } from 'ngx-pagination';
import { ThemedLangSwitchComponent } from './lang-switch/themed-lang-switch.component';

const MODULES = [
CommonModule,
Expand Down Expand Up @@ -335,6 +336,7 @@ const COMPONENTS = [
DsSelectComponent,
ErrorComponent,
LangSwitchComponent,
ThemedLangSwitchComponent,
LoadingComponent,
ThemedLoadingComponent,
LogInComponent,
Expand Down
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions src/themes/custom/app/shared/lang-switch/lang-switch.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { LangSwitchComponent as BaseComponent } from '../../../../../app/shared/lang-switch/lang-switch.component';

@Component({
selector: 'ds-lang-switch',
// styleUrls: ['./lang-switch.component.scss'],
styleUrls: ['../../../../../app/shared/lang-switch/lang-switch.component.scss'],
// templateUrl: './lang-switch.component.html',
templateUrl: '../../../../../app/shared/lang-switch/lang-switch.component.html',
})
export class LangSwitchComponent extends BaseComponent {
}
2 changes: 2 additions & 0 deletions src/themes/custom/eager-theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import {
ItemSearchResultListElementComponent
} from './app/shared/object-list/search-result-list-element/item-search-result/item-types/item/item-search-result-list-element.component';
import { TopLevelCommunityListComponent } from './app/home-page/top-level-community-list/top-level-community-list.component';
import { LangSwitchComponent } from './app/shared/lang-switch/lang-switch.component';


/**
Expand Down Expand Up @@ -91,6 +92,7 @@ const DECLARATIONS = [
EditCollectionSelectorComponent,
EditCommunitySelectorComponent,
EditItemSelectorComponent,
LangSwitchComponent,
];

@NgModule({
Expand Down
2 changes: 1 addition & 1 deletion src/themes/dspace/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="d-flex flex-grow-1 ml-auto justify-content-end align-items-center">
<ds-themed-search-navbar></ds-themed-search-navbar>
<ds-lang-switch></ds-lang-switch>
<ds-themed-lang-switch></ds-themed-lang-switch>
<ds-context-help-toggle></ds-context-help-toggle>
<ds-themed-auth-nav-menu></ds-themed-auth-nav-menu>
<ds-impersonate-navbar></ds-impersonate-navbar>
Expand Down
2 changes: 1 addition & 1 deletion src/themes/dspace/app/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ul>
</div>
<ds-search-navbar class="navbar-collapsed"></ds-search-navbar>
<ds-lang-switch class="navbar-collapsed"></ds-lang-switch>
<ds-themed-lang-switch class="navbar-collapsed"></ds-themed-lang-switch>
<ds-context-help-toggle class="navbar-collapsed"></ds-context-help-toggle>
<ds-themed-auth-nav-menu class="navbar-collapsed"></ds-themed-auth-nav-menu>
<ds-impersonate-navbar class="navbar-collapsed"></ds-impersonate-navbar>
Expand Down

0 comments on commit f9b4460

Please sign in to comment.