mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-23 01:37:59 +00:00
highlight directive added
This commit is contained in:
@@ -7,6 +7,7 @@ import { AppComponent } from './app.component';
|
|||||||
import { ConfigService } from './shared/services/config.service';
|
import { ConfigService } from './shared/services/config.service';
|
||||||
import { DataService } from './shared/services/data.service';
|
import { DataService } from './shared/services/data.service';
|
||||||
import { HomeComponent } from './home/home.component';
|
import { HomeComponent } from './home/home.component';
|
||||||
|
import { HighlightDirective } from './shared/directives/highlight.directive';
|
||||||
import { MatchComponent } from './shared/components/match.component';
|
import { MatchComponent } from './shared/components/match.component';
|
||||||
import { routing } from './app.routes';
|
import { routing } from './app.routes';
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ import { routing } from './app.routes';
|
|||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
HomeComponent,
|
HomeComponent,
|
||||||
|
HighlightDirective,
|
||||||
MatchComponent
|
MatchComponent
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<span class="label label-success">{{match.Type}}</span>
|
<span class="label label-success">{{match.Type}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-default btn-xs" (click)="subscribe()">
|
<button type="button" class="btn btn-default btn-md" (click)="subscribe()">
|
||||||
Subscribe to feed
|
Subscribe to feed
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let feed of match.Feeds">
|
<tr *ngFor="let feed of match.Feeds" feedHighlight>
|
||||||
<td>
|
<td>
|
||||||
<span class="feed-time">{{feed.CreatedAt | date:'shortTime' }}</span>
|
<span class="feed-time">{{feed.CreatedAt | date:'shortTime' }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
22
app/shared/directives/highlight.directive.ts
Normal file
22
app/shared/directives/highlight.directive.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { Directive, ElementRef, HostListener, Input, Renderer } from '@angular/core';
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: '[feedHighlight]'
|
||||||
|
})
|
||||||
|
export class HighlightDirective {
|
||||||
|
constructor(private el: ElementRef, private renderer: Renderer) {
|
||||||
|
this.renderer.setElementClass(this.el.nativeElement, 'feed-highlight', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('mouseenter') onMouseEnter() {
|
||||||
|
this.highlight('white');
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('mouseleave') onMouseLeave() {
|
||||||
|
this.highlight(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private highlight(color: string) {
|
||||||
|
this.renderer.setElementStyle(this.el.nativeElement, 'backgroundColor', color);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,4 +35,13 @@ th, td {
|
|||||||
|
|
||||||
.feed-update {
|
.feed-update {
|
||||||
color: #337ab7;
|
color: #337ab7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.feed-highlight {
|
||||||
|
background-color: #eee;
|
||||||
|
-webkit-transition: background-color 2000ms linear;
|
||||||
|
-moz-transition: background-color 2000ms linear;
|
||||||
|
-o-transition: background-color 2000ms linear;
|
||||||
|
-ms-transition: background-color 2000ms linear;
|
||||||
|
transition: background-color 2000ms linear;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user