-
-
Save yokoishioka/8234eb4484f3dd29988b440f6f8baf46 to your computer and use it in GitHub Desktop.
Angular SVG component
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
<svg [ngClass]="{ 'drop-shadow' : dropShadow }" [class]="size ? size : ''" xmlns="http://www.w3.org/2000/svg" | |
xmlns:xlink="http://www.w3.org/1999/xlink"> | |
<use [attr.xlink:href]="link" [attr.href]="link" /> | |
</svg> |
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
@import "variables"; | |
svg { | |
width: inherit; | |
height: inherit; | |
} | |
.xs { | |
width: $icon-xs-sm; | |
height: $icon-xs-sm; | |
} | |
.sm { | |
width: $icon-sm-sm; | |
height: $icon-sm-sm; | |
} | |
.md { | |
width: $icon-md-sm; | |
height: $icon-md-sm; | |
} | |
.lg { | |
width: $icon-lg-sm; | |
height: $icon-lg-sm; | |
} | |
@media (min-width: $breakpoint-md) { | |
.xs { | |
width: $icon-xs-md; | |
height: $icon-xs-md; | |
} | |
.sm { | |
width: $icon-sm-md; | |
height: $icon-sm-md; | |
} | |
.md { | |
width: $icon-md-md; | |
height: $icon-md-md; | |
} | |
.lg { | |
width: $icon-lg-md; | |
height: $icon-lg-md; | |
} | |
} |
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
import { Component, Input, OnInit } from '@angular/core'; | |
import { SvgSize } from './svg'; | |
@Component({ | |
selector: 'ces-svg', | |
templateUrl: './svg.component.html', | |
styleUrls: ['./svg.component.scss'] | |
}) | |
export class SvgComponent implements OnInit { | |
link: string = ''; | |
@Input() size: SvgSize | undefined; | |
@Input() type: string = ''; | |
@Input() dropShadow: boolean = true; | |
constructor() { | |
} | |
ngOnInit(): void { | |
this.link = `/assets/images/svgs/${this.type}.svg#${this.type}`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment