mirror of
https://github.com/flarum/framework.git
synced 2025-06-04 23:14:32 +08:00
Massive JavaScript cleanup
- Use JSX for templates - Docblock/comment everything - Mostly passes ESLint (still some work to do) - Lots of renaming, refactoring, etc. CSS hasn't been updated yet.
This commit is contained in:
57
js/forum/src/components/HeaderSecondary.js
Normal file
57
js/forum/src/components/HeaderSecondary.js
Normal file
@ -0,0 +1,57 @@
|
||||
import Component from 'flarum/Component';
|
||||
import Button from 'flarum/components/Button';
|
||||
import LogInModal from 'flarum/components/LogInModal';
|
||||
import SignUpModal from 'flarum/components/SignUpModal';
|
||||
import SessionDropdown from 'flarum/components/SessionDropdown';
|
||||
import NotificationsDropdown from 'flarum/components/NotificationsDropdown';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import listItems from 'flarum/helpers/listItems';
|
||||
|
||||
/**
|
||||
* The `HeaderSecondary` component displays secondary footer controls, such as
|
||||
* the search box and the user menu. On the default skin, these are shown on the
|
||||
* right side of the header.
|
||||
*/
|
||||
export default class HeaderSecondary extends Component {
|
||||
view() {
|
||||
return (
|
||||
<ul className="header-controls">
|
||||
{listItems(this.items().toArray())}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an item list for the controls.
|
||||
*
|
||||
* @return {ItemList}
|
||||
*/
|
||||
items() {
|
||||
const items = new ItemList();
|
||||
|
||||
items.add('search', app.search.render());
|
||||
|
||||
if (app.session.user) {
|
||||
items.add('notifications', NotificationsDropdown.component());
|
||||
items.add('session', SessionDropdown.component());
|
||||
} else {
|
||||
items.add('signUp',
|
||||
Button.component({
|
||||
children: 'Sign Up',
|
||||
className: 'btn btn-link',
|
||||
onclick: () => app.modal.show(new SignUpModal())
|
||||
})
|
||||
);
|
||||
|
||||
items.add('logIn',
|
||||
Button.component({
|
||||
children: 'Log In',
|
||||
className: 'btn btn-link',
|
||||
onclick: () => app.modal.show(new LogInModal())
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user