FEATURE: Add ability to hide modal header (#24290)

This commit is contained in:
Jordan Vidrine 2023-11-08 12:15:35 -06:00 committed by GitHub
parent 670692cfa9
commit 9d1e8265da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -25,13 +25,15 @@
<div class="modal-middle-container">
<div class="modal-inner-container">
{{yield to="aboveHeader"}}
{{#if
(or
this.dismissable
@title
(has-block "headerBelowTitle")
(has-block "headerAboveTitle")
(and
(not @hideHeader)
(or
this.dismissable
@title
(has-block "headerBelowTitle")
(has-block "headerAboveTitle")
)
)
}}
<div class={{concat-class "modal-header" @headerClass}}>

View File

@ -4,6 +4,7 @@
<Styleguide::Component>
<DModal
@closeModal={{fn (mut this.inline) true}}
@hideHeader={{this.hideHeader}}
@inline={{this.inline}}
@title={{this.title}}
@subtitle={{this.subtitle}}
@ -23,6 +24,12 @@
</Styleguide::Component>
<Styleguide::Controls>
<Styleguide::Controls::Row @name="@hideHeader">
<DToggleSwitch
@state={{this.hideHeader}}
{{on "click" this.toggleHeader}}
/>
</Styleguide::Controls::Row>
<Styleguide::Controls::Row @name="@inline">
<DToggleSwitch @state={{this.inline}} {{on "click" this.toggleInline}} />
</Styleguide::Controls::Row>

View File

@ -5,6 +5,7 @@ import I18n from "discourse-i18n";
export default class extends Component {
@tracked inline = true;
@tracked hideHeader = false;
@tracked dismissable = true;
@tracked modalTagName = "div";
@tracked title = I18n.t("styleguide.sections.modal.header");
@ -16,6 +17,11 @@ export default class extends Component {
flashTypes = ["success", "info", "warning", "error"];
modalTagNames = ["div", "form"];
@action
toggleHeader() {
this.hideHeader = !this.hideHeader;
}
@action
toggleInline() {
this.inline = !this.inline;