Skip to content

Commit 50246bb

Browse files
authored
[CalloutCard] Fix dismiss button UI inconsistencies (#12967)
### WHY are these changes introduced? Fixes #12968 The dismiss button on the CalloutCard does not match the UI of the dismiss button on the Banner, which is very apparent when the components are rendered near each other. ### WHAT is this pull request doing? This makes four changes to the CalloutCard dismiss button: - Use tertiary button variant - Use regular sized X icon - Adjust position to match Banner - Add translated label <details> <summary>Before</summary> <img width="983" alt="04-30-17lmm-1zbu4" src="https://github.com/user-attachments/assets/9aee2357-c91b-4dee-90bc-a998eff97c3f"> </details> <details> <summary>After</summary> <img width="1004" alt="04-31-awl5i-59kp8" src="https://github.com/user-attachments/assets/24cb1c09-6bce-471a-9730-9da8f2cef564"> </details> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [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) ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] 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
1 parent f4b1bd4 commit 50246bb

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

.changeset/real-laws-draw.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
CalloutCard dismiss button improvements:
6+
7+
- Use tertiary button variant
8+
- Use regular sized X icon
9+
- Adjust position to match Banner
10+
- Add translated label

polaris-react/src/components/CalloutCard/CalloutCard.module.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636

3737
.Dismiss {
38-
right: var(--p-space-400);
38+
right: var(--p-space-300);
3939
top: var(--p-space-400);
4040
position: absolute;
4141

@@ -45,5 +45,5 @@
4545
}
4646

4747
.hasDismiss {
48-
padding-right: calc(var(--p-space-800) + var(--p-space-200));
48+
padding-right: calc(var(--p-space-800) + var(--p-space-300));
4949
}

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
2-
import {XSmallIcon} from '@shopify/polaris-icons';
2+
import {XIcon} from '@shopify/polaris-icons';
33

44
import {classNames} from '../../utilities/css';
5+
import {useI18n} from '../../utilities/i18n';
56
import type {IconableAction} from '../../types';
67
// eslint-disable-next-line import/no-deprecated
78
import {LegacyCard} from '../LegacyCard';
@@ -37,6 +38,7 @@ export function CalloutCard({
3738
secondaryAction,
3839
onDismiss,
3940
}: CalloutCardProps) {
41+
const i18n = useI18n();
4042
const primaryActionMarkup = buttonFrom(primaryAction);
4143
const secondaryActionMarkup = secondaryAction
4244
? buttonFrom(secondaryAction, {
@@ -56,10 +58,10 @@ export function CalloutCard({
5658
const dismissButton = onDismiss ? (
5759
<div className={styles.Dismiss}>
5860
<Button
59-
variant="plain"
60-
icon={XSmallIcon}
61+
variant="tertiary"
62+
icon={XIcon}
6163
onClick={onDismiss}
62-
accessibilityLabel="Dismiss card"
64+
accessibilityLabel={i18n.translate('Polaris.Banner.dismissButton')}
6365
/>
6466
</div>
6567
) : null;

0 commit comments

Comments
 (0)