Skip to content

Commit 9999b41

Browse files
Remove sendAction from side-hover-panel & ts format
1 parent 5e9cebb commit 9999b41

File tree

5 files changed

+96
-74
lines changed

5 files changed

+96
-74
lines changed

addon/components/drag-and-drop/component.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@ export default Component.extend({
1717
if (this._onDragElement && this.onDragClass) {
1818
return this.onDragClass;
1919
}
20-
21-
return;
2220
}),
2321

2422
dragElementInZoneClass: computed('_onDragElementInZone', 'onDragInZoneClass', function () {
2523
if (this._onDragElementInZone && this.onDragInZoneClass) {
2624
return this.onDragInZoneClass;
2725
}
28-
29-
return;
3026
}),
3127

3228
didInsertElement() {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class={{this.computedClassNames}} {{did-insert this.initialize}} {{will-destroy this.teardown}} ...attributes>
2+
<div role="button" class="panel-backdrop hidden" {{on 'click' this.backdrop}}></div>
3+
<div class="hover-panel">{{yield}}</div>
4+
</div>
5+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import Component from '@glimmer/component';
2+
import { action } from '@ember/object';
3+
4+
interface SideHoverPanelArgs {
5+
side: string;
6+
stickTo: string;
7+
width: string;
8+
height: string;
9+
disableScrolling: boolean;
10+
isOverContent: boolean;
11+
shouldAnimate: boolean;
12+
backdropAction: () => void;
13+
}
14+
15+
export default class SideHoverPanel extends Component<SideHoverPanelArgs> {
16+
hoverPanel: HTMLElement | null = null;
17+
panelBackdrop: HTMLElement | null = null;
18+
19+
get computedClassNames(): string {
20+
let classes = ['__side-hover-panel'];
21+
if (this.args.isOverContent) {
22+
classes.push('__side-hover-panel--over-content');
23+
}
24+
return classes.join(' ');
25+
}
26+
27+
get backdropAction(): () => void {
28+
return this.args.backdropAction;
29+
}
30+
31+
get side(): string {
32+
return this.args.side ?? 'right';
33+
}
34+
35+
get shouldAnimate(): boolean {
36+
return this.args.shouldAnimate ?? true;
37+
}
38+
39+
get width(): string {
40+
return this.args.width ?? '100%';
41+
}
42+
43+
get height(): string {
44+
return this.args.height ?? '100%';
45+
}
46+
47+
get disableScrolling(): boolean {
48+
return this.args.disableScrolling ?? false;
49+
}
50+
51+
get stickTo(): string {
52+
return this.args.stickTo ?? 'right';
53+
}
54+
55+
initialize(element: HTMLElement) {
56+
this.hoverPanel = element.querySelector('.hover-panel')! as HTMLElement;
57+
this.hoverPanel.classList.add(this.side + '_side');
58+
this.hoverPanel.classList.add(this.stickTo + '_align');
59+
60+
if (this.shouldAnimate) {
61+
this.hoverPanel.classList.add('animate');
62+
}
63+
64+
this.hoverPanel.classList.add(this.side + '_transform');
65+
66+
if (this.backdropAction != null) {
67+
this.panelBackdrop = element.querySelector('.panel-backdrop');
68+
this.panelBackdrop!.classList.remove('hidden');
69+
}
70+
71+
this.hoverPanel.style.width = this.width;
72+
this.hoverPanel.style.height = this.height;
73+
74+
if (this.disableScrolling) {
75+
document.querySelector('body')?.classList.add('disable-scrolling');
76+
}
77+
}
78+
79+
teardown() {
80+
this.hoverPanel?.remove();
81+
this.panelBackdrop?.classList.add('hidden');
82+
if (this.disableScrolling) {
83+
document.querySelector('body')?.classList.remove('disable-scrolling');
84+
}
85+
}
86+
87+
@action
88+
backdrop(): void {
89+
this.args.backdropAction?.();
90+
}
91+
}

addon/components/layout/side-hover-panel/component.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

addon/components/layout/side-hover-panel/template.hbs

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)