Skip to content

Commit

Permalink
Remove card shadows from smaller breakpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Germanika committed Nov 8, 2024
1 parent a9e9e4d commit 6fee7aa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-otters-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Removed default `Card` and `LegacyCard` bevel styles below sm breakpoint
11 changes: 4 additions & 7 deletions polaris-react/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type {
BreakpointsAlias,
ColorBackgroundAlias,
BorderRadiusAliasOrScale,
SpaceScale,
} from '@shopify/polaris-tokens';
import React from 'react';

import {useBreakpoints} from '../../utilities/breakpoints';
import type {ResponsiveProp} from '../../utilities/css';
import {Box} from '../Box';
import {ShadowBevel} from '../ShadowBevel';
Expand Down Expand Up @@ -39,15 +37,14 @@ export const Card = ({
padding = {xs: '400'},
roundedAbove = 'sm',
}: CardProps) => {
const breakpoints = useBreakpoints();
const defaultBorderRadius: BorderRadiusAliasOrScale = '300';
const hasBorderRadius = Boolean(breakpoints[`${roundedAbove}Up`]);

return (
<WithinContentContext.Provider value>
<ShadowBevel
boxShadow="100"
borderRadius={hasBorderRadius ? defaultBorderRadius : '0'}
borderRadius="300"
bevel={{
[roundedAbove]: true,
}}
zIndex="32"
>
<Box
Expand Down
20 changes: 16 additions & 4 deletions polaris-react/src/components/Card/tests/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,29 @@ describe('Card', () => {
expect(card).toContainReactComponentTimes('p', 2);
});

it('sets default border radius when roundedAbove breakpoint passed in', () => {
setMediaWidth('breakpoints-sm');
it('cards are rounded sm and above by default', () => {
const card = mountWithApp(
<Card roundedAbove="sm">
<Card>
{heading}
{subheading}
</Card>,
);

expect(card).toContainReactComponent(ShadowBevel, {
bevel: {sm: true},
});
});

it('cards respect incoming roundedAbove prop', () => {
const card = mountWithApp(
<Card roundedAbove="md">
{heading}
{subheading}
</Card>,
);

expect(card).toContainReactComponent(ShadowBevel, {
borderRadius: '300',
bevel: {md: true},
});
});
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
.LegacyCard {
background-color: var(--p-color-bg-surface);
box-shadow: var(--p-shadow-300);
outline: var(--p-border-width-025) solid transparent;
overflow: clip;

@mixin shadow-bevel var(--p-shadow-100), var(--p-border-radius-0), null, '',
101;

+ .LegacyCard {
margin-top: var(--p-space-400);

Expand All @@ -16,6 +12,7 @@
}

@media (--p-breakpoints-sm-up) {
box-shadow: var(--p-shadow-300);
border-radius: var(--p-border-radius-200);

@mixin shadow-bevel var(--p-shadow-100), var(--p-border-radius-300), null,
Expand Down

0 comments on commit 6fee7aa

Please sign in to comment.