Previews

No matching results.

x
1
2
3
4
<span data-view-component="true" class="Truncate">
<span data-view-component="true" class="Truncate-text"> <span data-view-component="true" class="position-relative"><a id="truncate-link-owner" href="https://github.com" data-view-component="true" class="Link">really-long-repository-owner-name</a> <tool-tip id="tooltip-44c2a195-d305-4af9-8469-a9a21c10d3e1" for="truncate-link-owner" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">really-long-repository-owner-name</tool-tip></span></span>
<span data-view-component="true" class="Truncate-text text-bold"> <span data-view-component="true" class="position-relative"><a id="truncate-link-repo" href="https://github.com" data-view-component="true" class="Link">really-long-repository-name</a> <tool-tip id="tooltip-6a8df8eb-94a5-430c-9bcd-0e5b290b97c7" for="truncate-link-repo" popover="manual" data-direction="s" data-type="description" data-view-component="true" class="sr-only position-absolute">really-long-repository-name</tool-tip></span></span>
</span>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<%= render(Primer::Beta::Truncate.new) do |component| %>
<% component.with_item do %>
<%= render(Primer::Beta::Link.new(href: "https://github.com", id: "truncate-link-owner")) do |link| %>
<% link.with_tooltip(text: "really-long-repository-owner-name") %>
really-long-repository-owner-name
<% end %>
<% end %>
<% component.with_item(font_weight: :bold) do %>
<%= render(Primer::Beta::Link.new(href: "https://github.com", id: "truncate-link-repo")) do |link| %>
<% link.with_tooltip(text: "really-long-repository-name") %>
really-long-repository-name
<% end %>
<% end %>
<% end %>

app/components/primer/beta/truncate.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Truncate */
.Truncate {
display: inline-flex;
min-width: 0;
max-width: 100%;
}
.Truncate > .Truncate-text {
min-width: 1ch;
max-width: fit-content;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:is(.Truncate > .Truncate-text) + .Truncate-text {
/* stylelint-disable-next-line primer/spacing */
margin-left: var(--control-small-gap);
}
.Truncate-text--primary:is(.Truncate > .Truncate-text) {
flex-basis: 200%;
}
.Truncate-text--expandable:is(.Truncate > .Truncate-text):hover,.Truncate-text--expandable:is(.Truncate > .Truncate-text):focus,.Truncate-text--expandable:is(.Truncate > .Truncate-text):active {
max-width: 100% !important;
flex-shrink: 0;
cursor: pointer;
}