Skip to content

Commit 7c9fed7

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

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

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

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

97103
.Item-selected {
@@ -195,21 +201,18 @@ $disabled-fade: 0.6;
195201
display: flex;
196202
flex-wrap: nowrap;
197203
width: 100%;
198-
margin: 0 var(--p-space-1);
199204
}
200205

201206
.Text {
202207
@include nav-item-text-attributes;
203208
}
204209

205210
.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-
);
211+
display: -webkit-box;
210212
overflow: hidden;
211-
text-overflow: ellipsis;
212-
white-space: nowrap;
213+
-webkit-line-clamp: 1;
214+
-webkit-box-orient: vertical;
215+
word-break: break-all;
213216
}
214217

215218
.SecondaryAction {
@@ -218,6 +221,7 @@ $disabled-fade: 0.6;
218221
align-items: center;
219222
height: nav(mobile-height);
220223
padding: var(--p-space-1) var(--p-space-4);
224+
margin-right: var(--p-space-1);
221225
border-radius: var(--p-border-radius-1);
222226

223227
@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)