Skip to content

Commit 9683209

Browse files
committed
created a wrapper to allow the nav item with its secondary actions to highlight uniformly
1 parent ed3da74 commit 9683209

File tree

3 files changed

+56
-50
lines changed

3 files changed

+56
-50
lines changed

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

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,11 @@ $disabled-fade: 0.6;
9292
.Item {
9393
@include nav-item-attributes;
9494
position: relative;
95-
96-
margin-inline-start: var(--p-space-2);
97-
98-
&:last-child {
99-
margin-inline-end: var(--p-space-2);
100-
}
10195
}
10296

10397
.Item-selected {
10498
font-weight: var(--p-font-weight-semibold);
10599
color: var(--p-text-primary);
106-
background-color: var(--p-background-selected);
107100
outline: var(--p-border-width-1) solid transparent;
108101

109102
&::before {
@@ -118,25 +111,6 @@ $disabled-fade: 0.6;
118111
border-bottom-right-radius: var(--p-border-radius-1);
119112
}
120113

121-
@include focus-ring;
122-
123-
&:hover,
124-
&.keyFocused {
125-
background-color: var(--p-background-hovered);
126-
color: var(--p-text-primary-hovered);
127-
}
128-
129-
.keyFocused {
130-
@include focus-ring($style: 'focused');
131-
}
132-
133-
&:active,
134-
&:active:hover {
135-
@include no-focus-ring;
136-
color: var(--p-text-primary);
137-
background-color: var(--p-background-pressed);
138-
}
139-
140114
@media #{$p-breakpoints-md-up} {
141115
font-weight: var(--p-font-weight-medium);
142116
}
@@ -198,9 +172,41 @@ $disabled-fade: 0.6;
198172
}
199173

200174
.ItemWrapper {
175+
width: 100%;
176+
padding: 0 var(--p-space-2);
177+
}
178+
179+
.ItemInnerWrapper {
201180
display: flex;
202181
flex-wrap: nowrap;
203182
width: 100%;
183+
&:hover {
184+
background: var(--p-background-hovered);
185+
color: var(--p-text);
186+
text-decoration: none;
187+
}
188+
}
189+
190+
.ItemInnerWrapper-Selected {
191+
background-color: var(--p-background-selected);
192+
@include focus-ring;
193+
194+
&:hover,
195+
&.keyFocused {
196+
background-color: var(--p-background-hovered);
197+
color: var(--p-text-primary-hovered);
198+
}
199+
200+
.keyFocused {
201+
@include focus-ring($style: 'focused');
202+
}
203+
204+
&:active,
205+
&:active:hover {
206+
@include no-focus-ring;
207+
color: var(--p-text-primary);
208+
background-color: var(--p-background-pressed);
209+
}
204210
}
205211

206212
.Text {
@@ -234,7 +240,6 @@ $disabled-fade: 0.6;
234240
align-items: center;
235241
height: nav(mobile-height);
236242
padding: var(--p-space-1) var(--p-space-4);
237-
margin-right: var(--p-space-1);
238243
border-radius: var(--p-border-radius-1);
239244

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

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ $nav-animation-variables: (
3434
text-decoration: none;
3535
text-align: left;
3636

37-
&:hover {
38-
background: var(--p-background-hovered);
39-
color: var(--p-text);
40-
text-decoration: none;
41-
}
42-
4337
@include focus-ring;
4438

4539
&.keyFocused {

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,25 +315,32 @@ export function Item({
315315
return (
316316
<li className={className}>
317317
<div className={styles.ItemWrapper}>
318-
<UnstyledLink
319-
url={url}
320-
className={itemClassName}
321-
external={external}
322-
tabIndex={tabIndex}
323-
aria-disabled={disabled}
324-
aria-label={accessibilityLabel}
325-
onClick={getClickHandler(onClick)}
326-
onKeyUp={handleKeyUp}
327-
onBlur={handleBlur}
328-
{...normalizeAriaAttributes(
329-
secondaryNavigationId,
330-
subNavigationItems.length > 0,
331-
showExpanded,
318+
<div
319+
className={classNames(
320+
styles.ItemInnerWrapper,
321+
selected && styles['ItemInnerWrapper-Selected'],
332322
)}
333323
>
334-
{itemContentMarkup}
335-
</UnstyledLink>
336-
{secondaryActionMarkup}
324+
<UnstyledLink
325+
url={url}
326+
className={itemClassName}
327+
external={external}
328+
tabIndex={tabIndex}
329+
aria-disabled={disabled}
330+
aria-label={accessibilityLabel}
331+
onClick={getClickHandler(onClick)}
332+
onKeyUp={handleKeyUp}
333+
onBlur={handleBlur}
334+
{...normalizeAriaAttributes(
335+
secondaryNavigationId,
336+
subNavigationItems.length > 0,
337+
showExpanded,
338+
)}
339+
>
340+
{itemContentMarkup}
341+
</UnstyledLink>
342+
{secondaryActionMarkup}
343+
</div>
337344
</div>
338345
{secondaryNavigationMarkup}
339346
</li>

0 commit comments

Comments
 (0)