Skip to content

Conversation

qq99
Copy link
Contributor

@qq99 qq99 commented Nov 14, 2019

WHY are these changes introduced?

We have a need to use a Button to control the collapsed/expanded state of a Collapsible. When the collapsible is collapsed, we want to say Show more with downwards caret. When expanded, we want to say Show less with upwards caret.

Screen Shot 2019-11-14 at 10 34 23 AM

The previous API is respected, so this is purely an opt-in enhancement

The icon will animate via CSS transition

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

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

export function Playground() {
  const [expanded, setExpanded] = React.useState(false);

  return (
    <Page title="Playground">
      <Card sectioned>
        <Button plain>Button without `disclosure` prop</Button>
        <br />
        <Button>Button without `disclosure` prop</Button>
        <br />
        <Button plain disclosure>
          Button with `disclosure` prop
        </Button>
        <br />
        <Button plain disclosure="down">
          Button with `disclosure="down"` prop
        </Button>
        <br />
        <Button plain disclosure="up">
          Button with `disclosure="up"` prop
        </Button>
        <br />
        <Button
          plain
          disclosure={expanded ? 'up' : 'down'}
          onClick={() => setExpanded(!expanded)}
        >
          Button you can toggle down/up on click
        </Button>
        <br />
        <Button
          disclosure={expanded ? 'up' : 'down'}
          onClick={() => setExpanded(!expanded)}
        >
          Button you can toggle down/up on click
        </Button>
      </Card>
    </Page>
  );
}

🎩 checklist

@qq99 qq99 changed the title [wip][Button] Improve the disclosure API for button, allowing user to spec… [wip][Button] Improve the disclosure API for button, allowing user to specify the direction the disclosure icon faces Nov 14, 2019
@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch from cb31973 to 69b1ca2 Compare November 14, 2019 15:32
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2019

💦 Potential splash zone of changes introduced to src/**/*.tsx in this pull request:

Files modified5
Files potentially affected54

Details

All files potentially affected (total: 54)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🎨 src/components/Button/Button.scss (total: 54)

Files potentially affected (total: 54)

🧩 src/components/Button/Button.tsx (total: 53)

Files potentially affected (total: 53)

📄 src/components/Button/README.md (total: 0)

Files potentially affected (total: 0)

🧩 src/components/Button/tests/Button.test.tsx (total: 0)

Files potentially affected (total: 0)


This comment automatically updates as changes are made to this pull request.
Feedback, troubleshooting: open an issue or reach out on Slack in #polaris-tooling.

@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch from 69b1ca2 to 8391ad9 Compare November 14, 2019 15:40
@qq99 qq99 marked this pull request as ready for review November 14, 2019 15:41
@qq99 qq99 changed the title [wip][Button] Improve the disclosure API for button, allowing user to specify the direction the disclosure icon faces [Button] Improve the disclosure API for button, allowing user to specify the direction the disclosure icon faces Nov 14, 2019
@qq99 qq99 requested review from dleroux and tmlayton November 14, 2019 15:43
@qq99
Copy link
Contributor Author

qq99 commented Nov 14, 2019

I think percy bugged out? 🤔 Showing visual diff that I can't see locally

@dleroux
Copy link
Contributor

dleroux commented Nov 14, 2019

The code looks good. I just question the animation. Since we don't have this type of animation today it sort of took me by surprise. Maybe @sarahill or @johanstromqvist can share their thoughts.

animation

@qq99
Copy link
Contributor Author

qq99 commented Nov 14, 2019

I'm cool without the animation too, just have it instantaneous, whichever most people prefer

The implementation on today's OrderDetails page has no animation

@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch from 8391ad9 to c5de50b Compare November 14, 2019 16:18
@dleroux
Copy link
Contributor

dleroux commented Nov 14, 2019

I think percy bugged out? 🤔 Showing visual diff that I can't see locally

It's fine, it's because you added a new example.

@dleroux
Copy link
Contributor

dleroux commented Nov 14, 2019

I'm cool without the animation too, just have it instantaneous, whichever most people prefer

The implementation on today's OrderDetails page has no animation

I lean towards no animation, but let's see what the people I pinged think.

@BPScott
Copy link
Member

BPScott commented Nov 14, 2019

For the upwards caret I think we should use the proper icon CaretUpMinor instead of rendering CaretDownMinor upside down

@qq99
Copy link
Contributor Author

qq99 commented Nov 14, 2019

I chose to use the same icon (but rotate it) for the CSS transitions, otherwise it would be impossible

If we want to go static and no animations, we could use CaretUpMinor

@johanstromqvist
Copy link
Contributor

I don't have any strong opinions on the animation. If it does a good job for the user, I don't think it's a problem that it's novel.

Is it necessary? No I don't think so.
Is it an improvement from immediate change? Yes, I think it does add some context and responsiveness to the UI.

The animation probably looks more prominent isolated in the GIF, than it would when implemented. If the caret rotates together and in sync with the expand/collapse, I think the eye will be drawn to the content, not the caret.

@dleroux dleroux self-requested a review November 14, 2019 17:08
@qq99
Copy link
Contributor Author

qq99 commented Nov 18, 2019

Good to ship? Anyone 2nd ✅ ?

@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch 2 times, most recently from c3e3373 to a3a2dd1 Compare November 18, 2019 16:34
@brandon-yetman
Copy link

brandon-yetman commented Nov 19, 2019

Small example of the animation with popover content. Definitely echo @johanstromqvist that at least for me, the eye is drawn to the content and the animation is not as prominent. Makes the whole interaction feel more "fluid" in my opinion.

Kapture 2019-11-19 at 15 11 01

@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch from a3a2dd1 to 1c6ffe6 Compare November 19, 2019 21:14
…ify the direction the disclosure icon faces, CSS transition to animate when the prop changes
@qq99 qq99 force-pushed the button-disclosure-api-enhancement branch from 1c6ffe6 to d189453 Compare November 19, 2019 21:32
@qq99 qq99 merged commit f69365b into master Nov 19, 2019
@qq99 qq99 deleted the button-disclosure-api-enhancement branch November 19, 2019 21:40
Copy link
Contributor

@tmlayton tmlayton left a comment

Choose a reason for hiding this comment

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

For posterity: 👍

@dleroux dleroux temporarily deployed to production December 4, 2019 14:42 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.

6 participants