getodk / central-frontend

Vue.js based frontend for ODK Central
https://docs.getodk.org/central-intro/
Apache License 2.0
32 stars 57 forks source link

Truncate long display name in navbar #928

Closed matthew-white closed 7 months ago

matthew-white commented 8 months ago

Closes #348.

If the user's display name is less than 275px, then it should look exactly like it does today. If it is 275px or more, then it should be truncated:

What has been done to verify that this works as intended?

I tried it out locally.

Why is this the best possible solution? Were any other approaches considered?

275px is a bit long, but there are places in Central where we allow text to go 250px before truncation. There's room in the navbar, and I think it's nice to avoid truncation in this case, so I opted for a little more than 250px. Especially if we ever add more to the navbar, I think we could also consider removing the name from the navbar and using generic text like "My Account".

In terms of the code, the hardest part was keeping the icon on the left, the text, and the caret on the right aligned. I was initially running into issues there, but vertical-align: top; did the trick. I also briefly tried a flexbox strategy, but I found myself having to do some manual alignment.

Before submitting this PR, please make sure you have: