Skip to content

Commit

Permalink
Updated Breadcrumb back button styling (#9733)
Browse files Browse the repository at this point in the history
<!--
  ☝️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/polaris-summer-editions/issues/947 by
overriding the styles of `Button` when in the Page Header. This follows
the same solution that the other buttons in the page [secondary actions
button groups
use](https://github.com/Shopify/polaris/blob/4d018664742bc3c9e7c4b577d31dcd05d09a2a6f/polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.scss#L8)


<!--
  Context about the problem that’s being addressed.
-->

### WHAT is this pull request doing?


https://github.com/Shopify/polaris/assets/4642404/2ecc28a3-f320-4ea7-aa41-e84f07db33c8


<!--
  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)

<!--
  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

---------

Co-authored-by: Aaron Casanova <[email protected]>
  • Loading branch information
Yuraima Estevez and aaronccasanova authored Jul 19, 2023
1 parent 4e18e79 commit 79e604b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-bats-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

empty
22 changes: 21 additions & 1 deletion polaris-react/src/components/Breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {UnstyledLink} from '../UnstyledLink';
import type {CallbackAction, LinkAction} from '../../types';
import {handleMouseUpByBlurring} from '../../utilities/focus';
import {Text} from '../Text';
import {Button} from '../Button';
import {useFeatures} from '../../utilities/features';

import styles from './Breadcrumbs.scss';

Expand All @@ -16,6 +18,7 @@ export interface BreadcrumbsProps {

export function Breadcrumbs({backAction}: BreadcrumbsProps) {
const {content} = backAction;
const {polarisSummerEditions2023} = useFeatures();

const contentMarkup = (
<>
Expand Down Expand Up @@ -52,5 +55,22 @@ export function Breadcrumbs({backAction}: BreadcrumbsProps) {
</button>
);

return <nav role="navigation">{breadcrumbMarkup}</nav>;
const summerEditionsBreadcrumbMarkup = (
<Button
key={content}
url={'url' in backAction ? backAction.url : undefined}
onPointerDown={handleMouseUpByBlurring}
aria-label={backAction.accessibilityLabel}
icon={ArrowLeftMinor}
accessibilityLabel={content}
/>
);

return (
<nav role="navigation">
{polarisSummerEditions2023
? summerEditionsBreadcrumbMarkup
: breadcrumbMarkup}
</nav>
);
}
23 changes: 23 additions & 0 deletions polaris-react/src/components/Page/components/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ $action-menu-rollup-computed-width: 40px;

.BreadcrumbWrapper {
grid-area: breadcrumbs;

#{$se23} & {
/* stylelint-disable-next-line selector-max-combinators -- SE23 match button group */
a,
button {
background-color: transparent;
border-radius: var(--p-border-radius-2);
box-shadow: none;

/* stylelint-disable-next-line selector-max-combinators -- SE23 match button group */
&:hover {
box-shadow: none;
background-color: var(--p-color-bg-strong-hover);
}

/* stylelint-disable-next-line selector-max-combinators -- SE23 match button group */
&:focus {
background-color: var(--p-color-bg-strong-active);
/* stylelint-disable-next-line declaration-no-important -- SE23 match button group */
box-shadow: var(--p-shadow-inset-md) !important;
}
}
}
}

.PaginationWrapper {
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export interface BaseButton {
/** Callback when element is touched */
onTouchStart?(): void;
/** Callback when pointerdown event is being triggered */
onPointerDown?(): void;
onPointerDown?(event: React.PointerEvent<HTMLButtonElement>): void;
}

export interface Action {
Expand Down

0 comments on commit 79e604b

Please sign in to comment.