-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Inserter: Preview saved block on hover #4246
Conversation
My thought was an |
editor/components/inserter/group.js
Outdated
@@ -56,6 +64,8 @@ export default class InserterGroup extends Component { | |||
ref={ bindReferenceNode( block.name ) } | |||
tabIndex={ current === block.name || disabled ? null : '-1' } | |||
disabled={ disabled } | |||
onMouseEnter={ this.hoverBlock( ( block ) ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant inner parentheses?
editor/components/inserter/group.js
Outdated
@@ -39,6 +39,14 @@ export default class InserterGroup extends Component { | |||
} | |||
} | |||
|
|||
hoverBlock( block ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name doesn't seem entirely accurate. This is not the hover handler itself; it creates a hover handler. Maybe: createToggleBlockHover
?
Also: Maybe it's worthwhile to check this.props.onHover
before returning anything here? That way, we could e.g. return null;
and avoid creating new function references (i.e. forcing React to reconcile changing function handlers).
@@ -1,3 +1,7 @@ | |||
$content-height: 250px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is these assigned variables are global to all stylesheets, and this seems like it might be a common name. Maybe worth prefixing to act as namespace if we want the variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
blocks/library/code/index.js
Outdated
example: { | ||
content: ` | ||
<?php | ||
echo "Beep Beeb Boop"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I'd find this reasonable to inline in the sense that even stylistically this is something I'd have on one line:
example: {
content: '<?php echo "Beep Beep Boop"; ?>',
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "Beeb" -> "Beep"
3919ca3
to
f444541
Compare
I added the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocks/library/code/index.js
Outdated
@@ -32,6 +32,10 @@ registerBlockType( 'core/code', { | |||
}, | |||
}, | |||
|
|||
example: { | |||
content: '<?php echo "Beep Beep Boop";?>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor: I'd expect a space before the closing ?>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: PHP Guidelines recommend single quotes:
If you’re not evaluating anything in the string, use single quotes.
@@ -0,0 +1,39 @@ | |||
/** | |||
* External dependencie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "dependencie" -> "dependencies"
@jasmussen @youknowriad I think this might need a few more iterations, what do you think of enabling only for "saved blocks" initially? That provides immediate value and requires less consideration of dummy data since saved blocks, by their nature, don't need it. |
I think it's fine to start small and test. 👍 👍 |
Should I remove the "example" API for now? |
I don't mind retaining it but not documented. |
I updated this, it's now limited to the reusable blocks and I also updated the design of the inserter "blocks" by removing the margin in favor of a padding to avoid the flickering when we move the mouse between saved blocks. |
395053c
to
24e0dfa
Compare
Can I have a final review here? |
@jasmussen I'm not able to reproduce the error. Do you know what kind of reusable block produces this error? |
I just left the office, I may not be able to reproduce at home, but it's an old installation with lots of reusable blocks created across different versions. I'm the same session I noticed a reusable block in the recent tab that was actually deleted. |
I was reliably reproducing this as well. |
Was the issue I noted in #4246 (review) addressed ?
|
@aduth The issue was not handled but not sure what can we do about it? Any ideas? Should we show the preview on the right of the inserter instead? cc @jasmussen |
The effect of the preview when the inserter opens upwards is a blinking effect where you hover over a saved block and the preview kicks in moving the hovered block upwards, and then it goes for a loop. Can we just show the preview above the inserter, instead of below it, when the inserter opens upwards? |
@jasmussen That's another issue, we probably can do what you suggest but it doesn't solve the "scrolling" issue if there's not enough space. |
Ah, understood. How about we solve this in two phases. For now, we decide that this is a desktop only enhancement, with no preview on mobile — hover doesn't work too well there anyway. And given that, we show the preview on the right instead of above or below. We can also make it smaller. |
Ok, I moved the preview to the right, I think it's better. |
2f68d7e
to
67b89c8
Compare
I've been able to break it by creating a paragraph block, saving as reusable, selecting it on the editor canvas, then opening the inserter and hovering over it. The editor crashes with:
Should be easy to reproduce. |
67b89c8
to
e977dc4
Compare
This should be ready for a final review. |
@jasmussen I was seeing a few inconsistencies in the visual display of fonts, etc, that I think we should address. Might be worth applying default styles to a generic |
On which previewed blocks did you see these issues? |
@jasmussen Unfortunately, we can't use shadow dom because it doesn't work on Firefox and can't be polyfilled properly. |
(ノಠ益ಠ)ノ彡┻━┻ No worries, it was mostly a case of "it would be nice" :) |
It will look amazing as soon as we add |
1daee71
to
411f7d2
Compare
I'm thinking we can merge this right? |
@jasmussen we can use a class like |
I wonder if |
closes #4106
This PR tries to show a preview of the block to be inserted at the bottom of the inserter menu.
Ideas to improve the design are welcome.
I believe we could introduce a
sampleAttributes
property for blocks to make this preview more compelling using the sample attributes.Maybe we could consider dropping the margins between the blocks in the inserter to avoid the flickering effect when moving from a block to another.