Skip to content

Button Group#358

Merged
devongovett merged 24 commits intomasterfrom
btn-vert
Apr 3, 2020
Merged

Button Group#358
devongovett merged 24 commits intomasterfrom
btn-vert

Conversation

@dannify
Copy link
Copy Markdown
Member

@dannify dannify commented Apr 3, 2020

No description provided.

Copy link
Copy Markdown
Member Author

@dannify dannify left a comment

Choose a reason for hiding this comment

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

@LFDanLu Updates to your ButtonGroup pr. Let's talk about this tomorrow.

/* this padding should be safe as button group is always end aligned */
padding-inline-start: var(--spectrum-dialog-gap-size);

&.spectrum-Dialog-buttonGroup--noFooter {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This messes up the width of the buttons when vertical. @snowystinger please halp

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

LFDanLu
LFDanLu previously approved these changes Apr 3, 2020
Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM, still need to digest the useEffect stuff a bit

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

LFDanLu
LFDanLu previously approved these changes Apr 3, 2020
Copy link
Copy Markdown
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Ok button width looks fine in Dialog for vertical stacked ButtonGroups

@dannify dannify changed the title Button Group wip Button Group Apr 3, 2020
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is supposed to stay?

display: inline-flex;
/* Added this so it would wrap */
flex-wrap: wrap;
align-items: flex-end;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should all button groups flex end? or should this be something from slots?
maybe flex end is a good default and if needed, people can do flex-start through a new class

flex-shrink: 0;
}

> .spectrum-Rule--vertical {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

spectrum rule shouldn't be in this file? nor should tool, action button, or button. They'll have different names than their counterparts in the the button css file and the divider css file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

kk removed

}

> .spectrum-Rule--vertical {
block-size: auto;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this here?


.spectrum-Button + .spectrum-Button {
margin-left: var(--spectrum-buttongroup-button-gap-x);
margin-inline-start: var(--spectrum-buttongroup-button-gap-x);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@devongovett can we use your Flex gap stuff?

Comment on lines +50 to +61
useEffect(() => {
if (orientation !== 'vertical') {
if (scale !== lastScale) {
if (lastScale === 'large' && scale === 'medium') {
setHasOverflow(false);
} else {
checkForOverflow();
}
}
lastScale = scale;
}
}, [setHasOverflow, checkForOverflow, scale, orientation]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this will have some trouble if children are added/removed or if the locale changes or if any strings change

example where that might happen, confirm button in dialog is pressed, it performs an async action before closing, and while it does that, it displays a spinner and says wait while disabled. If the buttons were horizontal and the wait made it wrap, then we'd end up in a situation that doesn't look very good

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We may need to use a MutationObserver https://caniuse.com/#feat=mutationobserver because the internal change in the confirm button to display a wait spinner may not trigger anything here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When a change occurs, we'll need to remove the vertical class, useLayoutEffect to see if there's overflow and quickly reapply the vertical class if there is overflow

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

state shouldBeVertical, setShouldBeVertical = default false

useLayoutEffect:
  setShouldBeVertical(checkForOverflow)
deps: shouldBeVertical

useEffect:
  children updated?
  setShouldBeVerticalFalse
deps: children


useEffect(() => {
if (orientation !== 'vertical') {
// I think performance could be optimized here by creating a global, debounced hook for listening to resize
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should probably make a useDebouncedResize hook or something with a single listener in it, we can probably put that off for now though, right now it's buttongroup, tabs, breadcrumbs, none of which are likely to have a lot of instances on a page at once

slots={{
button: {
isDisabled,
UNSAFE_className: classNames(styles, 'spectrum-Button')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this classname should be renamed to spectrum-ButtonGroup-button

if (Component === V2ButtonGroup) {
return render(
<Provider theme={theme}>
<V2ButtonGroup data-testid={buttonGroupId} {...props}>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are any tests testing this? i think we can get rid of the V2 parity, it's pretty different in implementation no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can remove the v2 stuff

* The axis the ButtonGroup should align with.
* @default "horizontal"
*/
orientation?: Orientation,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it be mentioned that if vertical is used, no reflow will happen, it'll just always be vertical. But if horizontal is used, then reflow to vertical will happen?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be documented in the docs, I'll say something like "See the docs for reflow behavior".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

will be easier to link to it from here

}



Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove?

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@adobe-bot
Copy link
Copy Markdown

Build successful! 🎉

@devongovett devongovett merged commit 33294b7 into master Apr 3, 2020
@devongovett devongovett deleted the btn-vert branch April 3, 2020 23:47
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.

6 participants