Skip to content

Commit 4799b65

Browse files
chazdeanlaurkim
andauthored
[Layout foundations] Remove default spacing from Inline (#8454)
<!-- ☝️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 #8368 <!-- link to issue if one exists --> <!-- 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 --------- Co-authored-by: Lo Kim <lo.kim@shopify.com>
1 parent ba72800 commit 4799b65

28 files changed

+919
-869
lines changed

.changeset/eight-spies-complain.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': minor
3+
'polaris.shopify.com': minor
4+
---
5+
6+
Removed default spacing from `Inline`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function Item({
8888
const textMarkup = <span className={styles.Text}>{contentMarkup}</span>;
8989

9090
const contentElement = (
91-
<Inline blockAlign="center" gap="0">
91+
<Inline blockAlign="center">
9292
{prefixMarkup}
9393
{textMarkup}
9494
{badgeMarkup}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function WithEndJustifiedContent() {
194194
return (
195195
<Banner status="critical">
196196
<AlphaStack gap="1" fullWidth>
197-
<Inline align="space-between">
197+
<Inline gap="4" align="space-between">
198198
<Text variant="headingMd" fontWeight="semibold" as="h3">
199199
Deployment failed in 5min
200200
</Text>

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function Default() {
3333
<div style={{padding: '0'}}>
3434
<AlphaStack gap="4">
3535
{files.map((file, index) => (
36-
<Inline align="center" key={index}>
36+
<Inline gap="4" align="center" key={index}>
3737
<Thumbnail
3838
size="small"
3939
alt={file.name}
@@ -89,7 +89,7 @@ export function WithImageFileUpload() {
8989
const uploadedFiles = files.length > 0 && (
9090
<AlphaStack gap="4">
9191
{files.map((file, index) => (
92-
<Inline align="center" key={index}>
92+
<Inline gap="4" align="center" key={index}>
9393
<Thumbnail
9494
size="small"
9595
alt={file.name}
@@ -146,7 +146,7 @@ export function WithSingleFileUpload() {
146146

147147
const fileUpload = !file && <DropZone.FileUpload />;
148148
const uploadedFile = file && (
149-
<Inline>
149+
<Inline gap="4">
150150
<Thumbnail
151151
size="small"
152152
alt={file.name}
@@ -188,7 +188,7 @@ export function WithDropOnPage() {
188188
const uploadedFiles = files.length > 0 && (
189189
<AlphaStack gap="4">
190190
{files.map((file, index) => (
191-
<Inline align="center" key={index}>
191+
<Inline gap="4" align="center" key={index}>
192192
<Thumbnail
193193
size="small"
194194
alt={file.name}
@@ -250,7 +250,7 @@ export function AcceptsOnlySVGFiles() {
250250
const uploadedFiles = files.length > 0 && (
251251
<AlphaStack gap="4">
252252
{files.map((file, index) => (
253-
<Inline align="center" key={index}>
253+
<Inline gap="4" align="center" key={index}>
254254
<Thumbnail
255255
size="small"
256256
alt={file.name}
@@ -313,7 +313,7 @@ export function Nested() {
313313
const uploadedFiles = files.length > 0 && (
314314
<AlphaStack gap="4">
315315
{files.map((file, index) => (
316-
<Inline align="center" key={index}>
316+
<Inline gap="4" align="center" key={index}>
317317
<Thumbnail
318318
size="small"
319319
alt={file.name}
@@ -385,7 +385,7 @@ export function WithCustomFileUploadText() {
385385
const uploadedFiles = files.length > 0 && (
386386
<AlphaStack gap="4">
387387
{files.map((file, index) => (
388-
<Inline align="center" key={index}>
388+
<Inline gap="4" align="center" key={index}>
389389
<Thumbnail
390390
size="small"
391391
alt={file.name}
@@ -434,7 +434,7 @@ export function WithCustomFileDialogTrigger() {
434434
const uploadedFiles = files.length > 0 && (
435435
<AlphaStack gap="4">
436436
{files.map((file, index) => (
437-
<Inline align="center" key={index}>
437+
<Inline gap="4" align="center" key={index}>
438438
<Thumbnail
439439
size="small"
440440
alt={file.name}

polaris-react/src/components/Frame/components/Toast/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function Toast({
7474
<div className={className}>
7575
<KeypressListener keyCode={Key.Escape} handler={onDismiss} />
7676
{leadingIconMarkup}
77-
<Inline blockAlign="center">
77+
<Inline gap="4" blockAlign="center">
7878
<Text as="span" variant="bodyMd" fontWeight="medium">
7979
{content}
8080
</Text>

polaris-react/src/components/Inline/Inline.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface InlineProps {
2828
*/
2929
blockAlign?: BlockAlign;
3030
/** The spacing between elements. Accepts a spacing token or an object of spacing tokens for different screen sizes.
31-
* @default '4'
3231
* @example
3332
* gap='2'
3433
* gap={{xs: '2', sm: '3', md: '4', lg: '5', xl: '6'}}
@@ -43,7 +42,7 @@ export interface InlineProps {
4342
export const Inline = function Inline({
4443
align = 'start',
4544
blockAlign = 'center',
46-
gap = '4',
45+
gap,
4746
wrap = true,
4847
children,
4948
}: InlineProps) {

polaris-react/src/components/Inline/tests/Inline.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,49 @@ describe('<Inline />', () => {
1717

1818
expect(stack).toContainReactText(childText);
1919
});
20+
21+
it('renders custom properties by default', () => {
22+
const stack = mountWithApp(<Inline>{renderChildren()}</Inline>);
23+
24+
expect(stack).toContainReactComponent('div', {
25+
style: expect.objectContaining({
26+
'--pc-inline-align': 'start',
27+
'--pc-inline-block-align': 'center',
28+
'--pc-inline-wrap': 'wrap',
29+
}) as React.CSSProperties,
30+
});
31+
});
32+
33+
it('overrides custom properties if they are passed in', () => {
34+
const stack = mountWithApp(
35+
<Inline align="center" blockAlign="start" gap="10">
36+
{renderChildren()}
37+
</Inline>,
38+
);
39+
40+
expect(stack).toContainReactComponent('div', {
41+
style: expect.objectContaining({
42+
'--pc-inline-align': 'center',
43+
'--pc-inline-block-align': 'start',
44+
'--pc-inline-wrap': 'wrap',
45+
'--pc-inline-gap-xs': 'var(--p-space-10)',
46+
}) as React.CSSProperties,
47+
});
48+
});
49+
50+
it('accepts gap based on breakpoints', () => {
51+
const stack = mountWithApp(
52+
<Inline gap={{xs: '2', md: '8'}}>{renderChildren()}</Inline>,
53+
);
54+
55+
expect(stack).toContainReactComponent('div', {
56+
style: expect.objectContaining({
57+
'--pc-inline-align': 'start',
58+
'--pc-inline-block-align': 'center',
59+
'--pc-inline-wrap': 'wrap',
60+
'--pc-inline-gap-xs': 'var(--p-space-2)',
61+
'--pc-inline-gap-md': 'var(--p-space-8)',
62+
}) as React.CSSProperties,
63+
});
64+
});
2065
});

polaris-react/src/components/Modal/Modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const Modal: React.FunctionComponent<ModalProps> & {
156156

157157
const body = loading ? (
158158
<Box padding="4">
159-
<Inline align="center">
159+
<Inline gap="4" align="center">
160160
<Spinner />
161161
</Inline>
162162
</Box>

polaris-react/src/components/Modal/components/Footer/Footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ export function Footer({
3232
) : null;
3333

3434
return (
35-
<Inline blockAlign="center">
35+
<Inline gap="4" blockAlign="center">
3636
<Box
3737
borderBlockStart="divider"
3838
minHeight="var(--p-space-16)"
3939
padding="4"
4040
width="100%"
4141
>
42-
<Inline blockAlign="center" align="space-between">
42+
<Inline gap="4" blockAlign="center" align="space-between">
4343
<Box>{children}</Box>
4444
{actions}
4545
</Inline>

polaris-react/src/components/Modal/components/Header/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function Header({
2323
}: HeaderProps) {
2424
const titleHiddenMarkup = (
2525
<Box position="absolute" insetInlineEnd="0" zIndex="1">
26-
<Inline align="end">
26+
<Inline gap="4" align="end">
2727
<CloseButton titleHidden={titleHidden} onClick={onClose} />
2828
</Inline>
2929
</Box>
@@ -42,7 +42,7 @@ export function Header({
4242
borderBlockEnd="divider"
4343
>
4444
<Columns columns={{xs: '1fr auto'}}>
45-
<Inline>
45+
<Inline gap="4">
4646
<Text id={id} as="h2" variant="headingLg" breakWord>
4747
{children}
4848
</Text>

0 commit comments

Comments
 (0)