Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 917e24f

Browse files
Merge pull request #987 from deckgo/click-to-open-bottom-sheet
feat: open bottom sheet on click on indicator
2 parents 12098b8 + c777313 commit 917e24f

File tree

2 files changed

+54
-48
lines changed

2 files changed

+54
-48
lines changed

studio/src/app/components/editor/actions/footer/app-bottom-sheet/app-bottom-sheet.scss

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,27 @@ app-bottom-sheet {
4141
padding-top: 32px;
4242
}
4343

44-
> div.sheet-indicator {
44+
> button.sheet-indicator {
4545
position: absolute;
46-
top: 8px;
46+
top: 0;
4747
left: 50%;
48-
transform: translate(0, -50%);
49-
width: 16px;
50-
height: 4px;
51-
background: rgba(var(--ion-color-light-rgb), 0.4);
52-
border-radius: 16px;
48+
49+
padding: 8px;
50+
51+
outline: none;
52+
border: none;
53+
54+
background: transparent;
55+
56+
> div {
57+
display: block;
58+
59+
background: rgba(var(--ion-color-light-rgb), 0.4);
60+
border-radius: 16px;
61+
62+
width: 16px;
63+
height: 4px;
64+
}
5365
}
5466
}
5567
}

studio/src/app/components/editor/actions/footer/app-bottom-sheet/app-bottom-sheet.tsx

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,61 +40,43 @@ export class AppBottomSheet {
4040
}
4141

4242
private initWindowResize() {
43-
if (window) {
44-
window.addEventListener('resize', debounce(this.onWindowResize));
45-
}
43+
window?.addEventListener('resize', debounce(this.onWindowResize));
4644
}
4745

4846
private removeWindowResize() {
49-
if (window) {
50-
window.removeEventListener('resize', debounce(this.onWindowResize));
51-
}
47+
window?.removeEventListener('resize', debounce(this.onWindowResize));
5248
}
5349

5450
private onWindowResize = async () => {
5551
await this.initSize();
5652
};
5753

58-
private initSize(): Promise<void> {
59-
return new Promise<void>((resolve) => {
60-
this.bottomSheetTop = this.bottomSheetMinHeight;
61-
this.heightOffset = this.content.offsetHeight || this.el.offsetHeight;
62-
this.contentHeight = window.innerHeight || screen.height;
63-
64-
resolve();
65-
});
54+
private async initSize() {
55+
this.bottomSheetTop = this.bottomSheetMinHeight;
56+
this.heightOffset = this.content.offsetHeight || this.el.offsetHeight;
57+
this.contentHeight = window.innerHeight || screen.height;
6658
}
6759

68-
private init(): Promise<void> {
69-
return new Promise<void>((resolve) => {
70-
if (!this.container) {
71-
resolve();
72-
return;
73-
}
74-
75-
this.container.addEventListener('mousedown', this.startEvent, {passive: false});
76-
this.container.addEventListener('touchstart', this.startEvent, {passive: false});
77-
document.addEventListener('mouseup', this.endEvent, {passive: false});
78-
document.addEventListener('touchend', this.endEvent, {passive: false});
60+
private async init() {
61+
if (!this.container) {
62+
return;
63+
}
7964

80-
resolve();
81-
});
65+
this.container.addEventListener('mousedown', this.startEvent, {passive: false});
66+
this.container.addEventListener('touchstart', this.startEvent, {passive: false});
67+
document.addEventListener('mouseup', this.endEvent, {passive: false});
68+
document.addEventListener('touchend', this.endEvent, {passive: false});
8269
}
8370

84-
private destroy(): Promise<void> {
85-
return new Promise<void>((resolve) => {
86-
if (!this.container) {
87-
resolve();
88-
return;
89-
}
90-
91-
this.container.removeEventListener('mousedown', this.startEvent, true);
92-
this.container.removeEventListener('touchstart', this.startEvent, true);
93-
document.removeEventListener('mouseup', this.endEvent, true);
94-
document.removeEventListener('touchend', this.endEvent, true);
71+
private async destroy() {
72+
if (!this.container) {
73+
return;
74+
}
9575

96-
resolve();
97-
});
76+
this.container.removeEventListener('mousedown', this.startEvent, true);
77+
this.container.removeEventListener('touchstart', this.startEvent, true);
78+
document.removeEventListener('mouseup', this.endEvent, true);
79+
document.removeEventListener('touchend', this.endEvent, true);
9880
}
9981

10082
private startEvent = ($event: MouseEvent | TouchEvent) => {
@@ -138,6 +120,16 @@ export class AppBottomSheet {
138120
this.sheetChanged.emit(this.bottomSheetTop === this.bottomSheetMinHeight ? 'close' : 'open');
139121
}
140122

123+
private toggle($event: UIEvent) {
124+
$event.stopPropagation();
125+
126+
this.bottomSheetTop = this.bottomSheetTop === this.bottomSheetMinHeight ? this.content.offsetHeight : this.bottomSheetMinHeight;
127+
128+
this.startY = undefined;
129+
130+
this.sheetChanged.emit(this.bottomSheetTop === this.bottomSheetMinHeight ? 'close' : 'open');
131+
}
132+
141133
render() {
142134
return (
143135
<Host
@@ -146,7 +138,9 @@ export class AppBottomSheet {
146138
'--contentheight': `${this.contentHeight}px`,
147139
}}>
148140
<div class="container" ref={(el) => (this.container = el)}>
149-
<div class="sheet-indicator"></div>
141+
<button class="sheet-indicator" onClick={($event: UIEvent) => this.toggle($event)}>
142+
<div></div>
143+
</button>
150144
<div class="content" ref={(el) => (this.content = el)}>
151145
<slot></slot>
152146
</div>

0 commit comments

Comments
 (0)