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

adding custom width support to meter and progressbar #1560

Merged
merged 12 commits into from Apr 20, 2021

Conversation

ktabors
Copy link
Member

@ktabors ktabors commented Feb 9, 2021

Closes #1192

Changed the width to min-width and added inline size.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Goto the meter and/or progress bar stories
Check out the new width stories
Also check the other stories like side labels without width because that was a problem case when making the change.

🧢 Your Project:

RSP

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

snowystinger
snowystinger previously approved these changes Feb 9, 2021
Copy link
Member

@snowystinger snowystinger 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 in chrome/safari/ff on mac

@@ -18,15 +18,17 @@ governing permissions and limitations under the License.
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
width: var(--spectrum-barloader-large-width);
min-width: var(--spectrum-barloader-large-width);
Copy link
Member

Choose a reason for hiding this comment

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

Just wanna double check: did we check w/ spectrum regarding this min-width here? I noticed that spectrum css has a min-width of 192px applied to their progress bars but only if it has a side label not if the label is on top. You can try it out by modifying the widths here

IMO we should def have a min-width so that weird label and number value stacking doesn't happen but do we want a smaller value? 192px feels kinda large. This is 100px:
image

Comment on lines 162 to 163
'width: 30px, labelPosition: side, isIndeterminate: true',
() => render({width: '30px', labelPosition: 'side', isIndeterminate: true})
Copy link
Member

Choose a reason for hiding this comment

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

I think the css for the labelPosition: side will need to account for the case in which the width applied is less than the min-width. At the moment the wrapping div (.spectrum-BarLoader) will be of width 192px, but that doesn't account for the label width and thus the following can happen when there are sibling elements (aka the button is hidden by the progress bar):
image

Copy link
Member

Choose a reason for hiding this comment

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

I think spectrum-css styles might suffer from the same issue. Maybe a min-width: fit-content and have the label have a max width so it calculates properly? Open to opinions for this one

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

Copy link
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.

Overall looks fine to me, just one question though

Comment on lines 26 to 28
&.spectrum-BarLoader--indeterminate {
max-width: var(--spectrum-barloader-large-width);
}
Copy link
Member

Choose a reason for hiding this comment

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

Where did this come from?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeterminate progress bars are locked to 192px until we change the animations to work with custom widths.

Copy link
Member

Choose a reason for hiding this comment

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

gotcha, that should fine then

LFDanLu
LFDanLu previously approved these changes Feb 23, 2021
Comment on lines 71 to 75
min-width: fit-content;

.spectrum-BarLoader-track {
width: auto;
}
Copy link
Member

Choose a reason for hiding this comment

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

while one of these seems needed, where is this coming from?
also, line 70 has inline-size: auto, which is width: auto, i'm surprised it's needed for sideLabel and for track? lets be consistent and use inline-size
we can also use inline-size anywhere we have width, so min-width -> min-inline-size

Copy link
Member Author

Choose a reason for hiding this comment

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

So this line prevents the long label, labelPosition: side story from having a track larger than 192px. I appears the track auto width without the auto width in the side label parent works just fine, so I'll remove that. And I'll update to inline-size. :)

@adobe-bot
Copy link

Build successful! 🎉

@@ -18,15 +18,21 @@ governing permissions and limitations under the License.
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
width: var(--spectrum-barloader-large-width);
min-inline-size: var(--spectrum-barloader-large-width);
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to restrict the meter/progressbar size so that it must be greater than 192px?
I feel like we had discussed this before but I can't find that discussion anymore (and of course I resolved my own comment previously without adding details zzzz).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was at direction from Spectrum when this component was first created, but I can't find that historical knowledge.

Copy link
Member Author

@ktabors ktabors Mar 29, 2021

Choose a reason for hiding this comment

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

min width 48px in both scales. https://jira.corp.adobe.com/browse/SDS-5040

@devongovett devongovett added the waiting Waiting on Issue Author label Mar 18, 2021
@ktabors ktabors removed the waiting Waiting on Issue Author label Apr 15, 2021
@@ -18,15 +18,27 @@ governing permissions and limitations under the License.
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
width: var(--spectrum-barloader-large-width);
min-inline-size: 48px;
Copy link
Member Author

Choose a reason for hiding this comment

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

DNA hasn't created a token so I'm using 48px. Is there a different token I should use?

Copy link
Member

Choose a reason for hiding this comment

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

size-600 is 48px at medium

Copy link
Member Author

Choose a reason for hiding this comment

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

used 600 static because they want 48px for medium and large scales.

@adobe-bot
Copy link

Build successful! 🎉

() => render({width: '30px', labelPosition: 'side', label: 'Super long progress bar label. Sample label copy. Loading...'})
)
.add(
'width: 30px, labelPosition: side, isIndeterminate: true, long label, button on left',
Copy link
Member

Choose a reason for hiding this comment

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

button is on the right?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@adobe-bot
Copy link

Build successful! 🎉

snowystinger
snowystinger previously approved these changes Apr 19, 2021
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

lgtm

@adobe-bot
Copy link

Build successful! 🎉

@ktabors
Copy link
Member Author

ktabors commented Apr 19, 2021

lgtm

I found a bug

@snowystinger
Copy link
Member

what's the bug?

@ktabors
Copy link
Member Author

ktabors commented Apr 19, 2021

what's the bug?

The track is 48px in this story, not 192px. indeterminate should always be 192px.
https://reactspectrum.blob.core.windows.net/reactspectrum/6c80d7aa00642ebdb13e63c61f08d71041bf12ba/storybook/index.html?path=/story/progress-progressbar--width-30px-labelposition-side-isindeterminate-true-long-label-button-on-right

It's now back so indeterminate is always 192px. I just pushed a fix.

@adobe-bot
Copy link

Build successful! 🎉

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

gotcha, now it looks right

@devongovett
Copy link
Member

indeterminate should always be 192px

Why? It seems weird that indeterminate would have a different behavior from determinate. Especially if someone changed between them at runtime.

@snowystinger
Copy link
Member

@devongovett yep, I'd love for them to be any width too adobe/spectrum-css#497

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Ok going to merge this. Not sure how common the case of switching between indeterminate and determinate is, but we should follow up on that.

@devongovett devongovett merged commit 113b3c9 into main Apr 20, 2021
@devongovett devongovett deleted the progress_bar_width branch April 20, 2021 23:21
majornista pushed a commit to majornista/react-spectrum-v3 that referenced this pull request May 19, 2021
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.

Meter's progress bar doesn't grow beyond 192px wide
5 participants