Skip to content

Commit

Permalink
CalloutCard dismiss button improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
moraleslevi committed Dec 4, 2024
1 parent 70bfcbe commit f8ee15b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
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

0 comments on commit f8ee15b

Please sign in to comment.