Skip to content

Conversation

qq99
Copy link
Contributor

@qq99 qq99 commented Jun 5, 2019

Should merge after #1622 to minimize merge conflicts

WHAT is this pull request doing?

  • Adds ability to supply array of secondaryFooterActions, and adds deprecation notes to secondaryFooterAction (singular)
  • Allows primaryFooterAction and secondaryFooterAction to be disableable

With an array of actions, you can now easily achieve this:
Screen Shot 2019-06-05 at 10 57 17 AM

With an array of just 1 action, it falls back to rendering as if you had supplied a secondaryFooterAction (singular):
Screen Shot 2019-06-05 at 10 57 53 AM

Here's a picture of disabling the secondary, and of a custom disclosure text:
Screen Shot 2019-06-05 at 10 58 08 AM

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import * as React from 'react';
import {Page, Card, TextField} from '../src';

interface State {}

/* eslint-disable no-alert */
export default class Playground extends React.Component<{}, State> {
  render() {
    return (
      <Page title="Playground">
        <Card
          sectioned
          title="My cool card"
          actions={[{content: 'Header action'}]}
          primaryFooterAction={{content: 'Primary', disabled: true}}
          secondaryFooterAction={{content: 'yo'}}
          secondaryFooterActions={[
            {
              content: 'Secondary 1',
              onAction: () => alert('sec1'),
            },
            {
              content: 'Secondary 2',
              onAction: () => alert('sec2'),
            },
            {
              content: 'Disabled Secondary 3',
              disabled: true,
              onAction: () => alert('sec3'),
            },
          ]}
        >
          <TextField
            label="Textfield"
            readOnly
            disabled
            onChange={() => alert('test')}
          />
        </Card>
        <Card
          title="My cool card"
          actions={[{content: 'Header action'}]}
          primaryFooterAction={{content: 'Primary'}}
          secondaryFooterActions={[
            {
              content: 'Secondary 1',
              onAction: () => alert('sec1'),
            },
          ]}
        >
          <Card.Section>Card body</Card.Section>
          <Card.Section>Card body</Card.Section>
        </Card>
        <Card
          title="Disabled secondary"
          actions={[{content: 'Header action'}]}
          primaryFooterAction={{content: 'Primary'}}
          secondaryFooterActions={[
            {
              content: 'Secondary 1',
              disabled: true,
              onAction: () => alert('sec1'),
            },
          ]}
        >
          <Card.Section>Card body</Card.Section>
          <Card.Section>Card body</Card.Section>
        </Card>
        <Card
          title="Custom disclosure text"
          actions={[{content: 'Header action'}]}
          primaryFooterAction={{content: 'Primary'}}
          secondaryFooterActions={[
            {
              content: 'Secondary 1',
              onAction: () => alert('sec1'),
            },
            {
              content: 'Secondary 2',
              onAction: () => alert('sec2'),
            },
          ]}
          secondaryFooterActionsDisclosureText="..."
        >
          <Card.Section>Card body</Card.Section>
          <Card.Section>Card body</Card.Section>
        </Card>
        {/* Add the code you want to test in here */}
      </Page>
    );
  }
}
/* eslint-enable no-alert */

🎩 checklist

@alex-page alex-page changed the title [wip][Card] Add support for secondaryFooterActions, allow existing primaryFooterAction and secondaryFooterAction to be disableable [wip][Card] Add support for footer actions to be disabled Jun 5, 2019
@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from 794990d to 1db44b1 Compare June 5, 2019 15:04
@alex-page alex-page changed the title [wip][Card] Add support for footer actions to be disabled [wip][Card] Add support for multiple secondary actions in footer and the option to disable them Jun 5, 2019
@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from 1db44b1 to d3f5ac0 Compare June 5, 2019 15:05
@qq99 qq99 changed the title [wip][Card] Add support for multiple secondary actions in footer and the option to disable them [Card] Add support for multiple secondary actions in footer and the option to disable them Jun 5, 2019
```jsx
<Card
title="Shipment 1234"
secondaryFooterAction={{content: 'Cancel shipment'}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the old API is deprecated, I figured I'd update the existing singular example

Not sure why the lines below are showing up as new though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from d3f5ac0 to 6147e49 Compare June 5, 2019 15:17
@alex-page
Copy link
Member

Hey @qq99 I have asked for translations. From a quick glance this looks okay. Have you tophatted this change in mobile, multiple browsers and for accessibility?

@qq99
Copy link
Contributor Author

qq99 commented Jun 5, 2019

I could do multiple browsers easily enough: works nicely in Firefox,Chrome,Safari

I don't know how to test accessibility though and don't have a good solution to test this on a mobile phone

Mobile viewport simulator from Storybook:
Screen Shot 2019-06-05 at 3 24 35 PM
Screen Shot 2019-06-05 at 3 25 11 PM

@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from 6147e49 to 8ea3bfd Compare June 5, 2019 19:53
@qq99
Copy link
Contributor Author

qq99 commented Jun 5, 2019

We've been chatting about using ComplexAction instead in Slack (cc @chloerice),
after #1622 ships I can rebase

@BPScott BPScott temporarily deployed to polaris-react-pr-1625 June 6, 2019 18:44 Inactive
Copy link
Member

@chloerice chloerice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prop deprecation/replacement makes sense to me. Code and 🎩 👀 solid 👍 Just a couple typo fixes and a few content changes suggested.

I rebased your branch on master when I checked it out locally. The only real conflict was a content update from "Cancel shipment" to "Edit shipment" in one of README examples since there's now a specific example for a card with a destructive footer action. Didn't want to push it up in case you made any changes locally too, but happy to push it up if you run into issues.

expect(button.text()).toBe('a');
});
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a test for the disclosure text rendering a default value if secondaryFooterActionsDisclosureText is unset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is in a way, in popover works when disclosure button is clicked:

      const disclosureButton = card.find(Button).first();
      expect(disclosureButton).toHaveLength(1);
      expect(disclosureButton.text()).toBe('More');

@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from afbc5b7 to 4ec3a56 Compare June 11, 2019 13:57
@BPScott BPScott temporarily deployed to polaris-react-pr-1625 June 11, 2019 13:57 Inactive
@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from 4ec3a56 to 410ee75 Compare June 11, 2019 14:12
@qq99
Copy link
Contributor Author

qq99 commented Jun 11, 2019

I think I got all your changes @chloerice 🤞

@qq99 qq99 force-pushed the card-footer-actions-api-improvement branch from 410ee75 to 30063d0 Compare June 12, 2019 13:38
@BPScott BPScott requested a deployment to polaris-react-pr-1625 June 12, 2019 13:38 Abandoned
@qq99 qq99 merged commit 77c1741 into master Jun 12, 2019
@qq99 qq99 deleted the card-footer-actions-api-improvement branch June 12, 2019 13:45
@dleroux dleroux temporarily deployed to production June 25, 2019 17:18 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants