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 b80a0a8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 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
34 changes: 32 additions & 2 deletions polaris-react/playground/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,43 @@
import React from 'react';

import {Page} from '../src';
import {Banner, CalloutCard, Layout, Page, Text} from '../src';

export const Playground = {
tags: ['skip-tests'],
render() {
return (
<Page title="Playground">
{/* Add the code you want to test in here */}
<Layout>
<Layout.Section>
<Banner tone="info" onDismiss={() => {}}>
<Text as="p">
Enabling certain features in your store may prevent you from
selling bundles. Learn more about Shopify Bundles compatibility
</Text>
</Banner>
</Layout.Section>

<Layout.Section>
<CalloutCard
illustration="https://burst.shopifycdn.com/photos/hands-hold-a-cellphone-with-a-graph-on-screen.jpg?width=373"
title="Product bundles reports are now available"
primaryAction={{
content: 'View bundle reports',
onAction: () => {},
}}
secondaryAction={{
content: 'Learn more',
onAction: () => {},
}}
onDismiss={() => {}}
>
<Text as="p" variant="bodyMd" breakWord>
Get real-time metrics on how your bundles are performing with
the new Analytics.
</Text>
</CalloutCard>
</Layout.Section>
</Layout>
</Page>
);
},
Expand Down
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 b80a0a8

Please sign in to comment.