From 830c4ed8f82396980a8d415ea3d2f56150a68f16 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 5 Apr 2022 11:21:42 +0200 Subject: [PATCH] Card: adjust border radius size (#40032) * Card: adjust border radius size * Update unit tests * CHANGELOG --- packages/components/CHANGELOG.md | 1 + packages/components/src/card/styles.js | 16 +- .../src/card/test/__snapshots__/index.js.snap | 143 ++++++++++-------- packages/components/src/card/test/index.js | 12 +- .../flyout/test/__snapshots__/index.js.snap | 12 +- 5 files changed, 105 insertions(+), 79 deletions(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index eb4e732b4438c7..c3d28c0de13f9f 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -6,6 +6,7 @@ - Update `BorderControl` and `BorderBoxControl` to allow the passing of custom class names to popovers ([#39753](https://github.com/WordPress/gutenberg/pull/39753)). - `ToggleGroupControl`: Reintroduce backdrop animation ([#40021](https://github.com/WordPress/gutenberg/pull/40021)). +- `Card`: Adjust border radius effective size ([#40032](https://github.com/WordPress/gutenberg/pull/40032)). ### Internal diff --git a/packages/components/src/card/styles.js b/packages/components/src/card/styles.js index 9162a4790a93b3..ad08bf2690e8fa 100644 --- a/packages/components/src/card/styles.js +++ b/packages/components/src/card/styles.js @@ -8,6 +8,12 @@ import { css } from '@emotion/react'; */ import { COLORS, CONFIG } from '../utils'; +// Since the border for `Card` is rendered via the `box-shadow` property +// (as opposed to the `border` property), the value of the border radius needs +// to be adjusted by removing 1px (this is because the `box-shadow` renders +// as an "outer radius"). +const adjustedBorderRadius = `calc(${ CONFIG.cardBorderRadius } - 1px)`; + export const Card = css` box-shadow: 0 0 0 1px ${ CONFIG.surfaceBorderColor }; outline: none; @@ -62,13 +68,13 @@ export const Divider = css` export const borderRadius = css` &:first-of-type { - border-top-left-radius: ${ CONFIG.cardBorderRadius }; - border-top-right-radius: ${ CONFIG.cardBorderRadius }; + border-top-left-radius: ${ adjustedBorderRadius }; + border-top-right-radius: ${ adjustedBorderRadius }; } &:last-of-type { - border-bottom-left-radius: ${ CONFIG.cardBorderRadius }; - border-bottom-right-radius: ${ CONFIG.cardBorderRadius }; + border-bottom-left-radius: ${ adjustedBorderRadius }; + border-bottom-right-radius: ${ adjustedBorderRadius }; } `; @@ -85,7 +91,7 @@ export const borderless = css` `; export const rounded = css` - border-radius: ${ CONFIG.cardBorderRadius }; + border-radius: ${ adjustedBorderRadius }; `; const xSmallCardPadding = css` diff --git a/packages/components/src/card/test/__snapshots__/index.js.snap b/packages/components/src/card/test/__snapshots__/index.js.snap index 2c0dc3d22eb2d0..eea876b0cffe56 100644 --- a/packages/components/src/card/test/__snapshots__/index.js.snap +++ b/packages/components/src/card/test/__snapshots__/index.js.snap @@ -8,8 +8,8 @@ Snapshot Diff: @@ -1,8 +1,8 @@
@@ -25,8 +25,8 @@ Snapshot Diff: @@ -1,8 +1,8 @@
@@ -42,8 +42,8 @@ Snapshot Diff: @@ -1,8 +1,8 @@