I have created an Angular component with the following definition:
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'rdc-dynamic-icon-button',
templateUrl: './dynamic-icon-button.component.html',
styleUrls: ['./dynamic-icon-button.component.scss']
})
export class DynamicIconButtonComponent {
@Input() label = '';
@Input() icon = '';
@Input() fileType = '';
@Output() click = new EventEmitter<any>();
onClick() {
this.click.emit();
}
}
This is how the component template looks like:
<button (click)="onClick()">
<img src="../../../assets/icons/{{icon}}.{{fileType}}" />
<span class="buttonLabel">{{ label }}</span>
</button>
The CSS for the button is as follows:
button {
font-size: 0.8em;
width: 150px;
height: 45px;
background-color: white;
color: #0066cc;
border: 1px solid #0066cc;
border-radius: 30px;
padding: 1em;
}
// Icon within the button
img {
padding-right: 0.5em;
position: relative;
bottom: 5px;
}
Currently, I have used this button component twice in a row, each with a different icon: https://i.stack.imgur.com/lcjNe.png
However, the alignment of the second button's heart icon seems to be off due to bottom: 5px
being applied universally. How can I adjust the CSS property only for the second button to better align the heart icon? Here is the template code for reference:
<rdc-dynamic-icon-button
label="Share this page"
icon="share_icon"
fileType="svg"
class="results-descr-button1"
></rdc-dynamic-icon-button>
<rdc-dynamic-icon-button
label="Save this page"
icon="fill-1"
fileType="svg"
class="results-descr-button2"
></rdc-dynamic-icon-button>
A colleague mentioned using [ngStyle], but based on my research, it appears that it can only be used to style specific HTML tags and not CSS selectors within an Angular component. Please correct me if I am mistaken.