styles
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Component, Input, ElementRef, Renderer2, HostListener } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { IconComponent } from '../icon/icon.component';
|
||||
|
||||
@@ -7,21 +7,48 @@ type ButtonColor = 'primary' | 'secondary' | 'stroked' | 'flat' | 'icon' | 'icon
|
||||
@Component({
|
||||
selector: 'app-button',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
IconComponent
|
||||
],
|
||||
imports: [CommonModule, IconComponent],
|
||||
templateUrl: './button.component.html',
|
||||
styleUrl: './button.component.css'
|
||||
})
|
||||
export class ButtonComponent {
|
||||
@Input() color: ButtonColor = 'primary';
|
||||
@Input() type: 'button' | 'submit' = 'button';
|
||||
@Input() buttonType: ButtonColor = 'primary';
|
||||
@Input() submitType: 'button' | 'submit' = 'button';
|
||||
@Input() disabled = false;
|
||||
@Input() fullWidth = false;
|
||||
|
||||
@Input() tooltip: string | null = null;
|
||||
@Input() iconName: string | null = null;
|
||||
// --- HIER IST DIE KORREKTUR: Umbenennung zu svgColor ---
|
||||
@Input() svgColor: string | null = null; // Farbe des SVG-Inhalts im Button
|
||||
@Input() svgColor: string | null = null;
|
||||
|
||||
constructor(private el: ElementRef, private renderer: Renderer2) {}
|
||||
|
||||
// HostListener fängt Klick-Events direkt auf dem Host-Element (<app-button>) ab
|
||||
@HostListener('click', ['$event'])
|
||||
onClick(event: MouseEvent) {
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = this.el.nativeElement.querySelector('.btn');
|
||||
if (!button) return;
|
||||
|
||||
// Entferne alte Ripple-Effekte
|
||||
const existingRipple = button.querySelector('.ripple');
|
||||
if (existingRipple) {
|
||||
existingRipple.remove();
|
||||
}
|
||||
|
||||
// Erzeuge den Ripple-Effekt
|
||||
const circle = this.renderer.createElement('span');
|
||||
const diameter = Math.max(button.clientWidth, button.clientHeight);
|
||||
const radius = diameter / 2;
|
||||
|
||||
this.renderer.setStyle(circle, 'width', `${diameter}px`);
|
||||
this.renderer.setStyle(circle, 'height', `${diameter}px`);
|
||||
this.renderer.setStyle(circle, 'left', `${event.clientX - button.offsetLeft - radius}px`);
|
||||
this.renderer.setStyle(circle, 'top', `${event.clientY - button.offsetTop - radius}px`);
|
||||
this.renderer.addClass(circle, 'ripple');
|
||||
|
||||
this.renderer.appendChild(button, circle);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user