Previews

No matching results.

x
1
2
3
4
5
<span data-view-component="true" class="Truncate">
<span style="max-width: 300px;" data-view-component="true" class="Truncate-text">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</span>
<span style="max-width: 200px;" data-view-component="true" class="Truncate-text">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</span>
<span style="max-width: 100px;" data-view-component="true" class="Truncate-text">branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long</span>
</span>
1
2
3
4
5
render(Primer::Beta::Truncate.new) do |component|
component.with_item(max_width: 300) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
component.with_item(max_width: 200) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
component.with_item(max_width: 100) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
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
31
/* Truncate */
.Truncate {
display: inline-flex;
min-width: 0;
max-width: 100%;
}
.Truncate > .Truncate-text {
min-width: 1ch;
max-width: -moz-fit-content;
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;
}