-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 new .Truncate class and deprecating css-truncate #1358
Conversation
🦋 Changeset detectedLatest commit: e4ee5f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Currently it's possible to truncate a single element with <span class="Truncate Truncate-text">Truncate some text</span> Or just use <span class="Truncate">Truncate some text</span>
<span class="Truncate Truncate--multiple">
<span class="Truncate-item">Truncate item 1</span>
<span class="Truncate-item">Truncate item 2</span>
<span class="Truncate-item">Truncate item 3</span>
</span>
We might need to do some testing but it should be fine as long as we don't use
This doesn't seem to work and Not sure if it possible to also truncate Here a Codepen from trying to fix the file header https://github.com/github/github/issues/117827#issuecomment-514511496. Also relies on |
The compatibility issue |
I made some updates: preview
ooo, that's a bad bug, I'm removing the
This is fixed using Issues with grid support aside I'm not convinced it's a better alternative to flexbox here. I think flexbox gives us some more options about what parts of a string we truncate. see second example |
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.
This is fixed using
flex-basis
These multi .Truncate-text--primary
are pretty neat. 😍
Something I was wondering in Slack was if we should allow simple cases like <span class="Truncate Truncate-text">some text</span>
. Without the need for an extra nested element just to truncate some text. But as long as we only use the Truncate
ViewComponent it might be fine as is.
This PR re-writes
css-truncate
https://primer.style/view-components/components/truncate into a flexbox driven solution.Doing so gives us these advantages over the previous solution:
max-width
is no longer needed to truncate and we don't need the magic135px
hardcoded.👍🏻.Truncate
can do a reverse truncate where the...
shows up at the beginning instead of the end..Truncate
can have multiple items with a "primary" item that doesn't truncate at the same speed as the rest.Work based on work done by @vdepizzol https://codepen.io/vdepizzol/pen/VwPVyZa?editors=1100 In his example he used
grid
which is a nice implementation but there isn't enough support of thegrid-template-columns
property to make this work./cc @primer/ds-core