mirror of
https://github.com/flarum/core.git
synced 2025-06-25 20:24:56 +02:00
Add a first empty state to the discussion list
This commit is contained in:
@ -2,6 +2,7 @@ import Component from 'flarum/Component';
|
||||
import DiscussionListItem from 'flarum/components/DiscussionListItem';
|
||||
import Button from 'flarum/components/Button';
|
||||
import LoadingIndicator from 'flarum/components/LoadingIndicator';
|
||||
import Placeholder from 'flarum/components/Placeholder';
|
||||
|
||||
/**
|
||||
* The `DiscussionList` component displays a list of discussions.
|
||||
@ -53,6 +54,15 @@ export default class DiscussionList extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.discussions.length == 0) {
|
||||
const text = 'Looks like there are no discussions here. Why don\'t you create a new one?';
|
||||
return (
|
||||
<div className="DiscussionList">
|
||||
{Placeholder.component({text})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="DiscussionList">
|
||||
<ul className="DiscussionList-discussions">
|
||||
|
19
js/lib/components/Placeholder.js
Normal file
19
js/lib/components/Placeholder.js
Normal file
@ -0,0 +1,19 @@
|
||||
import Component from 'flarum/Component';
|
||||
|
||||
/**
|
||||
* The `Placeholder` component displays a muted text with some call to action,
|
||||
* usually used as an empty state.
|
||||
*
|
||||
* ### Props
|
||||
*
|
||||
* - `text`
|
||||
*/
|
||||
export default class Placeholder extends Component {
|
||||
view() {
|
||||
return (
|
||||
<div className="Placeholder">
|
||||
<p>{this.props.text}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user