Skip to content

Commit

Permalink
Merge pull request silverstripe#316 from creative-commoners/pulls/4.0…
Browse files Browse the repository at this point in the history
…/loading-indicator

FIX ElementList shows loading indicator while GraphQL query fetches list of blocks
  • Loading branch information
robbieaverill authored Aug 13, 2018
2 parents 9d9cb7b + 1552750 commit 273e76d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion client/src/components/ElementEditor/Element.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
.element-editor__element {
display: block;
border-bottom: 1px solid $border-color-light;
color: inherit;
cursor: pointer;
display: block;
padding: $panel-padding-x;

&:hover {
text-decoration: inherit;
color: inherit;
background-color: $table-hover-bg;
}

&:last-child {
border-bottom: 0;
}
}
22 changes: 20 additions & 2 deletions client/src/components/ElementEditor/ElementList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,24 @@ class ElementList extends Component {
));
}

/**
* Renders a loading component
*
* @returns {LoadingComponent|null}
*/
renderLoading() {
const { loading, LoadingComponent } = this.props;

if (loading) {
return <LoadingComponent />;
}
return null;
}

render() {
return (
<div className="elemental-editor__list">
{this.renderLoading()}
{this.renderBlocks()}
</div>
);
Expand All @@ -36,18 +51,21 @@ class ElementList extends Component {
ElementList.propTypes = {
// @todo support either ElementList or Element children in an array (or both)
blocks: PropTypes.arrayOf(elementType),
loading: PropTypes.bool,
};

ElementList.defaultProps = {
blocks: [],
loading: false,
};

export { ElementList as Component };

export default inject(
['Element'],
(ElementComponent) => ({
['Element', 'Loading'],
(ElementComponent, LoadingComponent) => ({
ElementComponent,
LoadingComponent,
}),
() => 'ElementEditor.ElementList'
)(ElementList);
10 changes: 4 additions & 6 deletions client/src/components/ElementEditor/ElementList.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.elemental-editor__list {
background-color: $white;

border-bottom: 1px solid $border-color-light;
border-top: 1px solid $border-color-light;
margin-left: -$panel-padding-x;
margin-right: -$panel-padding-x;
border-top: 1px solid $border-color-light;

> .element-editor__element {
border-bottom: 1px solid $border-color-light;
}
min-height: 6rem;
position: relative;
}

0 comments on commit 273e76d

Please sign in to comment.