diff --git a/bizmatch/src/app/components/base-input/base-input.component.ts b/bizmatch/src/app/components/base-input/base-input.component.ts index 9cc1b09..bcfb2ed 100644 --- a/bizmatch/src/app/components/base-input/base-input.component.ts +++ b/bizmatch/src/app/components/base-input/base-input.component.ts @@ -19,6 +19,7 @@ export abstract class BaseInputComponent implements ControlValueAccessor { @Input() label: string = ''; // @Input() id: string = ''; @Input() name: string = ''; + isTooltipVisible = false; constructor(protected validationMessagesService: ValidationMessagesService) {} ngOnInit() { this.subscription = this.validationMessagesService.messages$.subscribe(() => { @@ -51,4 +52,9 @@ export abstract class BaseInputComponent implements ControlValueAccessor { this.validationMessage = this.validationMessagesService.getMessage(this.name); } setDisabledState?(isDisabled: boolean): void {} + toggleTooltip(event: Event) { + event.preventDefault(); + event.stopPropagation(); + this.isTooltipVisible = !this.isTooltipVisible; + } } diff --git a/bizmatch/src/app/components/tooltip/tooltip.component.ts b/bizmatch/src/app/components/tooltip/tooltip.component.ts index d83d1db..38baf8e 100644 --- a/bizmatch/src/app/components/tooltip/tooltip.component.ts +++ b/bizmatch/src/app/components/tooltip/tooltip.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { Component, Input } from '@angular/core'; +import { Component, Input, SimpleChanges } from '@angular/core'; import { initFlowbite } from 'flowbite'; @Component({ @@ -9,11 +9,36 @@ import { initFlowbite } from 'flowbite'; templateUrl: './tooltip.component.html', }) export class TooltipComponent { - @Input() id; - @Input() text; + @Input() id: string; + @Input() text: string; + @Input() isVisible: boolean = false; + ngOnInit() { + this.initializeTooltip(); + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['isVisible']) { + this.updateTooltipVisibility(); + } + } + + private initializeTooltip() { setTimeout(() => { initFlowbite(); }, 10); } + + private updateTooltipVisibility() { + const tooltipElement = document.getElementById(this.id); + if (tooltipElement) { + if (this.isVisible) { + tooltipElement.classList.remove('invisible', 'opacity-0'); + tooltipElement.classList.add('visible', 'opacity-100'); + } else { + tooltipElement.classList.remove('visible', 'opacity-100'); + tooltipElement.classList.add('invisible', 'opacity-0'); + } + } + } } diff --git a/bizmatch/src/app/components/validated-city/validated-city.component.html b/bizmatch/src/app/components/validated-city/validated-city.component.html index b1b1f98..a16d228 100644 --- a/bizmatch/src/app/components/validated-city/validated-city.component.html +++ b/bizmatch/src/app/components/validated-city/validated-city.component.html @@ -4,10 +4,12 @@