Skip to content

Commit

Permalink
Add reverseOrder prop to AlphaStack for `flex-direction: column-rev…
Browse files Browse the repository at this point in the history
…erse` (#7842)

<!--
  ☝️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?

We need `flex-direction: column-reverse` in order to rebuild
`EmptyState`. Adding this to `AlphaStack`

Supports #7809

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

### WHAT is this pull request doing?

<!--
  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
  • Loading branch information
yurm04 committed Dec 6, 2022
1 parent 0c8fd7f commit 49ed527
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-bats-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Add flex-direction: column-reverse to AlphaStack
7 changes: 2 additions & 5 deletions polaris-react/src/components/AlphaStack/AlphaStack.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
--pc-stack-gap-xl: var(--pc-stack-gap-lg);
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
display: flex;
flex-direction: column;
// stylelint-disable-next-line -- local component custom property is required for flex direction
flex-direction: var(--pc-stack-order);
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
align-items: var(--pc-stack-align);
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
Expand All @@ -38,10 +39,6 @@
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
gap: var(--pc-stack-gap-xl);
}

> * {
max-width: 100%;
}
}

.listReset {
Expand Down
4 changes: 4 additions & 0 deletions polaris-react/src/components/AlphaStack/AlphaStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface AlphaStackProps extends React.AriaAttributes {
gap?: Gap;
/** HTML id attribute */
id?: string;
/** Toggle order of child items */
reverseOrder?: boolean;
}

export const AlphaStack = ({
Expand All @@ -45,6 +47,7 @@ export const AlphaStack = ({
fullWidth = false,
gap = '4',
id,
reverseOrder = false,
...restProps
}: AlphaStackProps) => {
const className = classNames(
Expand All @@ -55,6 +58,7 @@ export const AlphaStack = ({

const style = {
'--pc-stack-align': align ? `${align}` : '',
'--pc-stack-order': reverseOrder ? 'column-reverse' : 'column',
...getResponsiveProps('stack', 'gap', 'space', gap),
} as React.CSSProperties;

Expand Down

0 comments on commit 49ed527

Please sign in to comment.