Skip to content

Commit a8b47b7

Browse files
committed
fix: docs examples
1 parent 8be5fb1 commit a8b47b7

File tree

15 files changed

+91
-30
lines changed

15 files changed

+91
-30
lines changed

apps/docs/src/app/components/live-example-viewer/docs-live-example-viewer.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.docs-live-example__example {
1+
.docs-live-example__example:not(.docs-live-example__example_notification-center-popover) {
22
padding: var(--kbq-size-xl);
33

44
overflow: auto;

packages/components/core/pop-up/pop-up-trigger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ export abstract class KbqPopUpTrigger<T> implements OnInit, OnDestroy {
116116

117117
stickToWindow: PopUpPlacements.Top | PopUpPlacements.Right | PopUpPlacements.Bottom | PopUpPlacements.Left | string;
118118

119+
container: HTMLElement;
120+
119121
abstract disabled: boolean;
120122
abstract arrow: boolean;
121123
abstract trigger: string;

packages/components/core/pop-up/pop-up.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,33 @@ export abstract class KbqPopUp implements OnDestroy {
175175

176176
this.arrow = false;
177177

178-
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, this.trigger.stickToWindow, 0);
179-
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, oppositeSide, 'unset');
178+
if (this.trigger.container) {
179+
const width = this.elementRef.nativeElement.getBoundingClientRect().width;
180+
const height = this.elementRef.nativeElement.getBoundingClientRect().height;
181+
182+
if (this.trigger.stickToWindow === PopUpPlacements.Right) {
183+
const left = this.trigger.container.getBoundingClientRect().right - width;
184+
185+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'left', `${left}px`);
186+
} else if (this.trigger.stickToWindow === PopUpPlacements.Left) {
187+
const left = this.trigger.container.getBoundingClientRect().left;
188+
189+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'left', `${left}px`);
190+
} else if (this.trigger.stickToWindow === PopUpPlacements.Top) {
191+
const top = this.trigger.container.getBoundingClientRect().top;
192+
193+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'top', `${top}px`);
194+
} else if (this.trigger.stickToWindow === PopUpPlacements.Bottom) {
195+
const top = this.trigger.container.getBoundingClientRect().bottom - height;
196+
197+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'top', `${top}px`);
198+
}
199+
200+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'right', 'unset');
201+
// this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, 'bottom', 'unset');
202+
} else {
203+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, this.trigger.stickToWindow, 0);
204+
this.renderer.setStyle(this.trigger.overlayRef?.overlayElement, oppositeSide, 'unset');
205+
}
180206
}
181207
}

packages/components/notification-center/notification-center.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ export class KbqNotificationCenterTrigger
331331
| PopUpPlacements.Left
332332
| string;
333333

