Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/components/Navigation/Navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ $disabled-fade: 0.6;
}

.SecondaryAction {
@include recolor-icon(var(--p-icon));
@include recolor-icon($fill-color: var(--p-icon));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to named vars throughout this PR for clarity. Should make things slightly easier to figure out what's going on when we remove recolor-icon()

display: flex;
align-items: center;
height: nav(mobile-height);
Expand All @@ -206,16 +206,15 @@ $disabled-fade: 0.6;
&:focus,
&:active {
@include recolor-icon(
var(--p-icon-hovered),
transparent,
$filter-color: var(--p-action-primary)
$fill-color: var(--p-icon-hovered),
$filter-color: var(--p-filter-icon-action-primary)
);
background: var(--p-background-hovered);

@media (-ms-high-contrast: active) {
@include recolor-icon(
$fill-color: var(--p-icon-on-interactive),
$filter-color: var(--p-icon-on-interactive)
$filter-color: var(--p-filter-icon-on-interactive)
);
}
}
Expand All @@ -228,7 +227,7 @@ $disabled-fade: 0.6;

&:active {
@include no-focus-ring;
@include recolor-icon(var(--p-icon-pressed));
@include recolor-icon($fill-color: var(--p-icon-pressed));
background: var(--p-background-pressed);
}

Expand Down Expand Up @@ -358,7 +357,7 @@ $secondary-item-font-size: rem(15px);

.Action {
@include unstyled-button;
@include recolor-icon(var(--p-icon));
@include recolor-icon($fill-color: var(--p-icon));
display: flex;
align-items: center;
height: nav(mobile-nav-height);
Expand All @@ -375,18 +374,18 @@ $secondary-item-font-size: rem(15px);
&:hover,
&:focus {
background: var(--p-background-hovered);
@include recolor-icon(var(--p-icon-hovered), transparent);
@include recolor-icon($fill-color: var(--p-icon-hovered));

@media (-ms-high-contrast: active) {
@include recolor-icon(
$fill-color: var(--p-icon-on-interactive),
$filter-color: var(--p-icon-on-interactive)
$filter-color: var(--p-filter-icon-on-interactive)
);
}
}

&:hover {
@include recolor-icon($filter-color: var(--p-icon-on-interactive));
@include recolor-icon($filter-color: var(--p-filter-icon));
}

&:focus {
Expand All @@ -401,7 +400,7 @@ $secondary-item-font-size: rem(15px);
// stylelint-disable-next-line selector-max-specificity
&:active,
&:active:hover {
@include recolor-icon(var(--p-icon-pressed));
@include recolor-icon($fill-color: var(--p-icon-pressed));
background: var(--p-background-pressed);
@include no-focus-ring;
}
Expand All @@ -419,9 +418,8 @@ $secondary-item-font-size: rem(15px);

&:hover {
@include recolor-icon(
var(--p-action-primary),
null,
$filter-color: var(--p-icon-on-interactive)
$fill-color: var(--p-action-primary),
$filter-color: var(--p-filter-icon-action-primary)
);
color: var(--p-text-primary);
}
Expand Down
9 changes: 7 additions & 2 deletions src/components/Navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Use to present a navigation menu in the [frame](https://polaris.shopify.com/comp
<Navigation.Section
items={[
{
url: '/path/to/place',
url: '/',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always have one active items in the nav within the admin. This change reflects that int he basic example

label: 'Home',
icon: HomeMajor,
},
Expand Down Expand Up @@ -202,7 +202,7 @@ Use to present a secondary action, related to a section and to title the section
<Navigation.Section
items={[
{
url: '/',
url: '/path/to/place',
Copy link
Member Author

@kyledurand kyledurand Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had two active items in this example which should never happen. Undoing this one since the example is for selected secondary, which is below

label: 'Home',
icon: HomeMajor,
},
Expand Down Expand Up @@ -495,6 +495,11 @@ This example showcases the many elements that can compose a navigation, especial
label: 'Icon as img',
icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.791 2.253l-.597 3.583A1 1 0 0 0 2.18 7h.893a1.5 1.5 0 0 0 1.342-.83L5 5l.585 1.17A1.5 1.5 0 0 0 6.927 7h1.146a1.5 1.5 0 0 0 1.342-.83L10 5l.585 1.17a1.5 1.5 0 0 0 1.342.83h1.146a1.5 1.5 0 0 0 1.342-.83L15 5l.585 1.17a1.5 1.5 0 0 0 1.342.83h.893a1 1 0 0 0 .986-1.164l-.597-3.583A1.5 1.5 0 0 0 16.729 1H3.271a1.5 1.5 0 0 0-1.48 1.253zM4 18.5A1.5 1.5 0 0 1 5.5 17H8v-3h4v3h2.5a1.5 1.5 0 0 1 1.5 1.5v.5H4v-.5z"></path><path d="M2 9h2v4h12V9h2v4.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 2 13.5V9z"></path></svg>',
},
{
url: '/',
label: 'Icon as img – Active',
icon: '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.791 2.253l-.597 3.583A1 1 0 0 0 2.18 7h.893a1.5 1.5 0 0 0 1.342-.83L5 5l.585 1.17A1.5 1.5 0 0 0 6.927 7h1.146a1.5 1.5 0 0 0 1.342-.83L10 5l.585 1.17a1.5 1.5 0 0 0 1.342.83h1.146a1.5 1.5 0 0 0 1.342-.83L15 5l.585 1.17a1.5 1.5 0 0 0 1.342.83h.893a1 1 0 0 0 .986-1.164l-.597-3.583A1.5 1.5 0 0 0 16.729 1H3.271a1.5 1.5 0 0 0-1.48 1.253zM4 18.5A1.5 1.5 0 0 1 5.5 17H8v-3h4v3h2.5a1.5 1.5 0 0 1 1.5 1.5v.5H4v-.5z"></path><path d="M2 9h2v4h12V9h2v4.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 2 13.5V9z"></path></svg>',
},
{
url: '/path/to/place',
label: 'Other secondary action',
Expand Down
22 changes: 15 additions & 7 deletions src/components/Navigation/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ $nav-animation-variables: (
// hardcoding this variable for now because we need to rip out all instances
// of filter() eventually but can't for this one right now. The value is the
// equivalent value for filter('icon').
--p-icon-filter: brightness(0) saturate(100%) invert(36%) sepia(13%)
--p-filter-icon: brightness(0) saturate(100%) invert(36%) sepia(13%)
saturate(137%) hue-rotate(169deg) brightness(95%) contrast(87%);

@include recolor-icon(var(--p-icon), transparent, var(--p-icon-filter));
--p-filter-icon-action-primary: brightness(0) saturate(100%) invert(20%)
sepia(59%) saturate(5557%) hue-rotate(162deg) brightness(95%) contrast(101%);
--p-filter-icon-on-interactive: brightness(0) saturate(100%) invert(100%);
Comment on lines +83 to +87
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks @kyledurand.


@include recolor-icon(
$fill-color: var(--p-icon),
$filter-color: var(--p-filter-icon)
);
flex-shrink: 0;
align-self: flex-start;
width: nav(icon-size);
Expand All @@ -99,7 +105,10 @@ $nav-animation-variables: (

.Item:hover &,
.Item.keyFocused & {
@include recolor-icon(var(--p-icon), transparent, var(--p-icon));
@include recolor-icon(
$fill-color: var(--p-icon),
$filter-color: var(--p-filter-icon)
);
}

.Item-selected &,
Expand All @@ -108,9 +117,8 @@ $nav-animation-variables: (
.subNavigationActive:hover &,
.Item-selected.keyFocused & {
@include recolor-icon(
var(--p-action-primary),
transparent,
var(--p-icon-on-interactive)
$fill-color: var(--p-action-primary),
$filter-color: var(--p-filter-icon-action-primary)
);
}

Expand Down