Skip to content

Commit

Permalink
add nav to poll compose
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Feb 21, 2024
1 parent 0d78029 commit e7abc4c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 33 additions & 1 deletion js/src/forum/components/ComposePollPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import PollForm from './PollForm';
import PollFormState from '../states/PollFormState';
import ComposePollHero from './ComposePollHero';
import Button from 'flarum/common/components/Button';
import listItems from 'flarum/common/helpers/listItems';
import ItemList from 'flarum/common/utils/ItemList';
import SelectDropdown from 'flarum/common/components/SelectDropdown';
import IndexPage from 'flarum/forum/components/IndexPage';

export default class ComposePollPage extends Page {
poll: Poll | null | undefined = null;
Expand Down Expand Up @@ -55,7 +59,14 @@ export default class ComposePollPage extends Page {
<div className="ComposePollCollectionPage">
<ComposePollHero poll={this.poll} />
<div className="container">
<PollForm poll={this.poll} onsubmit={this.onsubmit.bind(this)} />
<div className="sideNavContainer">
<nav className="PollsPage-nav sideNav">
<ul>{listItems(this.sidebarItems().toArray())}</ul>
</nav>
<div className="sideNavOffset">
<PollForm poll={this.poll} onsubmit={this.onsubmit.bind(this)} />
</div>
</div>
</div>
</div>
);
Expand Down Expand Up @@ -97,4 +108,25 @@ export default class ComposePollPage extends Page {
m.route.set(app.route('fof.polls.list'));
}
}

sidebarItems(): ItemList<Mithril.Children> {
const items = new ItemList<Mithril.Children>();

items.add(
'nav',
<SelectDropdown
buttonClassName="Button"
className="App-titleControl"
accessibleToggleLabel={app.translator.trans('core.forum.index.toggle_sidenav_dropdown_accessible_label')}
>
{this.navItems().toArray()}
</SelectDropdown>
);

return items;
}

navItems() {
return IndexPage.prototype.navItems();
}
}
2 changes: 1 addition & 1 deletion js/src/forum/components/PollsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class PollsPage extends Page<IPageAttrs, PollListState> {
);
}

sidebarItems() {
sidebarItems(): ItemList<Mithril.Children> {
const items = new ItemList<Mithril.Children>();
const canStartPoll = app.forum.attribute<boolean>('canStartGlobalPolls');

Expand Down

0 comments on commit e7abc4c

Please sign in to comment.