Skip to content

Commit

Permalink
[Banner] Fix content size (#8256)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Fixes some unexpected behaviour with the `Bleed` component content width

### WHAT is this pull request doing?

Content inside `Bleed` shouldn't extend past the intended content area
  • Loading branch information
aveline authored Feb 3, 2023
1 parent 31abdab commit 43776be
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/blue-queens-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
---

- Fixed `Bleed` width behavior
- Fixed `Banner` content width
5 changes: 5 additions & 0 deletions polaris-react/src/components/Banner/Banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
// stylelint-enable selector-max-class, selector-max-specificity
}

.ContentWrapper {
margin-top: calc(-1 * var(--p-space-05));
flex: 1 1 auto;
}

.withinContentContainer {
padding: var(--p-space-4);

Expand Down
21 changes: 21 additions & 0 deletions polaris-react/src/components/Banner/Banner.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import type {ComponentMeta} from '@storybook/react';
import {
AlphaStack,
Banner,
Button,
Card,
Inline,
Link,
List,
Modal,
Text,
TextContainer,
} from '@shopify/polaris';

Expand Down Expand Up @@ -186,3 +189,21 @@ export function InACard() {
</Card>
);
}

export function WithEndJustifiedContent() {
return (
<Banner status="critical">
<AlphaStack gap="1" fullWidth>
<Inline align="space-between">
<Text variant="headingMd" fontWeight="semibold" as="h3">
Deployment failed in 5min
</Text>
<Link external url="https://example.com">
Logs
</Link>
</Inline>
<p>This order was archived on March 7, 2017 at 3:12pm EDT.</p>
</AlphaStack>
</Banner>
);
}
5 changes: 2 additions & 3 deletions polaris-react/src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {Icon, IconProps} from '../Icon';
import {WithinContentContext} from '../../utilities/within-content-context';
import {Text} from '../Text';
import {Box} from '../Box';
import {Bleed} from '../Bleed';

import styles from './Banner.scss';

Expand Down Expand Up @@ -174,10 +173,10 @@ export const Banner = forwardRef<BannerHandles, BannerProps>(function Banner(
<Icon source={iconName} color={iconColor} />
</Box>

<Bleed marginInline="0" marginBlockStart="05">
<div className={styles.ContentWrapper}>
{headingMarkup}
{contentMarkup}
</Bleed>
</div>
</div>
</BannerContext.Provider>
);
Expand Down
1 change: 0 additions & 1 deletion polaris-react/src/components/Bleed/Bleed.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import '../../styles/common';

.Bleed {
min-width: 100%;
// stylelint-disable -- Polaris component custom properties
--pc-bleed-margin-block-start-xs: initial;
--pc-bleed-margin-block-start-sm: var(--pc-bleed-margin-block-start-xs);
Expand Down

0 comments on commit 43776be

Please sign in to comment.