-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add button type to updatemenus #974
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
Conversation
dflt: false, | ||
description: [ | ||
'For dropdown menus, opens the menu in the reverse direction' | ||
] |
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.
👓 missing .join(' ')
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.
Ah, thanks! Yes, noticed that the tests seem to check for that :)
description: [ | ||
'Determines whether the menu and buttons are laid out vertically', | ||
'or horizontally' | ||
] |
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.
another missing .join(' ')
@@ -57,6 +57,37 @@ module.exports = { | |||
].join(' ') | |||
}, | |||
|
|||
openreverse: { |
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.
I'm not fully in ❤️ with this attribute name, but I can't think of anything else.
Maybe @cldougl could help.
with openreverse: false
buttons drop down (or to the right)
with openreverse: true
the buttons drop up (or to the left)
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.
I thought about expandreverse
.
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.
Does this have to be a boolean (t/f)? My initial thought is that it may be more clear if it's called something with direction
or dropdowndirection
/expanddirection
then have options up
/ down
For me, the reverse
is a tiny bit confusing because I think of the options being in a reversed order rather than the dropdown opening up vs down.
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.
Default is to the right, if horizontal, or down, if vertical. Hence 'reverse' instead of just up
/down
since the need for left
/right
would then be modal.
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.
Ahh… maybe orientation should encode both? The problem is that we have two orientations but four directions. What about orientation: 'l'|'r'|'u'|'d'
instead of 'h'|'v'
. Or direction
instead of orientation
, if necessary for consistency.
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.
I like the 'l'|'r'|'u'|'d'
set of options.
But to avoid confusion, I wouldn't call the attribute orientation
(as orientation
is already used for legends, bar ...).
Maybe direction: 'l'|'r'|'u'|'d'
?
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.
ah I see! (sorry for the confusion w/ the sideway opening, didn't realize that was an option)
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.
+1 for direction
I like the explicitness of 'l'|'r'|'u'|'d'
over true|false
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.
Actually, we spell left
and right
when specifying text anchors, so let's go with:
direction: 'left'|'right'|'up'|'down'
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.
Changed to direction: 'left'|'right'|'up'|'down'
. Waiting for tests to pass.
drawButtons(gd, gHeader, gButton, menuOpts); | ||
} | ||
} else { | ||
drawButtons(gd, gHeader, null, menuOpts); |
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 lovely way to reuse the existing logic. Thanks!
I hope my code wasn't too hard to understand.
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.
Nope! It was pretty straightforward. Was kinda able to shoehorn my needs into it, as you've seen.
@@ -181,8 +191,8 @@ function drawHeader(gd, gHeader, gButton, menuOpts) { | |||
.text('▼'); |
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.
Maybe we could add some logic for that ▼
character around orientation
and openreverse
.
For example, orientation: 'h'
/ openreverse: true
would put some orientation: 'v'
/ openreverse: ture
would put some ⬆️ character etc.
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.
I have no strong opinion about it.
Let's ask @jackparmer and @delekru
@@ -313,7 +363,7 @@ function styleButtons(buttons, menuOpts) { | |||
buttons.each(function(buttonOpts, i) { | |||
var button = d3.select(this); | |||
|
|||
if(i === active) { | |||
if(i === active && menuOpts.showactive) { |
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 nice
|
||
// Store per-item sizes since a row of horizontal buttons, for example, | ||
// don't all need to be the same width: | ||
menuOpts.widths[i] = wEff; |
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 nice. I think now this exact same findDimensions
routine could be use for RangeSelectors
- that will be for a future PR though.
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.
Interesting. Yeah, I had to do some carefully wacky stuff to get it to handle all the cases (h/v, buttons/dropdown, reverse/nonreverse, anchor=t/b/l/r—which is at least no less than like 2^5 = 32 cases), but I think it works…
@etpinard the majority of the code went toward positioning so that the image mock tests the majority of what's implemented here. I could add more tests, but I think it'd only be redundant and more code to maintain. Other than that, I think this is ready for review. For simplicity in reviewing, you can see an update-to-date use that's nearly identical to the mock here: http://rickyreusser.com/animation-experiments/#updatemenus |
b6e4653
to
f8fba32
Compare
@@ -43,12 +43,12 @@ module.exports = function draw(gd) { | |||
* <g item header /> | |||
* <text item header-arrow /> | |||
* <g header-group /> | |||
* <g item header /> |
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.
AHHHH stupid vim plugin. It mangles html tags when you scroll incorrectly… restoring these.
💃 This looks amazing @rreusser can you update the introduction comment block for future reference to this PR (it's still showing As a side note, I'm kind of kicking myself for not naming the update menu |
Oh and by the way, I added #974 (comment) to #810 - if ever we decide to implement it in the future. |
@etpinard yeah, backwards compatibility can be a burden! It's always possible to move to a new syntax and very slowly deprecate the old, but I think this is fine for the foreseeable future. |
This PR adds the following attributes to updatemenus:
type
:'buttons'
/'dropdown'
: if true, is buttons instead of dropdowndirection
:'left'
/'right'
/'up'
/'down'
: affects which way the buttons extend, though they're still ordered l-to-r or top-to-bottom. It's not inconceivable to auto-detect this when the menu would otherwise go off-screen, but I think less magic is better.showactive
: boolean. Shows active state if true. Set to false to turn the buttons into plain non-stateful buttons.See live example at: http://rickyreusser.com/animation-experiments/#updatemenus
Notably, this PR does not implement scrolling for overflow. 😞