mirror of
https://github.com/flarum/framework.git
synced 2025-05-22 14:49:57 +08:00

- Get rid of Bootstrap (except we still rely on some JS) - Use BEM class names - Rework variables/theme config - Fix various bugs, including some on mobile The CSS is still not ideal – it needs to be cleaned up some more. But that can be a focus for after beta.
37 lines
922 B
JavaScript
37 lines
922 B
JavaScript
import highlight from 'flarum/helpers/highlight';
|
|
import avatar from 'flarum/helpers/avatar';
|
|
|
|
/**
|
|
* The `UsersSearchSource` finds and displays user search results in the search
|
|
* dropdown.
|
|
*
|
|
* @implements SearchSource
|
|
*/
|
|
export default class UsersSearchResults {
|
|
search(query) {
|
|
return app.store.find('users', {
|
|
filter: {q: query},
|
|
page: {limit: 5}
|
|
});
|
|
}
|
|
|
|
view(query) {
|
|
const results = app.store.all('users')
|
|
.filter(user => user.username().toLowerCase().substr(0, query.length) === query);
|
|
|
|
if (!results.length) return '';
|
|
|
|
return [
|
|
<li className="Dropdown-header">Users</li>,
|
|
results.map(user => (
|
|
<li className="UserSearchResult" data-index={'users' + user.id()}>
|
|
<a href={app.route.user(user)} config={m.route}>
|
|
{avatar(user)}
|
|
{highlight(user.username(), query)}
|
|
</a>
|
|
</li>
|
|
))
|
|
];
|
|
}
|
|
}
|