-
Notifications
You must be signed in to change notification settings - Fork 8.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
[Canvas] Alignment and distribution #39132
Conversation
Pinging @elastic/kibana-canvas |
💚 Build Succeeded |
8c2e4e5
to
ffd0a10
Compare
💚 Build Succeeded |
💚 Build Succeeded |
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.
@monfera first off, this is fantastic, thank you!
The good news: there is a rather common set of icons we can use for these!
The not-so-good news: I'm pretty backlogged at the moment and will need some time to get them done. If you'd like to get this merged, I can come back through add them once they're created. In the meantime, you can simply remove the icons for now.
I also have one small request that is quite subjective :) , can you remove the top borders on the Align elements and Distribute elements items so that we end up with this:
These will be very well-received features.
Working on adding these icons to EUI in time for Kibana 7.3: elastic/eui#2070 |
Thanks @ryankeairns! Will they import like the other icons over there, or do I need to do something special, or are you planning to add a commit? |
Upon updating from Master, you would be able to simply change the icon |
Those things are awesome, Ryan, thanks! I see it's merged into eui but kibana master apparently hasn't picked it up yet, if you know when it happens, can you tap me on the shoulder? Or should I bump it myself in this PR and I don't do damage with it? Btw. should Lines now removed! |
ffd0a10
to
72e9fc2
Compare
💚 Build Succeeded |
@monfera Greg is working on a new release and will then update Kibana. If your PR is ready prior to that happening, you can merge yours and I will add the icons once Kibana has been updated. It looks like |
Thanks @ryankeairns - I should've looked further in the code indeed, it's just in the comment (this PR uses the compliant name) |
72e9fc2
to
881a524
Compare
The design (icon) changes look good, just waiting on the EUI update in Kibana to come through. |
💚 Build Succeeded |
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.
This is such a neat feature! It makes lining up multiple elements so much easier. I just had a couple comments, but the rest looks good.
@@ -95,6 +95,25 @@ export const basicHandlerCreators = { | |||
}, | |||
}; | |||
|
|||
// handlers for group and ungroup |
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.
Nit: Can you update this comment?
}; | ||
|
||
this._getAlignmentMenuItems(close).forEach(menuFiller); | ||
this._getDistributionMenuItems(close).forEach(menuFiller); |
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.
Nit: You implemented this differently than I did with _getLayerMenuItems
. Why do you return the object wrapped in an array here instead of just the MenuTuple
object?
Since _getLayerMenuItems
, _getAlignmentMenuItems
, and _getDistributionMenuItems
are all similar functions, they should be implemented the same way, so it'd be great if you could refactor _getLayerMenuItems
like the two new functions or vice versa.
Also, would it make sense to take the conditional check for the number of selectedNodes
out of the individual functions and wrap the condition around these two function calls?
Here's an example of how I imagine this code looking (with all of the functions returning a MenuTuple
object)
this._getDistributionMenuItems(close).forEach(menuFiller); | |
const menuFiller = ({ menuItem, panel }: MenuTuple) => { | |
items.push(menuItem); | |
panels.push(panel); | |
}; | |
if (showLayerControls) { | |
menuFiller(this._getLayerMenuItems(); | |
} | |
if(selectedNodes.length > 2) { | |
menuFiller(this._getAlignmentMenuItems(close)); | |
menuFiller(this._getDistributionMenuItems(close)); | |
} |
Or alternatively (with all of the functions returning a MenuTuple[]
array):
this._getDistributionMenuItems(close).forEach(menuFiller); | |
const menuFiller = ({ menuItem, panel }: MenuTuple) => { | |
items.push(menuItem); | |
panels.push(panel); | |
}; | |
if (showLayerControls) { | |
this._getLayerMenuItems(close).forEach(menuFiller); | |
} | |
if(selectedNodes.length > 2) { | |
this._getAlignmentMenuItems(close).forEach(menuFiller); | |
this._getDistributionMenuItems(close).forEach(menuFiller); | |
} |
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.
@cqliu1 thanks for the feedback, looking at it with a fresh pair of eyes, uniformity and just plain simplicity supports your take, now pushed
@monfera Were you planning to add shortcuts for these actions? |
@cqliu1 I haven't seen shortcuts required and wasn't surprised as similar software often also doesn't have shortcuts for these. While technically possible, the concern is that there's an overload of shortcuts for a comparatively rare operation: 3 ops: align horizoontally, align vertically and distribute; 2 or 3 suboptions each. Either resulting in somewhat random keys or they somehow involve arrow keys and modifiers. Having said it, we could get the discussion going on shortcuts, can be a follow-up PR if it doesn't fit the time frame. Also it's a prime candidate for an eventual context menu |
I agree with @monfera 's assessment. These operations don't typically have shortcuts (at least not that I have experienced) and we could always add them later if the case arises. A context menu seems like a good solution, with regards to discoverability, in the long run. |
Kibana has been updated to EUI 12.1.0. Please rebase to see the new icons. Thanks! |
34d1f13
to
de67169
Compare
💚 Build Succeeded |
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.
LGTM 👍
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.
👍 LGTM, well done, great addition!
[Canvas] Alignment and distribution
💔 Build Failed |
Summary
Implements alignment and distribution.
Alignment:

Distribution, then some alignments:

Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] Unit or functional tests were updated or added to match the most common scenarios- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers