Skip to content

Jump Bar Overflow Accordion Effect #2045

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

swiftlysingh
Copy link

@swiftlysingh swiftlysingh commented May 14, 2025

Description

This PR introduces an initial implementation of an accordion-like effect for displaying file paths in the tab bar. The goal is to improve usability when file paths are too long to fit in the available space.

Current (Draft) Behavior:

  • The accordion effect is always shown, regardless of whether the file path is truncated.

Expected Behavior:

  • The accordion effect should only be triggered when a file path is truncated due to limited space in the scroll view.
  • If the file path fits within the visible area, the full path should be shown without any animation or effect.

Request for Feedback:

  • I would appreciate guidance on the best way to detect when a file path is actually truncated, so the effect only triggers in those cases.
  • Feedback on the user experience and any edge cases to consider is also welcome.

Related Issues


Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screen.Recording.2025-05-13.at.9.32.18.PM.mov

@swiftlysingh
Copy link
Author

@austincondiff — would love your input on this!

@austincondiff
Copy link
Collaborator

austincondiff commented May 14, 2025

@swiftlysingh Thanks so much for putting this together! This is a great start and really exciting to see it in action. Watching the screen recording, I think you're definitely on the right track. The basic accordion behavior is there, and the hover interaction feels pretty good, especially when you get to the animation.

As you mentioned, the accordion behavior should only kick in when the content overflows. You’ll want to detect when the full breadcrumb path exceeds the available width of the container.

A few things you might consider:

  • Use .background(GeometryReader { proxy in ... }) to measure the actual width of the rendered text.
  • Compare that to the width of the container (likely via another GeometryReader or a .frame modifier bound to a @State).
  • If the content is wider, toggle a @State variable like isTruncated = true and show the shadow/text fade-out.
  • And as you are aware, when there’s enough room, we should render the full text without any icon-only compression.
  • Make sure the last item gets priority and hides last.

When you do expand on hover, to make it feel smooth:

withAnimation(.easeInOut(duration: 0.2)) {
    // toggle view state
}

Thanks again for your work here! Happy to additional help if needed. Feel free to reach out on Discord in the help channel if you need another resource.

@swiftlysingh
Copy link
Author

swiftlysingh commented May 14, 2025

Got everything working! 🎉

I've attached a screen recording for reference:

Screen.Recording.2025-05-14.at.1.23.00.PM.mov

We can further tweak the curve at which the crumbs collapse, as well as set the minimum threshold for the crumb width.

Big thanks to @austincondiff for your help and input!

Feedback and suggestions are always welcome.

@swiftlysingh swiftlysingh marked this pull request as ready for review May 14, 2025 20:28
@austincondiff
Copy link
Collaborator

That looks very nice, @swiftlysingh. Great work!

Minor feedback: If you compare to Xcode, you see how the text fades out at the trailing edge when truncated. I'd try to do something similar if you can. Also, layout priority is as follows:

  1. Last item
  2. First item
  3. Items in between

If there is enough room, I have gotten it in a state where all the items in between the first and last are icons, the first and last are fully visible. As I resize it to be smaller, the first item starts to be truncated until they are all icons except the last item.

When hovering over any of the truncated items, there is a fade out at the trailing edge of the last item.

You are super close, really happy with the results. 👏

@swiftlysingh
Copy link
Author

Updated the jump bar behavior with the following changes:

  • Added a firstCrumbWidth property to allow independent width adjustment for the first crumb.
  • Implemented a gradient mask on each crumb when its text is truncated, improving visual indication of truncation.

See the visual example here:

Screen.Recording.2025-05-22.at.6.27.14.AM.mov

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.

2 participants