Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4e17711
[Layout foundations] Add alpha `Box` component (#7000)
laurkim Aug 30, 2022
1652413
[Layout foundations] Refactor `Box` without polymorphic dep (#7062)
laurkim Aug 31, 2022
030905a
[Layout foundations] Add `Columns` component (#7057)
kyledurand Sep 1, 2022
75ab664
[Layout foundations] Stack component prototype (#7036)
chazdean Sep 2, 2022
bbddeab
[Layout foundations] Add tests for `Box` (#7094)
laurkim Sep 2, 2022
c23014e
[Layout foundations] Remove `display` from root `Box` styling
laurkim Sep 6, 2022
68dfef7
[Layout foundations] Add tests for Stack (#7106)
chazdean Sep 7, 2022
42268be
[Layout foundations] Inline component prototype (#7029)
aveline Sep 14, 2022
ae7c77b
[Layout foundations] Add Tile component (#7092)
chazdean Sep 15, 2022
8de2c61
[Layout foundations] Add alpha `Bleed` component (#7156)
chazdean Sep 23, 2022
0660134
[Layout] `AlphaCard` with alternate `Box` css (#7207)
aveline Sep 23, 2022
af3d8cc
[Layout foundations] Add alpha pages in style guide for Box, Inline, …
laurkim Sep 26, 2022
e6c16f1
[Layout foundations] Add alpha `ContentBlock` component (#7255)
chazdean Sep 26, 2022
79a7069
[Layout foundations] Add alpha page in style guide for `Bleed` (#7276)
chazdean Sep 26, 2022
7288b9d
Update `AlphaCard` border radius to a boolean (#7287)
aveline Sep 28, 2022
6188a0b
[Layout foundations] Refactor `Box` and update `Toast` to use `Box` (…
laurkim Sep 29, 2022
a4a28a7
[Layout foundations] Add breakpoint configuration to `Tile` component…
chazdean Sep 29, 2022
3292df6
[Layout foundations] Refactor token types (#7296)
aveline Sep 29, 2022
ea250a9
Add `fullWidth` prop for `AlphaStack` (#7309)
aveline Sep 30, 2022
e84a772
Alpha card props (#7314)
aveline Sep 30, 2022
6b89052
[Layout foundations ] Rename `Tiles` (#7320)
aveline Oct 3, 2022
ae5401c
Rename `AlphaCard` shadow prop (#7325)
aveline Oct 3, 2022
2fcdfa5
Columns spacing (#7326)
aveline Oct 3, 2022
060697c
Remove `margin` from `Box` (#7327)
aveline Oct 3, 2022
d05c43e
Merge branch 'main' into layout-foundations-prototype
aveline Oct 3, 2022
74c488f
Update props.json
aveline Oct 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fast-candles-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Updated `AlphaCard` border radius to a boolean
6 changes: 6 additions & 0 deletions .changeset/few-ghosts-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Renamed `Columns` spacing
5 changes: 5 additions & 0 deletions .changeset/fresh-dingos-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added alpha `Inline` component
6 changes: 6 additions & 0 deletions .changeset/fuzzy-trainers-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Renamed `background` prop on `AlphaCard` for consistency
6 changes: 6 additions & 0 deletions .changeset/good-mugs-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Rename `Tiles` component
5 changes: 5 additions & 0 deletions .changeset/green-cougars-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'polaris.shopify.com': minor
---

Added alpha pages for `AlphaStack`, `Box`, `Columns`, `Inline`, and `Tile` components. Updated `StatusBanner` to capitalize status value.
5 changes: 5 additions & 0 deletions .changeset/poor-kiwis-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added `AlphaStack` component
5 changes: 5 additions & 0 deletions .changeset/proud-pans-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added `Columns` component
5 changes: 5 additions & 0 deletions .changeset/red-cycles-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added `Box` component
6 changes: 6 additions & 0 deletions .changeset/selfish-poets-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': patch
'polaris.shopify.com': patch
---

Renamed `AlphaCard` `shadow` prop
5 changes: 5 additions & 0 deletions .changeset/shiny-feet-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added `AlphaCard` component
6 changes: 6 additions & 0 deletions .changeset/stale-penguins-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/polaris': minor
'polaris.shopify.com': patch
---

Added `fullWidth` prop to `AlphaStack` and updated styleguide docs
5 changes: 5 additions & 0 deletions .changeset/tall-socks-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Added alpha `ContentBlock` component
7 changes: 7 additions & 0 deletions .changeset/three-games-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@shopify/polaris': patch
'@shopify/polaris-tokens': minor
---

Refactored token types in primitive Layout components
Exposed `DepthShadowAlias` type
5 changes: 5 additions & 0 deletions .changeset/witty-months-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'polaris.shopify.com': minor
---

Added alpha page for `ContentBlock`
72 changes: 72 additions & 0 deletions polaris-react/src/components/AlphaCard/AlphaCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import type {ComponentMeta} from '@storybook/react';
import {AlphaCard, AlphaStack, Text} from '@shopify/polaris';

export default {
component: AlphaCard,
} as ComponentMeta<typeof AlphaCard>;

export function Default() {
return (
<AlphaCard>
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
</Text>
<p>View a summary of your online store’s performance.</p>
</AlphaStack>
</AlphaCard>
);
}

export function BackgroundSubdued() {
return (
<AlphaCard background="surface-subdued">
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
</Text>
<p>View a summary of your online store’s performance.</p>
</AlphaStack>
</AlphaCard>
);
}

export function WithoutBorderRadius() {
return (
<AlphaCard hasBorderRadius={false}>
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
</Text>
<p>View a summary of your online store’s performance.</p>
</AlphaStack>
</AlphaCard>
);
}

export function BorderRadiusRoundedAbove() {
return (
<AlphaCard roundedAbove="sm">
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
</Text>
<p>View a summary of your online store’s performance.</p>
</AlphaStack>
</AlphaCard>
);
}

export function Flat() {
return (
<AlphaCard shadow="transparent">
<AlphaStack spacing="5">
<Text as="h3" variant="headingMd">
Online store dashboard
</Text>
<p>View a summary of your online store’s performance.</p>
</AlphaStack>
</AlphaCard>
);
}
57 changes: 57 additions & 0 deletions polaris-react/src/components/AlphaCard/AlphaCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type {
BreakpointsAlias,
ColorsTokenName,
DepthShadowAlias,
ShapeBorderRadiusScale,
SpacingSpaceScale,
} from '@shopify/polaris-tokens';
import React from 'react';

import {useBreakpoints} from '../../utilities/breakpoints';
import {Box} from '../Box';

type CardShadowTokensScale = Extract<DepthShadowAlias, 'card' | 'transparent'>;

type CardBackgroundColorTokenScale = Extract<
ColorsTokenName,
'surface' | 'surface-subdued'
>;

export interface AlphaCardProps {
/** Elements to display inside card */
children?: React.ReactNode;
background?: CardBackgroundColorTokenScale;
hasBorderRadius?: boolean;
shadow?: CardShadowTokensScale;
padding?: SpacingSpaceScale;
roundedAbove?: BreakpointsAlias;
}

export const AlphaCard = ({
children,
background = 'surface',
hasBorderRadius: hasBorderRadiusProp = true,
shadow = 'card',
padding = '5',
roundedAbove,
}: AlphaCardProps) => {
const breakpoints = useBreakpoints();
const defaultBorderRadius = '2' as ShapeBorderRadiusScale;

let hasBorderRadius = !roundedAbove && hasBorderRadiusProp;

if (roundedAbove && breakpoints[`${roundedAbove}Up`]) {
hasBorderRadius = true;
}

return (
<Box
background={background}
padding={padding}
shadow={shadow}
{...(hasBorderRadius && {borderRadius: defaultBorderRadius})}
>
{children}
</Box>
);
};
1 change: 1 addition & 0 deletions polaris-react/src/components/AlphaCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AlphaCard';
72 changes: 72 additions & 0 deletions polaris-react/src/components/AlphaCard/tests/AlphaCard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';
import {matchMedia} from '@shopify/jest-dom-mocks';
import {
BreakpointsTokenName,
breakpoints,
getMediaConditions,
} from '@shopify/polaris-tokens';

import {AlphaCard} from '..';

const mediaConditions = getMediaConditions(breakpoints);

const heading = <p>Online store dashboard</p>;
const subheading = <p>View a summary of your online store performance</p>;

describe('AlphaCard', () => {
beforeEach(() => {
matchMedia.mock();
});

afterEach(() => {
matchMedia.restore();
});

it('renders children', () => {
const alphaCard = mountWithApp(
<AlphaCard>
{heading}
{subheading}
</AlphaCard>,
);

expect(alphaCard).toContainReactComponentTimes('p', 2);
});

it('sets default border radius when roundedAbove breakpoint passed in', () => {
setMediaWidth('breakpoints-sm');
const alphaCard = mountWithApp(
<AlphaCard roundedAbove="sm">
{heading}
{subheading}
</AlphaCard>,
);

expect(alphaCard).toContainReactComponent('div', {
style: expect.objectContaining({
'--pc-box-border-radius-bottom-left': 'var(--p-border-radius-2)',
'--pc-box-border-radius-bottom-right': 'var(--p-border-radius-2)',
'--pc-box-border-radius-top-left': 'var(--p-border-radius-2)',
'--pc-box-border-radius-top-right': 'var(--p-border-radius-2)',
}),
});
});
});

function setMediaWidth(breakpointsTokenName: BreakpointsTokenName) {
const aliasDirectionConditions = Object.values(
mediaConditions[breakpointsTokenName],
);

jest.spyOn(window, 'matchMedia').mockImplementation((query) => ({
matches: aliasDirectionConditions.includes(query),
media: '',
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
}));
}
16 changes: 16 additions & 0 deletions polaris-react/src/components/AlphaStack/AlphaStack.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.AlphaStack {
display: flex;
flex-direction: column;
align-items: var(--pc-stack-align);
gap: var(--pc-stack-spacing);

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

.fullWidth {
> * {
width: 100%;
}
}
62 changes: 62 additions & 0 deletions polaris-react/src/components/AlphaStack/AlphaStack.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';
import type {ComponentMeta} from '@storybook/react';
import {Badge, AlphaStack} from '@shopify/polaris';

export default {
component: AlphaStack,
} as ComponentMeta<typeof AlphaStack>;

export function Default() {
return (
<AlphaStack>
<Badge>Paid</Badge>
<Badge>Processing</Badge>
<Badge>Fulfilled</Badge>
<Badge>Completed</Badge>
</AlphaStack>
);
}

export function Spacing() {
return (
<AlphaStack spacing="8">
<Badge>Paid</Badge>
<Badge>Processing</Badge>
<Badge>Fulfilled</Badge>
<Badge>Completed</Badge>
</AlphaStack>
);
}

export function AlignCenter() {
return (
<AlphaStack align="center">
<Badge>Paid</Badge>
<Badge>Processing</Badge>
<Badge>Fulfilled</Badge>
<Badge>Completed</Badge>
</AlphaStack>
);
}

export function AlignEnd() {
return (
<AlphaStack align="end">
<Badge>Paid</Badge>
<Badge>Processing</Badge>
<Badge>Fulfilled</Badge>
<Badge>Completed</Badge>
</AlphaStack>
);
}

export function FullWidthChildren() {
return (
<AlphaStack fullWidth>
<Badge>Paid</Badge>
<Badge>Processing</Badge>
<Badge>Fulfilled</Badge>
<Badge>Completed</Badge>
</AlphaStack>
);
}
Loading