Skip to content

Commit 0678a05

Browse files
committed
Navigation v11 style updates
1 parent 05910be commit 0678a05

File tree

4 files changed

+204
-6
lines changed

4 files changed

+204
-6
lines changed
Lines changed: 141 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,148 @@
11
import React from 'react';
2+
import {
3+
HomeMinor,
4+
MarketingMinor,
5+
OrdersMinor,
6+
ProductsMinor,
7+
ViewMinor,
8+
} from '@shopify/polaris-icons';
29

3-
import {Page} from '../src';
10+
import {Frame, Navigation} from '../src';
411

512
export function Playground() {
13+
const [selected, setSelected] = React.useState('home');
14+
615
return (
7-
<Page title="Playground">
8-
{/* Add the code you want to test in here */}
9-
</Page>
16+
<Frame>
17+
<Navigation location="/">
18+
<Navigation.Section
19+
items={[
20+
{
21+
url: '#',
22+
excludePaths: ['#'],
23+
label: 'Home',
24+
icon: HomeMinor,
25+
onClick: () => setSelected('home'),
26+
matches: selected === 'home',
27+
secondaryAction: {
28+
url: '#',
29+
accessibilityLabel: 'View your online store',
30+
icon: ViewMinor,
31+
tooltip: {
32+
content: 'View your online store',
33+
},
34+
},
35+
},
36+
{
37+
url: '#',
38+
excludePaths: ['#'],
39+
label: 'Orders',
40+
icon: OrdersMinor,
41+
badge: '15',
42+
onClick: () => setSelected('orders'),
43+
matches: selected === 'orders',
44+
subNavigationItems: [
45+
{
46+
url: '#',
47+
excludePaths: ['#'],
48+
disabled: false,
49+
label: 'Drafts',
50+
onClick: () => setSelected('drafts'),
51+
matches: selected === 'drafts',
52+
},
53+
{
54+
url: '#',
55+
excludePaths: ['#'],
56+
disabled: false,
57+
label: 'Shipping labels',
58+
onClick: () => setSelected('shippinglabels'),
59+
matches: selected === 'shippinglabels',
60+
},
61+
],
62+
},
63+
{
64+
url: '#',
65+
excludePaths: ['#'],
66+
label: 'Marketing',
67+
icon: MarketingMinor,
68+
badge: '15',
69+
onClick: () => setSelected('marketing'),
70+
matches: selected === 'marketing',
71+
secondaryAction: {
72+
url: '#',
73+
accessibilityLabel: 'View your online store',
74+
icon: ViewMinor,
75+
tooltip: {
76+
content: 'View your online store',
77+
},
78+
},
79+
subNavigationItems: [
80+
{
81+
url: '#',
82+
excludePaths: ['#'],
83+
disabled: false,
84+
label: 'Reports',
85+
onClick: () => setSelected('reports'),
86+
matches: selected === 'reports',
87+
},
88+
{
89+
url: '#',
90+
excludePaths: ['#'],
91+
disabled: false,
92+
label: 'Live view',
93+
onClick: () => setSelected('liveView'),
94+
matches: selected === 'liveView',
95+
},
96+
],
97+
},
98+
{
99+
url: '#',
100+
label: 'Products',
101+
icon: ProductsMinor,
102+
onClick: () => setSelected('products'),
103+
matches: selected === 'products',
104+
subNavigationItems: [
105+
{
106+
url: '#',
107+
disabled: false,
108+
label: 'Inventory',
109+
onClick: () => setSelected('inventory'),
110+
matches: selected === 'inventory',
111+
},
112+
{
113+
url: '#',
114+
disabled: false,
115+
label: 'Transfers',
116+
onClick: () => setSelected('transfers'),
117+
matches: selected === 'transfers',
118+
},
119+
{
120+
url: '#',
121+
excludePaths: ['#'],
122+
disabled: false,
123+
label: 'Collections',
124+
onClick: () => setSelected('collections'),
125+
matches: selected === 'collections',
126+
},
127+
{
128+
url: '#',
129+
disabled: false,
130+
label: 'Gift cards',
131+
onClick: () => setSelected('gift_cards'),
132+
matches: selected === 'gift_cards',
133+
},
134+
{
135+
url: '#',
136+
disabled: false,
137+
label: 'Price lists',
138+
onClick: () => setSelected('price_lists'),
139+
matches: selected === 'price_lists',
140+
},
141+
],
142+
},
143+
]}
144+
/>
145+
</Navigation>
146+
</Frame>
10147
);
11148
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ $disabled-fade: 0.6;
108108
.Item,
109109
.ItemInnerWrapper {
110110
border-radius: var(--p-border-radius-1);
111+
112+
#{$se23} & {
113+
border-radius: var(--p-border-radius-2);
114+
}
111115
}
112116

113117
.Item-selected {
@@ -127,6 +131,12 @@ $disabled-fade: 0.6;
127131
border-bottom-right-radius: var(--p-border-radius-1);
128132
}
129133

134+
#{$se23} & {
135+
&::before {
136+
display: none;
137+
}
138+
}
139+
130140
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
131141
@include focus-ring;
132142

@@ -197,6 +207,10 @@ $disabled-fade: 0.6;
197207
&:not(:first-child) {
198208
.ItemInnerWrapper {
199209
border-top: var(--p-border-width-1) solid var(--p-color-bg-app);
210+
211+
#{$se23} & {
212+
border-top: 0;
213+
}
200214
}
201215
}
202216
}
@@ -238,11 +252,19 @@ $disabled-fade: 0.6;
238252
margin-top: calc(var(--p-space-2) + var(--p-space-05));
239253
margin-bottom: calc(var(--p-space-2) + var(--p-space-05));
240254

255+
#{$se23} & {
256+
font-size: var(--p-font-size-100);
257+
}
258+
241259
@media #{$p-breakpoints-md-up} {
242260
font-size: var(--p-font-size-100);
243261
line-height: var(--p-font-line-height-2);
244262
margin-top: var(--p-space-1);
245263
margin-bottom: var(--p-space-1);
264+
265+
#{$se23} & {
266+
font-size: var(--p-font-experimental-size-80);
267+
}
246268
}
247269
}
248270

@@ -423,12 +445,29 @@ $disabled-fade: 0.6;
423445
line-height: 1;
424446
padding-left: var(--p-space-10);
425447
}
448+
449+
#{$se23} & {
450+
&:is(:hover, :focus-visible) {
451+
background: var(--p-color-experimental-bg-transparent-hover);
452+
}
453+
}
426454
}
427455

428456
.Text {
429457
margin-top: var(--p-space-1);
430458
margin-bottom: var(--p-space-1);
431459
line-height: var(--p-space-5);
460+
461+
#{$se23} & {
462+
font-weight: var(--p-font-weight-regular);
463+
color: var(--p-color-text-subdued);
464+
}
465+
}
466+
467+
#{$se23} & {
468+
.ItemInnerWrapper-selected {
469+
background-color: var(--p-color-experimental-bg-transparent-active);
470+
}
432471
}
433472

434473
.Item-selected {
@@ -449,6 +488,12 @@ $disabled-fade: 0.6;
449488
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
450489
@include no-focus-ring;
451490
}
491+
492+
#{$se23} & {
493+
.Text {
494+
color: var(--p-color-text);
495+
}
496+
}
452497
}
453498

454499
.Item-disabled {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {MouseEvent, ReactNode} from 'react';
33

44
import {useIsomorphicLayoutEffect} from '../../../../utilities/use-isomorphic-layout-effect';
55
import {classNames} from '../../../../utilities/css';
6+
import {useFeatures} from '../../../../utilities/features';
67
import {NavigationContext} from '../../context';
78
import {Badge} from '../../../Badge';
89
import {Icon} from '../../../Icon';
@@ -107,6 +108,7 @@ export function Item({
107108
const {location, onNavigationDismiss} = useContext(NavigationContext);
108109
const navTextRef = useRef<HTMLSpanElement>(null);
109110
const [isTruncated, setIsTruncated] = useState(false);
111+
const {polarisSummerEditions2023} = useFeatures();
110112

111113
useEffect(() => {
112114
if (!isNavigationCollapsed && expanded) {
@@ -284,7 +286,9 @@ export function Item({
284286
const itemClassName = classNames(
285287
styles.Item,
286288
disabled && styles['Item-disabled'],
287-
selected && canBeActive && styles['Item-selected'],
289+
polarisSummerEditions2023
290+
? (selected || childIsActive) && styles['Item-selected']
291+
: selected && canBeActive && styles['Item-selected'],
288292
showExpanded && styles.subNavigationActive,
289293
childIsActive && styles['Item-child-active'],
290294
);
@@ -376,7 +380,10 @@ export function Item({
376380
<div
377381
className={classNames(
378382
styles.ItemInnerWrapper,
379-
selected && canBeActive && styles['ItemInnerWrapper-selected'],
383+
polarisSummerEditions2023
384+
? (selected || childIsActive) &&
385+
styles['ItemInnerWrapper-selected']
386+
: selected && canBeActive && styles['ItemInnerWrapper-selected'],
380387
displayActionsOnHover &&
381388
styles['ItemInnerWrapper-display-actions-on-hover'],
382389
disabled && styles.ItemInnerDisabled,

polaris-tokens/src/token-groups/font.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ export type FontSizeScale =
1212
| '600'
1313
| '700';
1414

15+
export type FontExperimentalSizeScale = '70' | '80';
16+
1517
export type FontLineHeightScale = '1' | '2' | '3' | '4' | '5' | '6' | '7';
1618

1719
export type FontWeightAlias = 'regular' | 'medium' | 'semibold' | 'bold';
1820

1921
export type FontTokenName =
2022
| `font-family-${FontFamilyAlias}`
2123
| `font-size-${FontSizeScale}`
24+
| `font-experimental-size-${FontExperimentalSizeScale}`
2225
| `font-weight-${FontWeightAlias}`
2326
| `font-line-height-${FontLineHeightScale}`;
2427

@@ -37,9 +40,15 @@ export const font: {
3740
value:
3841
"ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace",
3942
},
43+
'font-experimental-size-70': {
44+
value: '11px',
45+
},
4046
'font-size-75': {
4147
value: '12px',
4248
},
49+
'font-experimental-size-80': {
50+
value: '13px',
51+
},
4352
'font-size-100': {
4453
value: '14px',
4554
},

0 commit comments

Comments
 (0)