File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
projects/coreui-angular/src/lib/services Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ export { LocalStorageService } from './local-storage.service';
5
5
export { InMemoryStorageService } from './in-memory-storage.service' ;
6
6
export { ColorModeService , ColorMode } from './color-mode.service' ;
7
7
export { UIDService } from './uid.service' ;
8
+ export { RtlService } from './rtl.service' ;
Original file line number Diff line number Diff line change
1
+ import { TestBed } from '@angular/core/testing' ;
2
+
3
+ import { RtlService } from './rtl.service' ;
4
+
5
+ describe ( 'RtlService' , ( ) => {
6
+ let service : RtlService ;
7
+
8
+ beforeEach ( ( ) => {
9
+ TestBed . configureTestingModule ( { } ) ;
10
+ service = TestBed . inject ( RtlService ) ;
11
+ } ) ;
12
+
13
+ it ( 'should be created' , ( ) => {
14
+ expect ( service ) . toBeTruthy ( ) ;
15
+ } ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { inject , Injectable } from '@angular/core' ;
2
+ import { DOCUMENT } from '@angular/common' ;
3
+
4
+ @Injectable ( {
5
+ providedIn : 'root'
6
+ } )
7
+ export class RtlService {
8
+ readonly #document = inject ( DOCUMENT ) ;
9
+
10
+ isRTL ( element ?: HTMLElement | null ) : boolean {
11
+ if ( element ) {
12
+ return element . closest ( '[dir="rtl"]' ) !== null ;
13
+ }
14
+
15
+ return this . #document?. documentElement ?. dir === 'rtl' || this . #document?. body ?. dir === 'rtl' ;
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments