mirror of
https://github.com/wassname/talk.git
synced 2026-07-08 22:39:48 +08:00
Move Spinner down to replacing TabContent
This commit is contained in:
@@ -13,7 +13,7 @@ import t, {timeago} from 'coral-framework/services/i18n';
|
||||
import CommentBox from 'talk-plugin-commentbox/CommentBox';
|
||||
import QuestionBox from 'talk-plugin-questionbox/QuestionBox';
|
||||
import {isCommentActive} from 'coral-framework/utils';
|
||||
import {Spinner, Button, Tab, TabCount, TabPane} from 'coral-ui';
|
||||
import {Button, Tab, TabCount, TabPane} from 'coral-ui';
|
||||
import cn from 'classnames';
|
||||
|
||||
import {getTopLevelParent, attachCommentToParent} from '../graphql/utils';
|
||||
@@ -23,8 +23,6 @@ import StreamTabPanel from '../containers/StreamTabPanel';
|
||||
|
||||
import styles from './Stream.css';
|
||||
|
||||
const SpinnerWhenLoading = ({loading, children}) => loading ? <Spinner /> : <div>{children}</div>;
|
||||
|
||||
class Stream extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
@@ -144,6 +142,7 @@ class Stream extends React.Component {
|
||||
emit,
|
||||
sortOrder,
|
||||
sortBy,
|
||||
loading,
|
||||
} = this.props;
|
||||
|
||||
const slotProps = {data};
|
||||
@@ -171,6 +170,7 @@ class Stream extends React.Component {
|
||||
tabPaneSlot={'streamTabPanes'}
|
||||
slotProps={slotProps}
|
||||
queryData={slotQueryData}
|
||||
loading={loading}
|
||||
appendTabs={
|
||||
<Tab tabId={'all'} key='all'>
|
||||
All Comments <TabCount active={activeStreamTab === 'all'} sub>{totalCommentCount}</TabCount>
|
||||
@@ -223,7 +223,6 @@ class Stream extends React.Component {
|
||||
viewAllComments,
|
||||
auth: {loggedIn, user},
|
||||
editName,
|
||||
loading,
|
||||
} = this.props;
|
||||
const {keepCommentBox} = this.state;
|
||||
const open = !asset.isClosed;
|
||||
@@ -310,12 +309,10 @@ class Stream extends React.Component {
|
||||
/>
|
||||
)}
|
||||
|
||||
<SpinnerWhenLoading loading={loading}>
|
||||
{highlightedComment
|
||||
? this.renderHighlightedComment()
|
||||
: this.renderTabPanel()
|
||||
}
|
||||
</SpinnerWhenLoading>
|
||||
{highlightedComment
|
||||
? this.renderHighlightedComment()
|
||||
: this.renderTabPanel()
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.spinnerContainer {
|
||||
margin-top: 16px;
|
||||
}
|
||||
@@ -1,19 +1,23 @@
|
||||
import React from 'react';
|
||||
import {TabBar, TabContent} from 'coral-ui';
|
||||
import {Spinner, TabBar, TabContent} from 'coral-ui';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './StreamTabPanel.css';
|
||||
|
||||
class StreamTabPanel extends React.Component {
|
||||
|
||||
render() {
|
||||
const {activeTab, setActiveTab, tabs, tabPanes, sub} = this.props;
|
||||
const {activeTab, setActiveTab, tabs, tabPanes, sub, loading} = this.props;
|
||||
return (
|
||||
<div>
|
||||
<TabBar activeTab={activeTab} onTabClick={setActiveTab} sub={sub}>
|
||||
{tabs}
|
||||
</TabBar>
|
||||
<TabContent activeTab={activeTab} sub={sub}>
|
||||
{tabPanes}
|
||||
</TabContent>
|
||||
{loading
|
||||
? <div className={styles.spinnerContainer}><Spinner /></div>
|
||||
: <TabContent activeTab={activeTab} sub={sub}>
|
||||
{tabPanes}
|
||||
</TabContent>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ class StreamTabPanelContainer extends React.Component {
|
||||
setActiveTab={this.props.setActiveTab}
|
||||
tabs={this.getPluginTabElements().concat(this.props.appendTabs)}
|
||||
tabPanes={this.getPluginTabPaneElements().concat(this.props.appendTabPanes)}
|
||||
loading={this.props.loading}
|
||||
sub={this.props.sub}
|
||||
/>
|
||||
);
|
||||
@@ -110,6 +111,7 @@ StreamTabPanelContainer.propTypes = {
|
||||
queryData: PropTypes.object,
|
||||
className: PropTypes.string,
|
||||
sub: PropTypes.bool,
|
||||
loading: PropTypes.bool,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
|
||||
Reference in New Issue
Block a user