-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: nested popover #2649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: nested popover #2649
Changes from 27 commits
48247e8
57242bf
2609ac5
1c7925d
86142f9
6be9cf2
44a63ac
77d0dcd
04d2948
2f9d0fb
9821a3f
8e65390
cef51c7
6871c0a
de7c00e
d19665c
6502e71
6dd5141
1c2dc42
cf222e8
b761e4a
f36cb86
da00f16
fe4cdf6
b056297
ce35b59
75d8476
7fab576
0bce02c
b13f8c0
dcdb8fb
c2a7c8f
acd2710
b5fbccb
325aeac
5942b18
7611e0a
03aa22c
2d9d73a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Fired when window is resized | ||
*/ | ||
export const WindowResize = 'window resize'; | ||
|
||
/** | ||
* Payload that will be passed with the event | ||
*/ | ||
export interface WindowResizePayload { | ||
/** | ||
* True, if new window size is mobile | ||
neSpecc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
isMobile: boolean; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ import { I18nInternalNS } from '../../i18n/namespace-internal'; | |
import Flipper from '../../flipper'; | ||
import { TunesMenuConfigItem } from '../../../../types/tools'; | ||
import { resolveAliases } from '../../utils/resolve-aliases'; | ||
import Popover, { PopoverEvent } from '../../utils/popover'; | ||
import { type Popover, PopoverDesktop, PopoverMobile } from '../../utils/popover'; | ||
import { PopoverEvent } from '../../utils/popover/popover.types'; | ||
import { isMobileScreen } from '../../utils'; | ||
|
||
/** | ||
* HTML Elements that used for BlockSettings | ||
|
@@ -27,8 +29,6 @@ interface BlockSettingsNodes { | |
export default class BlockSettings extends Module<BlockSettingsNodes> { | ||
/** | ||
* Module Events | ||
* | ||
* @returns {{opened: string, closed: string}} | ||
*/ | ||
public get events(): { opened: string; closed: string } { | ||
return { | ||
|
@@ -56,8 +56,12 @@ export default class BlockSettings extends Module<BlockSettingsNodes> { | |
* | ||
* @todo remove once BlockSettings becomes standalone non-module class | ||
*/ | ||
public get flipper(): Flipper { | ||
return this.popover?.flipper; | ||
public get flipper(): Flipper | undefined { | ||
if (this.popover === null) { | ||
return; | ||
} | ||
|
||
return 'flipper' in this.popover ? this.popover?.flipper : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah, there will be TypeScript error. Property |
||
} | ||
|
||
/** | ||
|
@@ -67,9 +71,9 @@ export default class BlockSettings extends Module<BlockSettingsNodes> { | |
|
||
/** | ||
* Popover instance. There is a util for vertical lists. | ||
neSpecc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* Null until popover is not initialized | ||
*/ | ||
private popover: Popover | undefined; | ||
|
||
private popover: Popover | null = null; | ||
|
||
/** | ||
* Panel with block settings with 2 sections: | ||
|
@@ -89,6 +93,7 @@ export default class BlockSettings extends Module<BlockSettingsNodes> { | |
*/ | ||
public destroy(): void { | ||
this.removeAllNodes(); | ||
this.listeners.destroy(); | ||
} | ||
|
||
/** | ||
|
@@ -118,7 +123,10 @@ export default class BlockSettings extends Module<BlockSettingsNodes> { | |
|
||
/** Tell to subscribers that block settings is opened */ | ||
this.eventsDispatcher.emit(this.events.opened); | ||
this.popover = new Popover({ | ||
|
||
const PopoverClass = isMobileScreen() ? PopoverMobile : PopoverDesktop; | ||
|
||
this.popover = new PopoverClass({ | ||
searchable: true, | ||
items: tunesItems.map(tune => this.resolveTuneAliases(tune)), | ||
customContent: customHtmlTunesContainer, | ||
|
@@ -132,15 +140,15 @@ export default class BlockSettings extends Module<BlockSettingsNodes> { | |
|
||
this.popover.on(PopoverEvent.Close, this.onPopoverClose); | ||
|
||
this.nodes.wrapper.append(this.popover.getElement()); | ||
this.nodes.wrapper?.append(this.popover.getElement()); | ||
|
||
this.popover.show(); | ||
} | ||
|
||
/** | ||
* Returns root block settings element | ||
*/ | ||
public getElement(): HTMLElement { | ||
public getElement(): HTMLElement | undefined { | ||
return this.nodes.wrapper; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.