Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Expand block preview #353

Conversation

raissanorth
Copy link
Contributor

Resolves silverstripe/silverstripe-elemental-blocks#43

Block is not expandable:

screen shot 2018-08-27 at 3 56 44 pm

Block is expandable and expanded; the preview is hidden

screen shot 2018-08-27 at 3 53 34 pm

Block is expandable and not expanded; the preview is shown
screen shot 2018-08-27 at 3 54 05 pm

Changes in this PR...

  • add a FormBuilder component
  • add a Summary component
  • both of the above are injected into Content and rendered by it
  • move the prior Content unit tests into the Summary test file, since the latter is handling this logic now
  • add new unit tests for the Content component
  • add unit tests for Element component

Design review by @clarkepaul still outstanding.

The expand button has been tested on Edge 17, IE 11 (browser stack), Chrome 11, Firefox 61, and Safari 11 . It is keyboard accessible on all of these browsers, expect Safari.

Also, the styling is slightly off on Edge 17:

image

Copy link
Contributor

@robbieaverill robbieaverill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just some linting issues to tidy up. Also please remove yarn-error.log and add it to your global git ignore :)

fileUrl,
fileTitle,
content,
previewExpanded,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like this should be a context argument

E.g. if (context === 'preview') { return <SummaryComponent ...props />; } else { return <FormBuilderComponent ...props />}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest I change the state on Element to, or only rename Content's prop and change the type to a string?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see - this is loosely coupled to the container's state name... leave it as is +D

const { link } = this.props;
handleExpand() {
const {
element: { InlineEditable },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just import the element and use that` - the fact that the InlineEditable prop is capitalised is misleading, because usually capitalisation in React is used for component names, this sort of implies that it could be renderable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming from GraphQL, which is the reason it is capitalised. Would you still like me to rename it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but if you don't destructure it as much as this then you can refer to it as element.InlineEditable and it's fine =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll go for your last suggestion. But for consistency I'll do the same with ID, Title, and BlockSchema.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, thanks!

@@ -66,11 +86,16 @@ class Element extends Component {
title={Title}
elementType={BlockSchema.type}
fontIcon={BlockSchema.iconClass}
link={link}
caretClickCallback={(event) => this.handleExpand(event)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleExpand is already bound to this in the constructor - I think you could use caretClickCallback={this.handleExpand} here

@@ -39,6 +40,20 @@ class Header extends Component {
}
}

/**
* Handle the opening/closing of the block preview
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation slightly out

'btn',
{ 'font-icon-right-open-big': !expandable,
'font-icon-up-open-big': expandable && previewExpanded,
'font-icon-down-open-big': expandable && !previewExpanded });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please format this object a little - each entry on a new line with consistent indentation

@raissanorth raissanorth force-pushed the pulls/master/expand-block-preview branch from 3bc5633 to dbf4b56 Compare August 27, 2018 04:13
@raissanorth
Copy link
Contributor Author

Note to self, rewrite the Behat tests!

@raissanorth raissanorth force-pushed the pulls/master/expand-block-preview branch from dbf4b56 to da5a68e Compare August 27, 2018 04:56
@robbieaverill robbieaverill merged commit 8ffc0fc into silverstripe:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants