src/app/components/use-button/use-button.component.ts
Displays a button with custom text
selector | ccf-use-button |
styleUrls | ./use-button.component.scss |
templateUrl | ./use-button.component.html |
Inputs |
buttonData | |
Type : UseButton
|
|
Details of the button |
import { Component, Input } from '@angular/core';
import { UseButton } from './use-button';
/** Displays a button with custom text */
@Component({
selector: 'ccf-use-button',
templateUrl: './use-button.component.html',
styleUrls: ['./use-button.component.scss'],
})
export class UseButtonComponent {
/** Details of the button */
@Input() buttonData!: UseButton;
}
<a
*ngIf="buttonData.url; else route"
mat-raised-button
target="_blank"
[attr.href]="buttonData.url"
[attr.download]="buttonData.icon === 'download' ? '' : null"
disableRipple
>
<span *ngIf="buttonData.icon" class="material-symbols-outlined icon">{{ buttonData.icon }}</span>
{{ buttonData.text.trim() }}
</a>
<ng-template #route>
<a mat-raised-button [routerLink]="['', buttonData.route]">
<span *ngIf="buttonData.icon" class="material-symbols-outlined icon">{{ buttonData.icon }}</span>
{{ buttonData.text.trim() }}
</a>
</ng-template>
./use-button.component.scss
:host {
display: block;
width: fit-content;
.mat-mdc-raised-button:hover {
background: rgba(103, 80, 164, 0.08);
}
.mat-mdc-raised-button:focus,
.mat-mdc-raised-button:active {
background: rgba(103, 80, 164, 0.12);
}
.mat-mdc-raised-button:disabled {
background: rgba(29, 27, 32, 0.12);
}
.mat-mdc-raised-button {
font-weight: 500;
font-size: 1.125rem;
padding: 0rem 1.5rem;
margin-left: 1px;
min-width: 124px;
color: #444c65;
border-radius: 6.25rem;
height: 3.5rem;
background-color: #f7f2fa;
box-shadow:
0px 1px 2px rgba(0, 0, 0, 0.3),
0px 1px 3px 1px rgba(0, 0, 0, 0.15);
white-space: normal;
letter-spacing: 0;
line-height: 1.6875rem;
}
::ng-deep .mat-mdc-raised-button .mdc-button__label {
display: flex;
align-items: center;
}
.icon {
margin-right: 5px;
}
a:-webkit-any-link {
text-decoration: unset !important;
}
@media (max-width: 26.75rem) {
.mat-mdc-raised-button {
width: calc(100vw - 2.5rem);
line-height: 1.25rem;
padding: 0.5rem 1rem;
}
}
}