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
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
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');
if (attrs.disabled || loading) {
attrs.className += ' ' + classNames('disabled', loading && 'loading');
attrs.className = classNames(attrs.className, 'disabled', loading && 'loading');
delete attrs.onclick;
}

View File

@ -43,7 +43,7 @@ export default function listItems(items) {
item
) : (
<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}
>
{item}

View File

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

View File

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