Skip to content

Instantly share code, notes, and snippets.

View lwairore's full-sized avatar
💭
I may be slow to respond.

Karangu Lucas Wairore lwairore

💭
I may be slow to respond.
View GitHub Profile
@lwairore
lwairore / rainbow.directive.ts
Created July 29, 2020 11:58
The RainbowDirective listens for a keydown event on the host and sets its text and border color to a random color from a set of a few available colors.
import {
Directive,
HostBinding,
HostListener
} from '@angular/core';
@Directive({
selector: '[appRainbow]'
})
export class RainbowDirective {
@lwairore
lwairore / navbar-color-change-on-scroll.directive.ts
Last active September 7, 2020 07:17
NavbarColorChangeOnScrollDirective Angular directive toggles the CSS classes of a navbar on scrolling.
import { Directive, HostListener, HostBinding } from '@angular/core';
@Directive({
selector: '[otsNavbarColorChangeOnScroll]'
})
export class NavbarColorChangeOnScrollDirective {
private whiteNavbar: boolean;
constructor() { }
@HostListener('window:scroll', ['$event'])