mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 16:04:55 +08:00
fe16633a0c
menus and tooltips are now appended to their own portals. The service are the only responsible for managing the instances, prior to this commit, services could manage one instance, but the DMenu and DTooltip components could also take over which could cause unexpected states. This change also allows nested menus/tooltips. Other notable changes: - few months ago core copied the CloseOnClickOutside modifier of float-kit without removing the float-kit one, this commit now only use the core one. - the close function is now trully async - the close function accepts an instance or an identifier as parameter
51 lines
1.5 KiB
Plaintext
51 lines
1.5 KiB
Plaintext
import Component from "@glimmer/component";
|
|
import { inject as service } from "@ember/service";
|
|
import { and } from "truth-helpers";
|
|
import DModal from "discourse/components/d-modal";
|
|
import DFloatBody from "float-kit/components/d-float-body";
|
|
|
|
export default class DInlineFloat extends Component {
|
|
@service site;
|
|
|
|
<template>
|
|
{{#if @instance.expanded}}
|
|
{{#if (and this.site.mobileView @instance.options.modalForMobile)}}
|
|
<DModal
|
|
@closeModal={{@instance.close}}
|
|
@hideHeader={{true}}
|
|
data-identifier={{@instance.options.identifier}}
|
|
data-content
|
|
>
|
|
{{#if @instance.options.component}}
|
|
<@instance.options.component
|
|
@data={{@instance.options.data}}
|
|
@close={{@instance.close}}
|
|
/>
|
|
{{else}}
|
|
{{@instance.options.content}}
|
|
{{/if}}
|
|
</DModal>
|
|
{{else}}
|
|
<DFloatBody
|
|
@instance={{@instance}}
|
|
@trapTab={{@trapTab}}
|
|
@mainClass={{@mainClass}}
|
|
@innerClass={{@innerClass}}
|
|
@role={{@role}}
|
|
@portalOutletElement={{@instance.portalOutletElement}}
|
|
@inline={{@inline}}
|
|
>
|
|
{{#if @instance.options.component}}
|
|
<@instance.options.component
|
|
@data={{@instance.options.data}}
|
|
@close={{@instance.close}}
|
|
/>
|
|
{{else}}
|
|
{{@instance.options.content}}
|
|
{{/if}}
|
|
</DFloatBody>
|
|
{{/if}}
|
|
{{/if}}
|
|
</template>
|
|
}
|