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

fix: Allow Breadcrumb items to wrap #2869

Merged
merged 6 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-penguins-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

fix: Allow breadcrumb items to wrap.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/components/primer/beta/breadcrumbs.pcss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.breadcrumb-item {
display: inline-block;
margin-left: -0.35em;
white-space: nowrap;
Copy link
Member

Choose a reason for hiding this comment

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

If I recall correctly, I think this was put in because of the truncation that's sometimes used with the breadcrumbs. Could you write a lookbook preview with the truncate-css and Truncate component to see if there's any bad effects there?

Copy link
Member Author

@smockle smockle May 28, 2024

Choose a reason for hiding this comment

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

Sure! To clarify, are you asking for two stories—one using primer/css’ truncate and one using primer/view_components’ Truncate? Or, does the Truncate component use the truncate CSS under-the-hood, such that only a single story is necessary?

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 you could use the deprecated Primer::Truncate for the CSS one and the Primer::Beta::Truncate for the standard way.

Copy link
Member Author

@smockle smockle May 29, 2024

Choose a reason for hiding this comment

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

Stories added!

I don’t see any bad effects from removing white-space: nowrap.

list-style: none;

&::after {
Expand Down
12 changes: 12 additions & 0 deletions previews/primer/beta/breadcrumbs_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def default(number_of_links: 2)
end
end
end

# @label WithBetaTruncate
# @snapshot
def with_beta_truncate
render_with_template
end

# @label WithDeprecatedTruncate
# @snapshot
def with_deprecated_truncate
render_with_template
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% texts = [
"Breadcrumb Item 1",
"Breadcrumb Item 2 with a really long, long, long name",
"Breadcrumb Item 3 with an extremely long, long, long name"
] %>

<%= render(Primer::Beta::Breadcrumbs.new) do |breadcrumbs| %>
<% texts.each_with_index do |text, i| %>
<% breadcrumbs.with_item(href: "##{i}") do %>
<%= render(Primer::Beta::Truncate.new) do |truncate| %>
<% truncate.with_item(max_width: 135) { text } %>
<% end %>
<% end %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%# erblint:counter DeprecatedComponentsCounter 1 %>
<% texts = [
"Breadcrumb Item 1",
"Breadcrumb Item 2 with a really long, long, long name",
"Breadcrumb Item 3 with an extremely long, long, long name"
] %>

<%= render(Primer::Beta::Breadcrumbs.new) do |breadcrumbs| %>
<% texts.each_with_index do |text, i| %>
<% breadcrumbs.with_item(href: "##{i}") do %>
<%= render(Primer::Truncate.new(inline: true, max_width: 135)) { text } %>
<% end %>
<% end %>
<% end %>
Loading