-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin-ui): Add missing RTL compatibility to some admin-ui compone…
…nts (#2451)
- Loading branch information
1 parent
ed109b9
commit 96eb96e
Showing
9 changed files
with
171 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 8 additions & 13 deletions
21
packages/admin-ui/src/lib/core/src/components/notification/notification.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
<div | ||
class="notification-wrapper" | ||
#wrapper | ||
[style.top.px]="offsetTop" | ||
[ngClass]="{ | ||
visible: isVisible, | ||
info: type === 'info', | ||
success: type === 'success', | ||
error: type === 'error', | ||
warning: type === 'warning' | ||
}" | ||
> | ||
<div [dir]="direction$ | async" class="notification-wrapper" #wrapper [style.top.px]="offsetTop" [ngClass]="{ | ||
visible: isVisible, | ||
info: type === 'info', | ||
success: type === 'success', | ||
error: type === 'error', | ||
warning: type === 'warning' | ||
}"> | ||
<clr-icon [attr.shape]="getIcon()" size="24"></clr-icon> | ||
{{ stringifyMessage(message) | translate: translationVars }} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/admin-ui/src/lib/core/src/providers/localization/localization.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { TestingCommonModule } from '../../../../../testing/testing-common.module'; | ||
import { MockI18nService } from '../i18n/i18n.service.mock'; | ||
import { DataService } from '../../data/providers/data.service'; | ||
import { I18nService } from '../../providers/i18n/i18n.service'; | ||
import { LocalizationService } from './localization.service'; | ||
|
||
describe('LocalizationService', () => { | ||
let service: LocalizationService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [TestingCommonModule], | ||
providers: [ | ||
LocalizationService, | ||
{ provide: I18nService, useClass: MockI18nService }, | ||
{ provide: DataService, useClass: class {} }, | ||
], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}); | ||
service = TestBed.inject(LocalizationService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/admin-ui/src/lib/core/src/providers/localization/localization.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, map } from 'rxjs'; | ||
|
||
import { DataService } from '../../data/providers/data.service'; | ||
import { I18nService } from '../../providers/i18n/i18n.service'; | ||
import { LanguageCode } from '../../common/generated-types'; | ||
|
||
export type LocalizationDirectionType = Observable<'ltr' | 'rtl'>; | ||
export type LocalizationLanguageCodeType = Observable<[LanguageCode, string | undefined]>; | ||
|
||
/** | ||
* @description | ||
* Provides localization helper functionality. | ||
* | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class LocalizationService { | ||
uiLanguageAndLocale$: LocalizationLanguageCodeType; | ||
direction$: LocalizationDirectionType; | ||
|
||
constructor(private i18nService: I18nService, private dataService: DataService) { | ||
this.uiLanguageAndLocale$ = this.dataService.client | ||
?.uiState() | ||
?.stream$?.pipe(map(({ uiState }) => [uiState.language, uiState.locale ?? undefined])); | ||
|
||
this.direction$ = this.uiLanguageAndLocale$?.pipe( | ||
map(([languageCode]) => { | ||
return this.i18nService.isRTL(languageCode) ? 'rtl' : 'ltr'; | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 14 additions & 18 deletions
32
...ages/admin-ui/src/lib/core/src/shared/components/modal-dialog/modal-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
<clr-modal | ||
[clrModalOpen]="true" | ||
(clrModalOpenChange)="modalOpenChange($event)" | ||
[clrModalClosable]="options?.closable" | ||
[clrModalSize]="options?.size" | ||
[ngClass]="'modal-valign-' + (options?.verticalAlign || 'center')" | ||
> | ||
<h3 class="modal-title"><ng-container *ngTemplateOutlet="(titleTemplateRef$ | async)"></ng-container></h3> | ||
<div class="modal-body"> | ||
<vdr-dialog-component-outlet | ||
[component]="childComponentType" | ||
(create)="onCreate($event)" | ||
></vdr-dialog-component-outlet> | ||
</div> | ||
<div class="modal-footer"> | ||
<ng-container *ngTemplateOutlet="(buttonsTemplateRef$ | async)"></ng-container> | ||
</div> | ||
</clr-modal> | ||
<div [dir]="direction$ | async"> | ||
<clr-modal [clrModalOpen]="true" (clrModalOpenChange)="modalOpenChange($event)" | ||
[clrModalClosable]="options?.closable" [clrModalSize]="options?.size" | ||
[ngClass]="'modal-valign-' + (options?.verticalAlign || 'center')"> | ||
<h3 class="modal-title"><ng-container *ngTemplateOutlet="(titleTemplateRef$ | async)"></ng-container></h3> | ||
<div class="modal-body"> | ||
<vdr-dialog-component-outlet [component]="childComponentType" | ||
(create)="onCreate($event)"></vdr-dialog-component-outlet> | ||
</div> | ||
<div class="modal-footer"> | ||
<ng-container *ngTemplateOutlet="(buttonsTemplateRef$ | async)"></ng-container> | ||
</div> | ||
</clr-modal> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters