Skip to content

Instantly share code, notes, and snippets.

View yokoishioka's full-sized avatar

yoko ishioka yokoishioka

View GitHub Profile
import { Directive, HostListener } from '@angular/core';
import { DevicesService } from './devices.service';
@Directive({
selector: '[cesDeviceScreenSize]'
})
export class DeviceScreenSizeDirective {
constructor(
private devices: DevicesService
) { }
@yokoishioka
yokoishioka / device-screen-size.directive.ts
Last active April 29, 2020 01:27
service and directive to detect screen size changes
import { Directive, HostListener } from '@angular/core';
import { DevicesService } from './devices.service';
@Directive({
selector: '[cesDeviceScreenSize]'
})
export class DeviceScreenSizeDirective {
constructor(
private devices: DevicesService
) { }
import { Component, Input } from '@angular/core';
@Component({
selector: 'ces-svg',
template: `
<img src="/assets/images/svgs/{{ type }}.svg" [alt]="type + ' icon'" [title]="title">
`,
styleUrls: [
'./svg.component.scss'
]
svg {
width: inherit;
height: inherit;
fill: inherit;
background: inherit;
background-color: inherit;
}
img {
width: inherit;
import { Component } from '@angular/core';
@Component({
selector: 'ces-svg-astronaut',
templateUrl: '../../../../../../src/assets/images/svgs/astronaut.svg',
styleUrls: ['../../svg.component.scss']
})
export class SvgAstronautComponent {
constructor() { }
@import "src/assets/styles/variables.scss";
button {
font-size: inherit;
background: inherit;
color: inherit;
text-align: center;
padding: 0.5em 1.0em;
border: 1px solid;
border-radius: $border-radius;
import { Component, Input } from '@angular/core';
@Component({
selector: 'ces-button',
templateUrl: './button.component.html',
styleUrls: [
'./button.component.scss'
]
})
<ces-button type="button" class="no-border no-padding" (click)="onClose()">
<span *ngIf="label" class="label">{{ label }}</span>
<img *ngIf="showIcon" src="/assets/svgs/button-close.png" alt="button that hides its parent">
<ng-content></ng-content>
</ces-button>
@yokoishioka
yokoishioka / button-hide-parent.ts
Last active March 4, 2020 06:49
button that hides any parent
import { Component, Input, Renderer2, ElementRef, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'ces-button-hide-parent',
templateUrl: './button-hide-parent.component.html',
styleUrls: ['./button-hide-parent.component.scss']
})
export class ButtonHideParentComponent {
@Input() showIcon: boolean;
@Input() label:string;
<button [ngClass]="class" [disabled]="disabled">
<ng-content></ng-content>
<ces-svg *ngIf="icon" [type]="icon"></ces-svg>
<span *ngIf="label">{{ label }}</span>
</button>