Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CalloutCard] Fix dismiss button UI inconsistencies #12967

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .changeset/real-laws-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@shopify/polaris': patch
---

CalloutCard dismiss button improvements:

- Use tertiary button variant
- Use regular sized X icon
- Adjust position to match Banner
- Add translated label
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

.Dismiss {
right: var(--p-space-400);
right: var(--p-space-300);
top: var(--p-space-400);
position: absolute;

Expand All @@ -45,5 +45,5 @@
}

.hasDismiss {
padding-right: calc(var(--p-space-800) + var(--p-space-200));
padding-right: calc(var(--p-space-800) + var(--p-space-300));
}
10 changes: 6 additions & 4 deletions polaris-react/src/components/CalloutCard/CalloutCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import {XSmallIcon} from '@shopify/polaris-icons';
import {XIcon} from '@shopify/polaris-icons';

import {classNames} from '../../utilities/css';
import {useI18n} from '../../utilities/i18n';
import type {IconableAction} from '../../types';
// eslint-disable-next-line import/no-deprecated
import {LegacyCard} from '../LegacyCard';
Expand Down Expand Up @@ -37,6 +38,7 @@ export function CalloutCard({
secondaryAction,
onDismiss,
}: CalloutCardProps) {
const i18n = useI18n();
const primaryActionMarkup = buttonFrom(primaryAction);
const secondaryActionMarkup = secondaryAction
? buttonFrom(secondaryAction, {
Expand All @@ -56,10 +58,10 @@ export function CalloutCard({
const dismissButton = onDismiss ? (
<div className={styles.Dismiss}>
<Button
variant="plain"
icon={XSmallIcon}
variant="tertiary"
icon={XIcon}
onClick={onDismiss}
accessibilityLabel="Dismiss card"
accessibilityLabel={i18n.translate('Polaris.Banner.dismissButton')}
/>
</div>
) : null;
Expand Down
Loading