-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
260 additions
and
10 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
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
4 changes: 4 additions & 0 deletions
4
src/app/docs/customization/dynamic-styles/dynamic-styles.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<p> | ||
dynamic-styles works! | ||
</p> | ||
<a [className]="classes.myStylesRoot">myStylesRoot</a> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/docs/customization/dynamic-styles/dynamic-styles.component.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DynamicStylesComponent } from './dynamic-styles.component'; | ||
|
||
describe('DynamicStylesComponent', () => { | ||
let component: DynamicStylesComponent; | ||
let fixture: ComponentFixture<DynamicStylesComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DynamicStylesComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DynamicStylesComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/app/docs/customization/dynamic-styles/dynamic-styles.component.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,39 @@ | ||
import { Component, OnInit, Injectable, ElementRef, Renderer2 } from '@angular/core'; | ||
import { LyTheme2, DynamicStyles } from '@alyle/ui'; | ||
|
||
const myStyles = (theme) => ({ | ||
root: { | ||
color: theme.primary.default, | ||
'&:hover': { | ||
color: theme.accent.default | ||
} | ||
} | ||
}); | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DynamicStylesService { | ||
constructor( | ||
public theme: LyTheme2 | ||
) { | ||
this.theme.addStyleSheet(myStyles, 'myStyles'); | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: 'aui-dynamic-styles', | ||
templateUrl: './dynamic-styles.component.html', | ||
styleUrls: ['./dynamic-styles.component.scss'] | ||
}) | ||
export class DynamicStylesComponent implements OnInit { | ||
classes = this.theme.classes; | ||
constructor( | ||
private dynamicStylesService: DynamicStylesService, | ||
private theme: LyTheme2 | ||
) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
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
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
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,22 @@ | ||
import { ElementRef, Renderer2 } from '@angular/core'; | ||
import { LyTheme2 } from './theme2.service'; | ||
import { Style } from '@alyle/ui'; | ||
|
||
export class DynamicStyles { | ||
get classes() { | ||
return this.theme.classes; | ||
} | ||
constructor( | ||
private theme: LyTheme2 | ||
) { | ||
|
||
} | ||
setUpStyle<T>(id: string, style: Style<T>, el?: any, instance?: string) { | ||
const newClass = this.theme.setUpStyle<T>(id, style); | ||
if (instance) { | ||
el.classList.remove(instance); | ||
} | ||
el.classList.add(newClass); | ||
return newClass; | ||
} | ||
} |
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