-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
gpui: Add line_clamp
to truncate text after a specified number of lines
#23058
Conversation
line_clamp
to truncate text after a specified number of lines.line_clamp
to truncate text after a specified number of lines
9f37e94
to
f5890c7
Compare
pub enum Truncate { | ||
/// Truncate the text without an ellipsis | ||
#[default] | ||
Truncate, |
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.
Remove Truncate
to avoid ambiguity
self | ||
} | ||
|
||
/// Sets the truncate to prevent text from wrapping and truncate overflowing text with an ellipsis (…) if needed. | ||
/// [Docs](https://tailwindcss.com/docs/text-overflow#truncate) | ||
fn truncate(mut self) -> Self { |
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.
Update truncate
to default with overflow_hidden, whitespace_nowrap, text_ellipsis
.
…number of lines.
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.
Thank you, let's merge/rebase on fresh main
and get this merged after the next release.
Release Notes:
Add this feature for some case we need keep 2 or 3 lines, but truncate. For example the blog post summary.
line_clamp
method.Ref: https://tailwindcss.com/docs/line-clamp
Break changes:
Renamed
gpui::Truncate
togpui::TextOverflow
to match CSS.Update
truncate
style method to match Tailwind CSS behavior:Show case
Describe changes
The second commit for make sure text layout to match with the line clamp. Before this change, they may wrap many lines in sometimes. And I also make line_clamp default to 1 if we used
truncate
to ensure no wrap.