Skip to content

Instantly share code, notes, and snippets.

@realtomaszkula
Created August 6, 2018 08:37
Show Gist options
  • Save realtomaszkula/21a8222d70d09a16b883c211dbd58bc6 to your computer and use it in GitHub Desktop.
Save realtomaszkula/21a8222d70d09a16b883c211dbd58bc6 to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-gradient-button',
template: `
<span class="gradient" [ngStyle]="gradientStyle"></span>
<span class="content">
<ng-content></ng-content>
</span>
`,
styles: [
`
// ..
.gradient {
position: absolute;
background: radial-gradient(circle closest-side, #9b27af, transparent);
transform: translate(-50%, -50%);
transition: width 0.2s ease, height 0.2s ease;
}
`
]
})
export class GradientButtonComponent {
// ..
get gradientStyle() {
const top = this.gradientTop;
const left = this.gradientLeft;
const gradientRadius = this.isGradientVisible ? this.gradientRadius : 0;
return {
'height.px': gradientRadius,
'width.px': gradientRadius,
'top.px': top,
'left.px': left
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment