Skip to content

Commit a38b1fa

Browse files
nabihaalikhanjuzser
authored andcommitted
fixing badges in polaris (Shopify#7769)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? Fixes https://github.com/Shopify/core-workflows/issues/516 <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? This PR changes the spacing of some polaris components, specifcally the badges when there is a secondary item involved. After the merging of this pr, the Polaris Navigation.Item component will be successfully updated to follow our new spacing parameters and the right-aligned icons (top-level nav items, pinned item's secondary actions, pin button) will still be correctly aligned after the Polaris update. <!-- Summary of the changes committed. Before / after screenshots are appreciated for UI changes. Make sure to include alt text that describes the screenshot. If you include an animated gif showing your change, wrapping it in a details tag is recommended. Gifs usually autoplay, which can cause accessibility issues for people reviewing your PR: <details> <summary>Summary of your gif(s)</summary> <img src="..." alt="Description of what the gif shows"> </details> --> <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) - Go on the polaris landing page and you will be able to see the different components. The spacing should look correct now. <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 246c992 commit a38b1fa

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

.changeset/tender-kings-approve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Updated badge spacing to right align with secondary action icons

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,17 @@ $disabled-fade: 0.6;
159159
margin-left: var(--p-space-2);
160160
display: inline-flex;
161161
margin-top: var(--p-space-2);
162+
margin-right: var(--p-space-2);
162163

163164
@media #{$p-breakpoints-md-up} {
164165
margin-top: var(--p-space-1);
165166
}
166167
}
167168

169+
.ListItem-hasAction .Badge {
170+
margin-right: 0;
171+
}
172+
168173
.Icon {
169174
@include nav-item-icon-attributes;
170175
}

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,3 +606,95 @@ export function UsingMajorIcons() {
606606
</Frame>
607607
);
608608
}
609+
610+
export function WithBadgeAndSecondaryAction() {
611+
return (
612+
<Frame>
613+
<Navigation location="/">
614+
<Navigation.Section
615+
items={[
616+
{
617+
url: '/path/to/place',
618+
label: 'Home',
619+
icon: HomeMinor,
620+
secondaryAction: {
621+
url: '/path/to/place/view',
622+
accessibilityLabel: 'View your online store',
623+
icon: ViewMinor,
624+
tooltip: {
625+
content: 'View your online store',
626+
},
627+
},
628+
},
629+
{
630+
url: '/path/to/place',
631+
label: 'Orders',
632+
icon: OrdersMinor,
633+
badge: '15',
634+
subNavigationItems: [
635+
{
636+
url: '/admin/orders/collections',
637+
disabled: false,
638+
selected: false,
639+
label: 'Collections',
640+
},
641+
{
642+
url: '/admin/orders/inventory',
643+
disabled: false,
644+
label: 'Inventory',
645+
},
646+
],
647+
},
648+
{
649+
url: '/path/to/place',
650+
label: 'Marketing',
651+
icon: MarketingMinor,
652+
badge: '15',
653+
secondaryAction: {
654+
url: '/path/to/place/view',
655+
accessibilityLabel: 'View your online store',
656+
icon: ViewMinor,
657+
tooltip: {
658+
content: 'View your online store',
659+
},
660+
},
661+
subNavigationItems: [
662+
{
663+
url: '/admin/analytics/collections',
664+
disabled: false,
665+
selected: false,
666+
label: 'Reports',
667+
},
668+
{
669+
url: '/admin/analytics/inventory',
670+
disabled: false,
671+
label: 'Live view',
672+
},
673+
],
674+
},
675+
{
676+
url: '/admin/products',
677+
label: 'Products',
678+
icon: ProductsMinor,
679+
selected: true,
680+
subNavigationItems: [
681+
{
682+
url: '/?path=/story/all-components-navigation--navigation-with-multiple-secondary-navigations',
683+
disabled: false,
684+
selected: false,
685+
label: 'Collections',
686+
},
687+
{
688+
url: '/admin/products/inventory',
689+
disabled: false,
690+
selected: true,
691+
label: 'Inventory',
692+
},
693+
],
694+
},
695+
]}
696+
/>
697+
</Navigation>
698+
</Frame>
699+
);
700+
}

0 commit comments

Comments
 (0)