DEV: refactors d-section (#15245)
- go tagless - properly declares properties - deprecates "false" in favour of false - drops jquery
This commit is contained in:
parent
76dff7fd9e
commit
5d44adb9b9
|
@ -1,24 +1,35 @@
|
||||||
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||||
|
|
||||||
// Can add a body class from within a component, also will scroll to the top automatically.
|
// Can add a body class from within a component, also will scroll to the top automatically.
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
tagName: "section",
|
tagName: null,
|
||||||
|
pageClass: null,
|
||||||
|
bodyClass: null,
|
||||||
|
scrollTop: true,
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
const pageClass = this.pageClass;
|
if (this.pageClass) {
|
||||||
if (pageClass) {
|
document.body.classList.add(`${this.pageClass}-page`);
|
||||||
$("body").addClass(`${pageClass}-page`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bodyClass = this.bodyClass;
|
if (this.bodyClass) {
|
||||||
if (bodyClass) {
|
document.body.classList.add(this.bodyClass);
|
||||||
$("body").addClass(bodyClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.scrollTop === "false") {
|
if (this.scrollTop === "false") {
|
||||||
|
deprecated("Uses boolean instead of string for scrollTop.", {
|
||||||
|
since: "2.8.0.beta9",
|
||||||
|
dropFrom: "2.9.0.beta1",
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.scrollTop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,14 +38,13 @@ export default Component.extend({
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
const pageClass = this.pageClass;
|
|
||||||
if (pageClass) {
|
if (this.pageClass) {
|
||||||
$("body").removeClass(`${pageClass}-page`);
|
document.body.classList.remove(`${this.pageClass}-page`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bodyClass = this.bodyClass;
|
if (this.bodyClass) {
|
||||||
if (bodyClass) {
|
document.body.classList.remove(this.bodyClass);
|
||||||
$("body").removeClass(bodyClass);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<section>{{yield}}</section>
|
|
@ -1,4 +1,4 @@
|
||||||
{{#d-section bodyClass="navigation-topics" class="navigation-container" scrollTop="false"}}
|
{{#d-section bodyClass="navigation-topics" class="navigation-container" scrollTop=false}}
|
||||||
{{d-navigation
|
{{d-navigation
|
||||||
filterMode=filterMode
|
filterMode=filterMode
|
||||||
canCreateTopic=canCreateTopic
|
canCreateTopic=canCreateTopic
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{#d-section pageClass="user-activity" class="user-secondary-navigation" scrollTop="false"}}
|
{{#d-section pageClass="user-activity" class="user-secondary-navigation" scrollTop=false}}
|
||||||
<nav role="navigation">
|
<nav role="navigation">
|
||||||
{{#mobile-nav class="activity-nav" desktopClass="action-list activity-list nav-stacked"}}
|
{{#mobile-nav class="activity-nav" desktopClass="action-list activity-list nav-stacked"}}
|
||||||
{{#d-navigation-item route="userActivity.index"}}{{i18n "user.filters.all"}}{{/d-navigation-item}}
|
{{#d-navigation-item route="userActivity.index"}}{{i18n "user.filters.all"}}{{/d-navigation-item}}
|
||||||
|
|
Loading…
Reference in New Issue