Skip to content

Commit 696c709

Browse files
committed
changed truncation to use -webkit-line-clamp
1 parent 30530df commit 696c709

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

polaris-react/src/components/Navigation/Navigation.scss

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ $disabled-fade: 0.6;
9292
.Item {
9393
@include nav-item-attributes;
9494
position: relative;
95+
96+
&:first-child {
97+
margin-left: var(--p-space-2);
98+
}
99+
100+
&:last-child {
101+
margin-right: var(--p-space-2);
102+
}
95103
}
96104

97105
.Item-selected {
@@ -195,21 +203,19 @@ $disabled-fade: 0.6;
195203
display: flex;
196204
flex-wrap: nowrap;
197205
width: 100%;
198-
margin: 0 var(--p-space-1);
199206
}
200207

201208
.Text {
202209
@include nav-item-text-attributes;
203210
}
204211

205212
.Text-truncated {
206-
width: calc(
207-
$layout-width-nav-base -
208-
(var(--pc-navigation-icon-size) + var(--p-space-4) * 6 + var(--p-space-1))
209-
);
213+
// stylelint-disable-next-line value-no-vendor-prefix
214+
display: -webkit-box;
210215
overflow: hidden;
211-
text-overflow: ellipsis;
212-
white-space: nowrap;
216+
-webkit-line-clamp: 1;
217+
-webkit-box-orient: vertical;
218+
word-break: break-all;
213219
}
214220

215221
.SecondaryAction {
@@ -218,6 +224,7 @@ $disabled-fade: 0.6;
218224
align-items: center;
219225
height: nav(mobile-height);
220226
padding: var(--p-space-1) var(--p-space-4);
227+
margin-right: var(--p-space-1);
221228
border-radius: var(--p-border-radius-1);
222229

223230
@media #{$p-breakpoints-md-up} {

polaris-react/src/components/Navigation/Navigation.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,22 @@ export function WithTruncationForVariousStates() {
284284
badge: 'Old',
285285
icon: HomeMinor,
286286
},
287+
{
288+
url: '/path/to/place',
289+
label: 'Lengthy label with secondary action',
290+
icon: OrdersMinor,
291+
selected: false,
292+
truncateText: true,
293+
badge: 'Old',
294+
secondaryAction: {
295+
url: '/admin/orders/add',
296+
accessibilityLabel: 'Add an order',
297+
icon: CirclePlusOutlineMinor,
298+
tooltip: {
299+
content: 'Add a lengthy order',
300+
},
301+
},
302+
},
287303
{
288304
url: '/admin/products',
289305
label: 'Truncated secondary navigation items',

polaris-react/src/components/Navigation/_variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $nav-animation-variables: (
2828
align-items: flex-start;
2929
max-width: 100%;
3030
padding: 0 var(--p-space-1) 0 var(--p-space-3);
31-
margin-left: var(--p-space-1);
31+
margin: 0;
3232
border-radius: var(--p-border-radius-1);
3333
color: var(--p-text);
3434
text-decoration: none;

0 commit comments

Comments
 (0)