DEV: Replace modal 'maxHeight' calculation with css

This commit is contained in:
David Taylor 2023-05-12 18:53:54 +01:00
parent ad431ab03a
commit f2482b5daa
5 changed files with 13 additions and 26 deletions

View File

@ -1,5 +1,4 @@
import Component from "@glimmer/component";
import { scheduleOnce } from "@ember/runloop";
import { disableImplicitInjections } from "discourse/lib/implicit-injections";
import { action } from "@ember/object";
import { tracked } from "@glimmer/tracking";
@ -31,25 +30,6 @@ export default class DModalBody extends Component {
$(fixedParent).modal("show");
}
scheduleOnce("afterRender", () => this._afterFirstRender(element));
}
@action
willDestroy() {
this.appEvents.trigger("modal:body-dismissed");
}
_afterFirstRender(element) {
const maxHeight = this.args.maxHeight;
if (maxHeight) {
const maxHeightFloat = parseFloat(maxHeight) / 100.0;
if (maxHeightFloat > 0) {
const viewPortHeight = $(window).height();
element.style.maxHeight =
Math.floor(maxHeightFloat * viewPortHeight) + "px";
}
}
this.appEvents.trigger(
"modal:body-shown",
pick(this.args, [
@ -64,4 +44,9 @@ export default class DModalBody extends Component {
])
);
}
@action
willDestroy() {
this.appEvents.trigger("modal:body-dismissed");
}
}

View File

@ -1,4 +1,4 @@
<DModalBody @title={{this.modalTitleKey}} @maxHeight="70%">
<DModalBody @title={{this.modalTitleKey}}>
<div id="revision">
<div id="revision-details">
{{d-icon "pencil-alt"}}

View File

@ -1,8 +1,4 @@
<DModalBody
@title="raw_email.title"
@class="incoming-email-modal"
@maxHeight="80%"
>
<DModalBody @title="raw_email.title" @class="incoming-email-modal">
<div class="incoming-email-tabs">
<DButton
@action={{action "displayRaw"}}

View File

@ -1,6 +1,10 @@
// styles that apply to the popup that appears when you show the edit history of a post
.modal.history-modal {
.modal-body {
max-height: 70vh;
}
#revision-numbers {
display: inline-block;
min-width: 96px;

View File

@ -392,6 +392,8 @@
}
.incoming-email-modal {
max-height: 80vh;
.btn {
transition: none;
background-color: transparent;