334+
@Input() container: HTMLElement;
335+
334336
/** @docs-private */
335337
get hasClickTrigger(): boolean {
336338
return this.trigger.includes(PopUpTriggers.Click);

packages/docs-examples/components/notification-center/notification-center-empty/notification-center-empty-example.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@
8080
#trigger="kbqNotificationCenterTrigger"
8181
kbq-navbar-ic-item
8282
kbqNotificationCenterTrigger
83+
[stickToWindow]="'bottom'"
84+
[container]="container"
8385
[popoverHeight]="'500px'"
84-
[kbqNotificationCenterPanelClass]="'example-notification-center-panel'"
8586
>
8687
<i kbq-icon="kbq-bell_16"></i>
8788
<div kbqNavbarIcTitle>Notifications</div>

packages/docs-examples/components/notification-center/notification-center-empty/notification-center-empty-example.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
55
import { LuxonDateModule } from '@koobiq/angular-luxon-adapter/adapter';
66
import { KbqBadgeModule } from '@koobiq/components/badge';
77
import { KbqButtonModule, KbqButtonStyles } from '@koobiq/components/button';
8-
import { KbqComponentColors, KbqFormattersModule, PopUpPlacements, ThemeService } from '@koobiq/components/core';
8+
import {
9+
KbqComponentColors,
10+
KbqFormattersModule,
11+
kbqInjectNativeElement,
12+
PopUpPlacements,
13+
ThemeService
14+
} from '@koobiq/components/core';
915
import { KbqDropdownModule } from '@koobiq/components/dropdown';
1016
import { KbqEmptyStateModule } from '@koobiq/components/empty-state';
1117
import { KbqIconModule } from '@koobiq/components/icon';
@@ -40,11 +46,6 @@ enum NavbarIcItems {
4046
standalone: true,
4147
selector: 'notification-center-empty-example',
4248
templateUrl: 'notification-center-empty-example.html',
43-
styles: `
44-
::ng-deep .example-notification-center-panel {
45-
margin-top: -98px;
46-
}
47-
`,
4849
imports: [
4950
KbqNotificationCenterModule,
5051
KbqNavbarIcModule,
@@ -63,6 +64,7 @@ enum NavbarIcItems {
6364
})
6465
export class NotificationCenterEmptyExample {
6566
readonly notificationCenterService = inject(KbqNotificationCenterService);
67+
container = kbqInjectNativeElement();
6668

6769
protected readonly currentTheme = toSignal(
6870
inject(ThemeService, { optional: true })?.current.pipe(

packages/docs-examples/components/notification-center/notification-center-error/notification-center-error-example.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@
8585
#trigger="kbqNotificationCenterTrigger"
8686
kbq-navbar-ic-item
8787
kbqNotificationCenterTrigger
88+
[stickToWindow]="'bottom'"
89+
[container]="container"
8890
[popoverHeight]="'500px'"
89-
[kbqNotificationCenterPanelClass]="'example-notification-center-panel'"
9091
>
9192
<i kbq-icon="kbq-bell_16"></i>
9293
<div kbqNavbarIcTitle>Notifications</div>

packages/docs-examples/components/notification-center/notification-center-error/notification-center-error-example.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
55
import { LuxonDateModule } from '@koobiq/angular-luxon-adapter/adapter';
66
import { KbqBadgeModule } from '@koobiq/components/badge';
77
import { KbqButtonModule, KbqButtonStyles } from '@koobiq/components/button';
8-
import { KbqComponentColors, KbqFormattersModule, PopUpPlacements, ThemeService } from '@koobiq/components/core';
8+
import {
9+
KbqComponentColors,
10+
KbqFormattersModule,
11+
kbqInjectNativeElement,
12+
PopUpPlacements,
13+
ThemeService
14+
} from '@koobiq/components/core';
915
import { KbqDropdownModule } from '@koobiq/components/dropdown';
1016
import { KbqEmptyStateModule } from '@koobiq/components/empty-state';
1117
import { KbqIconModule } from '@koobiq/components/icon';
@@ -42,11 +48,6 @@ enum NavbarIcItems {
4248
standalone: true,
4349
selector: 'notification-center-error-example',
4450
templateUrl: 'notification-center-error-example.html',
45-
styles: `
46-
::ng-deep .example-notification-center-panel {
47-
margin-top: -98px;
48-
}
49-
`,
5051
imports: [
5152
KbqNotificationCenterModule,
5253
KbqNavbarIcModule,
@@ -66,6 +67,7 @@ enum NavbarIcItems {
6667
})
6768
export class NotificationCenterErrorExample {
6869
notificationService = inject(KbqNotificationCenterService);
70+
container = kbqInjectNativeElement();
6971

7072
@ViewChild('actionsTemplate') actionsTemplateRef: TemplateRef<any>;
7173

packages/docs-examples/components/notification-center/notification-center-overview/notification-center-overview-example.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@
9292
#trigger="kbqNotificationCenterTrigger"
9393
kbq-navbar-ic-item
9494
kbqNotificationCenterTrigger
95+
[stickToWindow]="'bottom'"
96+
[container]="container"
9597
[popoverHeight]="'500px'"
96-
[kbqNotificationCenterPanelClass]="'example-notification-center-panel'"
9798
>
9899
<i kbq-icon="kbq-bell_16"></i>
99100
<div kbqNavbarIcTitle>Notifications</div>

packages/docs-examples/components/notification-center/notification-center-overview/notification-center-overview-example.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
1313
import { LuxonDateModule } from '@koobiq/angular-luxon-adapter/adapter';
1414
import { KbqBadgeModule } from '@koobiq/components/badge';
1515
import { KbqButtonModule, KbqButtonStyles } from '@koobiq/components/button';
16-
import { KbqComponentColors, KbqFormattersModule, PopUpPlacements, ThemeService } from '@koobiq/components/core';
16+
import {
17+
KbqComponentColors,
18+
KbqFormattersModule,
19+
kbqInjectNativeElement,
20+
PopUpPlacements,
21+
ThemeService
22+
} from '@koobiq/components/core';
1723
import { KbqDropdownModule } from '@koobiq/components/dropdown';
1824
import { KbqEmptyStateModule } from '@koobiq/components/empty-state';
1925
import { KbqIconModule } from '@koobiq/components/icon';
2026
import { KbqLinkModule } from '@koobiq/components/link';
27+
import { KbqNavbarModule } from '@koobiq/components/navbar';
2128
import { KbqNavbarIcModule } from '@koobiq/components/navbar-ic';
2229
import { KbqNotificationCenterModule, KbqNotificationCenterService } from '@koobiq/components/notification-center';
2330
import { KbqToastStyle } from '@koobiq/components/toast';
@@ -50,11 +57,6 @@ enum NavbarIcItems {
5057
standalone: true,
5158
selector: 'notification-center-overview-example',
5259
templateUrl: 'notification-center-overview-example.html',
53-
styles: `
54-
::ng-deep .example-notification-center-panel {
55-
margin-top: -98px;
56-
}
57-
`,
5860
imports: [
5961
KbqNotificationCenterModule,
6062
KbqNavbarIcModule,
@@ -67,11 +69,13 @@ enum NavbarIcItems {
6769
AsyncPipe,
6870
KbqLinkModule,
6971
LuxonDateModule,
70-
KbqFormattersModule
72+
KbqFormattersModule,
73+
KbqNavbarModule
7174
]
7275
})
7376
export class NotificationCenterOverviewExample implements AfterViewInit {
7477
notificationService = inject(KbqNotificationCenterService);
78+
container = kbqInjectNativeElement();
7579

7680
@ViewChild('actionsTemplate') actionsTemplateRef!: TemplateRef<any>;
7781
@ViewChild('captionTemplate') captionTemplateRef: TemplateRef<any>;

0 commit comments

Comments
 (0)