diff --git a/extensions/tags/js/src/common/helpers/tagLabel.js b/extensions/tags/js/src/common/helpers/tagLabel.js index eb520c068..5e6d52011 100644 --- a/extensions/tags/js/src/common/helpers/tagLabel.js +++ b/extensions/tags/js/src/common/helpers/tagLabel.js @@ -34,7 +34,8 @@ export default function tagLabel(tag, attrs = {}) { link ? Link : 'span', attrs, - {tag && tag.icon() && tagIcon(tag, {}, { useColor: false })} {tagText} + {tag && tag.icon() && tagIcon(tag, { className: 'TagLabel-icon' }, { useColor: false })} + {tagText} ); } diff --git a/extensions/tags/js/src/forum/components/TagsPage.js b/extensions/tags/js/src/forum/components/TagsPage.js index 690f71970..c6869571c 100755 --- a/extensions/tags/js/src/forum/components/TagsPage.js +++ b/extensions/tags/js/src/forum/components/TagsPage.js @@ -3,6 +3,7 @@ import IndexPage from 'flarum/forum/components/IndexPage'; import Link from 'flarum/common/components/Link'; import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import listItems from 'flarum/common/helpers/listItems'; +import ItemList from 'flarum/common/utils/ItemList'; import humanTime from 'flarum/common/helpers/humanTime'; import textContrastClass from 'flarum/common/helpers/textContrastClass'; import classList from 'flarum/common/utils/classList'; @@ -37,69 +38,107 @@ export default class TagsPage extends Page { }); } - view() { - if (this.loading) { - return ; - } - - const pinned = this.tags.filter((tag) => tag.position() !== null); - const cloud = this.tags.filter((tag) => tag.position() === null); - - return ( -
- {IndexPage.prototype.hero()} -
- - -
-
    - {pinned.map((tag) => { - const lastPostedDiscussion = tag.lastPostedDiscussion(); - const children = sortTags(tag.children() || []); - - return ( -
  • - - {tag.icon() && tagIcon(tag, {}, { useColor: false })} -

    {tag.name()}

    -

    {tag.description()}

    - {children ? ( -
    - {children.map((child) => [{child.name()}, ' '])} -
    - ) : ( - '' - )} - - {lastPostedDiscussion ? ( - - {lastPostedDiscussion.title()} - {humanTime(lastPostedDiscussion.lastPostedAt())} - - ) : ( - - )} -
  • - ); - })} -
- - {cloud.length ?
{cloud.map((tag) => [tagLabel(tag, { link: true }), ' '])}
: ''} -
-
-
- ); - } - oncreate(vnode) { super.oncreate(vnode); app.setTitle(app.translator.trans('flarum-tags.forum.all_tags.meta_title_text')); app.setTitleCount(0); } + + view() { + return
{this.pageContent().toArray()}
; + } + + pageContent() { + const items = new ItemList(); + + items.add('hero', this.hero(), 100); + items.add('main',
{this.mainContent().toArray()}
, 10); + + return items; + } + + mainContent() { + const items = new ItemList(); + + items.add('sidebar', this.sidebar(), 100); + items.add('content', this.content(), 10); + + return items; + } + + content() { + return
{this.contentItems().toArray()}
; + } + + contentItems() { + const items = new ItemList(); + + if (this.loading) { + items.add('loading', ); + } else { + const pinned = this.tags.filter((tag) => tag.position() !== null); + const cloud = this.tags.filter((tag) => tag.position() === null); + + items.add('tagTiles', this.tagTileListView(pinned), 100); + + if (cloud.length) { + items.add('cloud', this.cloudView(cloud), 10); + } + } + + return items; + } + + hero() { + return IndexPage.prototype.hero(); + } + + sidebar() { + return ( + + ); + } + + sidebarItems() { + return IndexPage.prototype.sidebarItems(); + } + + tagTileListView(pinned) { + return ; + } + + tagTileView(tag) { + const lastPostedDiscussion = tag.lastPostedDiscussion(); + const children = sortTags(tag.children() || []); + + return ( +
  • + + {tag.icon() && tagIcon(tag, {}, { useColor: false })} +

    {tag.name()}

    +

    {tag.description()}

    + {children ? ( +
    {children.map((child) => [{child.name()}, ' '])}
    + ) : ( + '' + )} + + {lastPostedDiscussion ? ( + + {lastPostedDiscussion.title()} + {humanTime(lastPostedDiscussion.lastPostedAt())} + + ) : ( + + )} +
  • + ); + } + + cloudView(cloud) { + return
    {cloud.map((tag) => [tagLabel(tag, { link: true }), ' '])}
    ; + } } diff --git a/framework/core/js/src/forum/components/ChangeEmailModal.tsx b/framework/core/js/src/forum/components/ChangeEmailModal.tsx index 0d32c6272..3f4506544 100644 --- a/framework/core/js/src/forum/components/ChangeEmailModal.tsx +++ b/framework/core/js/src/forum/components/ChangeEmailModal.tsx @@ -2,8 +2,9 @@ import app from '../../forum/app'; import Modal, { IInternalModalAttrs } from '../../common/components/Modal'; import Button from '../../common/components/Button'; import Stream from '../../common/utils/Stream'; -import Mithril from 'mithril'; +import type Mithril from 'mithril'; import RequestError from '../../common/utils/RequestError'; +import ItemList from '../../common/utils/ItemList'; /** * The `ChangeEmailModal` component shows a modal dialog which allows the user @@ -41,60 +42,75 @@ export default class ChangeEmailModal +
    {this.fields().toArray()}
    + + ); + } + + fields(): ItemList { + const items = new ItemList(); + if (this.success) { - return ( -
    -
    -

    - {app.translator.trans('core.forum.change_email.confirmation_message', { email: {this.email()} })} -

    -
    - -
    -
    + items.add( + 'help', +

    + {app.translator.trans('core.forum.change_email.confirmation_message', { + email: {this.email()}, + })} +

    + ); + + items.add( + 'dismiss', +
    + +
    + ); + } else { + items.add( + 'email', +
    + +
    + ); + + items.add( + 'password', +
    + +
    + ); + + items.add( + 'submit', +
    +
    ); } - return ( -
    -
    -
    - -
    -
    - -
    -
    - {Button.component( - { - className: 'Button Button--primary Button--block', - type: 'submit', - loading: this.loading, - }, - app.translator.trans('core.forum.change_email.submit_button') - )} -
    -
    -
    - ); + return items; } onsubmit(e: SubmitEvent) { @@ -111,13 +127,10 @@ export default class ChangeEmailModal { this.success = true; }) @@ -125,6 +138,10 @@ export default class ChangeEmailModal -
    -

    {app.translator.trans('core.forum.change_password.text')}

    -
    - {Button.component( - { - className: 'Button Button--primary Button--block', - type: 'submit', - loading: this.loading, - }, - app.translator.trans('core.forum.change_password.send_button') - )} -
    -
    +
    {this.fields().toArray()}
    ); } + fields() { + const fields = new ItemList(); + + fields.add('help',

    {app.translator.trans('core.forum.change_password.text')}

    ); + + fields.add( + 'submit', +
    + +
    + ); + + return fields; + } + onsubmit(e: SubmitEvent) { e.preventDefault(); @@ -44,8 +51,12 @@ export default class ChangePasswordModal + {this.controlsView(controls)} + {this.slidableUnderneathView()} + {this.contentView()} + + ); + } + + controlsView(controls: Mithril.ChildArray): Mithril.Children { + return ( + (controls.length > 0 && + Dropdown.component( + { + icon: 'fas fa-ellipsis-v', + className: 'DiscussionListItem-controls', + buttonClassName: 'Button Button--icon Button--flat Slidable-underneath Slidable-underneath--right', + accessibleToggleLabel: app.translator.trans('core.forum.discussion_controls.toggle_dropdown_accessible_label'), + }, + controls + )) || + null + ); + } + + slidableUnderneathView(): Mithril.Children { + const discussion = this.attrs.discussion; + const isUnread = discussion.isUnread(); + + return ( + + {icon('fas fa-check')} + + ); + } + + contentView(): Mithril.Children { + const discussion = this.attrs.discussion; const isUnread = discussion.isUnread(); const isRead = discussion.isRead(); + return ( +
    + {this.authorAvatarView()} + {this.badgesView()} + {this.mainView()} + {this.replyCountItem()} +
    + ); + } + + authorAvatarView(): Mithril.Children { + const discussion = this.attrs.discussion; + const user = discussion.user(); + + return ( + + + {avatar(user || null, { title: '' })} + + + ); + } + + badgesView(): Mithril.Children { + const discussion = this.attrs.discussion; + + return
      {listItems(discussion.badges().toArray())}
    ; + } + + mainView(): Mithril.Children { + const discussion = this.attrs.discussion; + const jumpTo = this.getJumpTo(); + + return ( + +

    {highlight(discussion.title(), this.highlightRegExp)}

    +
      {listItems(this.infoItems().toArray())}
    + + ); + } + + getJumpTo() { + const discussion = this.attrs.discussion; let jumpTo = 0; - const controls = DiscussionControls.controls(discussion, this).toArray(); - const attrs = this.elementAttrs(); if (this.attrs.params.q) { const post = discussion.mostRelevantPost(); @@ -84,46 +172,7 @@ export default class DiscussionListItem - {controls.length > 0 && - Dropdown.component( - { - icon: 'fas fa-ellipsis-v', - className: 'DiscussionListItem-controls', - buttonClassName: 'Button Button--icon Button--flat Slidable-underneath Slidable-underneath--right', - accessibleToggleLabel: app.translator.trans('core.forum.discussion_controls.toggle_dropdown_accessible_label'), - }, - controls - )} - - - {icon('fas fa-check')} - - -
    - - - {avatar(user || null, { title: '' })} - - - -
      {listItems(discussion.badges().toArray())}
    - - -

    {highlight(discussion.title(), this.highlightRegExp)}

    -
      {listItems(this.infoItems().toArray())}
    - - {this.replyCountItem()} -
    - - ); + return jumpTo; } oncreate(vnode: Mithril.VnodeDOM) {