1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +02:00

change use of classNames so no arrays/objects are used, just spread arguments

This commit is contained in:
David Sevilla Martin
2020-02-07 09:11:35 -05:00
parent eae6a11719
commit 4f79a05a4b
4 changed files with 18 additions and 22 deletions

View File

@@ -53,7 +53,7 @@ export default class Button<T extends ButtonProps = ButtonProps> extends Compone
const loading = extract(attrs, 'loading'); const loading = extract(attrs, 'loading');
if (attrs.disabled || loading) { if (attrs.disabled || loading) {
attrs.className += ' ' + classNames('disabled', loading && 'loading'); attrs.className = classNames(attrs.className, 'disabled', loading && 'loading');
delete attrs.onclick; delete attrs.onclick;
} }

View File

@@ -43,7 +43,7 @@ export default function listItems(items) {
item item
) : ( ) : (
<li <li
className={classNames(className, [item.itemName && `item-${item.itemName}`, active && 'active'])} className={classNames(className, item.itemName && `item-${item.itemName}`, active && 'active')}
key={item.attrs?.key || item.itemName} key={item.attrs?.key || item.itemName}
> >
{item} {item}

View File

@@ -81,16 +81,14 @@ export default class CommentPost extends Post {
const post = this.props.post; const post = this.props.post;
const attrs = super.attrs(); const attrs = super.attrs();
attrs.className = attrs.className = classNames(
(attrs.className || '') + attrs.className,
' ' + 'CommentPost',
classNames({ post.isHidden() && 'Post--hidden',
CommentPost: true, post.isEdited() && 'Post--edited',
'Post--hidden': post.isHidden(), this.revealContent && 'revealContent',
'Post--edited': post.isEdited(), this.isEditing() && 'editing'
revealContent: this.revealContent, );
editing: this.isEditing(),
});
return attrs; return attrs;
} }

View File

@@ -76,15 +76,13 @@ export default class Search extends Component {
return ( return (
<div <div
className={ className={classNames(
'Search ' + 'Search',
classNames({ this.value() && this.hasFocus && 'open',
open: this.value() && this.hasFocus, this.hasFocus && 'focused',
focused: this.hasFocus, !!currentSearch && 'active',
active: !!currentSearch, !!this.loadingSources && 'loading'
loading: !!this.loadingSources, )}
})
}
> >
<div className="Search-input"> <div className="Search-input">
<input <input
@@ -143,7 +141,7 @@ export default class Search extends Component {
// Handle input key events on the search input, triggering results to load. // Handle input key events on the search input, triggering results to load.
$input $input
.on('input focus', function() { .on('input focus', function(this: HTMLInputElement) {
const query = this.value.toLowerCase(); const query = this.value.toLowerCase();
if (!query) return; if (!query) return;