Skip to content

Commit 53611c5

Browse files
[CalloutCard] add Iconable actions & allows Button variant for secondary action (#11530)
Trying to make sure we can get this design going, like we already have for [Search and Discovery](https://github.com/Shopify/discovery-app/blob/main/app/ui/components/FeedbackCard/FeedbackCard.tsx) without needing to build custom components. We'll need that now on Email too and if this is approved, we could just have standard code everywhere for collecting feedback. <img width="749" alt="Screenshot 2024-01-30 at 2 25 36 PM" src="https://github.com/Shopify/polaris/assets/642737/e3629130-a6af-49d9-8b67-5da642b4c4b0"> ### WHY are these changes introduced and WHAT is this pull request doing? Currently we don't allow `primaryAction` to be null, which would allow us to achieve the same results by using `content`. I figured we could just enhance the API slightly making it backwards compatible and allowing more customization. ### 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) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide --------- Co-authored-by: Kyle Durand <[email protected]>
1 parent 92e726b commit 53611c5

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

.changeset/popular-birds-refuse.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
[CalloutCard] Added IconableAction to primaryAction and secondaryAction
6+
[CalloutCard] Added variant prop to secondaryAction

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2-
import type {ComponentMeta} from '@storybook/react';
3-
import {Badge, CalloutCard, Text} from '@shopify/polaris';
2+
import type {Meta} from '@storybook/react';
3+
import {Badge, CalloutCard} from '@shopify/polaris';
4+
import {SmileyHappyIcon, SmileySadIcon} from '@shopify/polaris-icons';
45

56
export default {
67
component: CalloutCard,
7-
} as ComponentMeta<typeof CalloutCard>;
8+
} as Meta<typeof CalloutCard>;
89

910
export function Default() {
1011
return (
@@ -65,3 +66,23 @@ export function WithCustomTitle() {
6566
</CalloutCard>
6667
);
6768
}
69+
70+
export function WithIconableActions() {
71+
return (
72+
<CalloutCard
73+
title="Tell us how we're doing"
74+
illustration="https://cdn.shopify.com/s/assets/admin/checkout/settings-customizecart-705f57c725ac05be5a34ec20c05b94298cb8afd10aac7bd9c7ad02030f48cfa0.svg"
75+
primaryAction={{
76+
content: 'Good',
77+
icon: SmileyHappyIcon,
78+
}}
79+
secondaryAction={{
80+
content: 'Bad',
81+
icon: SmileySadIcon,
82+
variant: 'secondary',
83+
}}
84+
>
85+
<p>How do you like our app?</p>
86+
</CalloutCard>
87+
);
88+
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import React from 'react';
22
import {XSmallIcon} from '@shopify/polaris-icons';
33

44
import {classNames} from '../../utilities/css';
5-
import type {Action} from '../../types';
5+
import type {IconableAction} from '../../types';
66
// eslint-disable-next-line import/no-deprecated
77
import {LegacyCard} from '../LegacyCard';
8-
// eslint-disable-next-line import/no-deprecated
9-
import {TextContainer} from '../TextContainer';
8+
import {BlockStack} from '../BlockStack';
109
import {ButtonGroup} from '../ButtonGroup';
1110
import {Button, buttonFrom} from '../Button';
11+
import type {ButtonProps} from '../Button';
1212
import {Text} from '../Text';
1313
import {Image} from '../Image';
1414

@@ -22,9 +22,9 @@ export interface CalloutCardProps {
2222
/** URL to the card illustration */
2323
illustration: string;
2424
/** Primary action for the card */
25-
primaryAction: Action;
25+
primaryAction: IconableAction;
2626
/** Secondary action for the card */
27-
secondaryAction?: Action;
27+
secondaryAction?: IconableAction & Pick<ButtonProps, 'variant'>;
2828
/** Callback when banner is dismissed */
2929
onDismiss?(): void;
3030
}
@@ -40,7 +40,7 @@ export function CalloutCard({
4040
const primaryActionMarkup = buttonFrom(primaryAction);
4141
const secondaryActionMarkup = secondaryAction
4242
? buttonFrom(secondaryAction, {
43-
variant: 'tertiary',
43+
variant: secondaryAction.variant ?? 'tertiary',
4444
})
4545
: null;
4646

@@ -86,7 +86,7 @@ export function CalloutCard({
8686
{title}
8787
</Text>
8888
</div>
89-
<TextContainer>{children}</TextContainer>
89+
<BlockStack>{children}</BlockStack>
9090
<div className={styles.Buttons}>{buttonMarkup}</div>
9191
</div>
9292

0 commit comments

Comments
 (0)