Improved naming of class for post by actor.

Made class list for post extensible by using a separate method.
This commit is contained in:
Daniël Klabbers 2019-11-11 12:58:33 +01:00
parent 9f0a178f58
commit 830f48a212

View File

@ -39,7 +39,7 @@ export default class Post extends Component {
view() { view() {
const attrs = this.attrs(); const attrs = this.attrs();
attrs.className = 'Post ' + (this.loading ? 'Post--loading ' : '') + (this.props.post.user() === app.session.user ? 'Post--self' : '') + (attrs.className || ''); attrs.className = this.classes().join(' ');
return ( return (
<article {...attrs}> <article {...attrs}>
@ -98,6 +98,20 @@ export default class Post extends Component {
return []; return [];
} }
classes() {
let classes = ['Post'];
if (this.loading) {
classes.push('Post--loading');
}
if (this.props.post.user() === app.session.user) {
classes.push('Post--by-actor');
}
return classes;
}
/** /**
* Build an item list for the post's actions. * Build an item list for the post's actions.
* *