import { Component, ViewChild, ElementRef, signal } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PopoverComponent } from '../../../../../ui-essentials/src/lib/components/overlays/popover'; type PopoverPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'; type PopoverSize = 'sm' | 'md' | 'lg'; type PopoverVariant = 'default' | 'elevated' | 'floating' | 'menu' | 'tooltip'; type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual'; @Component({ selector: 'ui-popover-demo', standalone: true, imports: [CommonModule, PopoverComponent], template: `
A flexible popover component with multiple positioning options, trigger types, and variants. Perfect for dropdowns, tooltips, context menus, and floating content.
This demonstrates the {{ variant }} styling variant of the popover component.
Positioned {{ position.value }} relative to trigger.
This popover appears when the input gains focus and helps guide the user.
This popover automatically adjusts its position to stay within the viewport.
Current Position: {{ currentAutoPosition() || 'right' }}
This popover has a backdrop and prevents body scroll. Click the backdrop or press ESC to close.
<!-- Basic Usage -->
<button #trigger>Click me</button>
<ui-popover [triggerElement]="trigger" position="bottom" trigger="click">
<p>Popover content goes here</p>
</ui-popover>
<!-- Advanced Configuration -->
<ui-popover
[triggerElement]="myTrigger"
position="bottom-start"
variant="menu"
trigger="click"
[autoPosition]="true"
[showArrow]="true"
(visibleChange)="onPopoverToggle($event)">
<div class="custom-menu">...</div>
</ui-popover>