Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Card] Fix padding in small devices #608

Merged
merged 4 commits into from
Nov 15, 2018
Merged

[Card] Fix padding in small devices #608

merged 4 commits into from
Nov 15, 2018

Conversation

amireynoso
Copy link
Contributor

@amireynoso amireynoso commented Nov 13, 2018

WHY are these changes introduced?

Resolves https://github.com/Shopify/polaris-react-deprecated/issues/1999

Card is supposed to have a 16px padding in small devices, as defined in the UI kit. This was causing inconsistencies when Card is used with other components that respect the 16px spacing rule [see issue for screenshots and live demo].

WHAT is this pull request doing?

Sets the current spacing rules (20px) as desktop rules using the page-content-when-not-fully-condensed breakpoint (already in place for Card). And sets 16px as the default value.

Questions / concerns

I'm using the page-content-when-not-fully-condensed mixin, which was already being used in Card (breakpoint is at around 490px).

However, it's not consistent to other breakpoints in components that should behave similarly, such as ResourceList (breakpoint is at 458px).

Is page-content-when-not-fully-condensed the right call in this case? Or should I use the same hard-coded value as ResourceList?

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Screenshots

Before fix

Notice the difference between the ResourceList spacing in the second card and the card title (mobile only).

image

After fix

Desktop stays the same.
image

Copy-paste this code in playground/Playground.tsx:
import * as React from 'react';
import {
  Page,
  Card,
  ResourceList,
  CalloutCard,
  TextStyle,
} from '@shopify/polaris';

export default class Playground extends React.Component<never, never> {
  render() {
    return (
      <Page title="Playground">
        <Card title="Online store dashboard">
          <Card.Section title="Reports">
            <p>View a summary of your online store’s performance.</p>
          </Card.Section>

          <Card.Section title="Summary">
            <p>
              View a summary of your online store’s performance, including
              sales, visitors, top products, and referrals.
            </p>
          </Card.Section>
        </Card>
        <Card title="Card title">
          <ResourceList
            resourceName={{singular: 'customer', plural: 'customers'}}
            items={[
              {
                id: 341,
                url: 'customers/341',
                name: 'Mae Jemison',
                location: 'Decatur, USA',
              },
              {
                id: 256,
                url: 'customers/256',
                name: 'Ellen Ochoa',
                location: 'Los Angeles, USA',
              },
            ]}
            renderItem={this.renderItem}
          />
        </Card>
        <CalloutCard
          title="Customize the style of your checkout"
          illustration="https://cdn.shopify.com/s/assets/admin/checkout/settings-customizecart-705f57c725ac05be5a34ec20c05b94298cb8afd10aac7bd9c7ad02030f48cfa0.svg"
          primaryAction={{
            content: 'Customize checkout',
            url: 'https://www.shopify.com',
          }}
        >
          <p>Upload your store’s logo, change colors and fonts, and more.</p>
        </CalloutCard>
      </Page>
    );
  }

  private renderItem(item: any) {
    const {id, url, name, location} = item;

    return (
      <ResourceList.Item
        id={id}
        url={url}
        accessibilityLabel={`View details for ${name}`}
      >
        <h3>
          <TextStyle variation="strong">{name}</TextStyle>
        </h3>
        <div>{location}</div>
      </ResourceList.Item>
    );
  }
}

🎩 checklist

@ghost
Copy link

ghost commented Nov 13, 2018

👋 Thanks for opening your first pull request. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. You can also join #polaris on the Shopify Partners Slack.

@amireynoso amireynoso changed the title Card padding in mobile is now 16px instead of 20px [Card] Fix padding in small devices Nov 13, 2018
@BPScott BPScott temporarily deployed to polaris-react-pr-608 November 13, 2018 19:11 Inactive
@amireynoso amireynoso requested a review from ry5n November 13, 2018 19:23
@BPScott BPScott temporarily deployed to polaris-react-pr-608 November 13, 2018 19:23 Inactive
@@ -17,11 +17,19 @@
}

.Header {
padding: spacing(loose) spacing(loose) 0;
padding: spacing() spacing() 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On https://github.com/Shopify/polaris-react-deprecated/issues/1999#issuecomment-417046795 it was discussed that side paddings should be 16px, but for top and bottom, should it still be 20px?

Copy link
Member

Choose a reason for hiding this comment

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

IMO yes, but tagging in @sarahill 👋

@chloerice
Copy link
Member

chloerice commented Nov 13, 2018

I'm using the page-content-when-not-fully-condensed mixin, which was already being used in Card (breakpoint is at around 490px).

However, it's not consistent to other breakpoints in components that should behave similarly, such as ResourceList (breakpoint is at 458px).

Is page-content-when-not-fully-condensed the right call in this case? Or should I use the same hard-coded value as ResourceList?

I'm not sure what the basis for having the special breakpoint in the resource list component is, but you're using the correct mixin here 👍

@amireynoso
Copy link
Contributor Author

Thanks, @chloerice!

I'll wait for @sarahill's input into what the top/bottom padding should be, and update if needed.

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.

Code and tophat are 👍

@sarahill sarahill self-requested a review November 14, 2018 14:37
Copy link
Contributor

@sarahill sarahill left a comment

Choose a reason for hiding this comment

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

This looks good to me! Thanks for making this fix 💯

@amireynoso
Copy link
Contributor Author

Thanks, @sarahill and @chloerice! I've just updated the conflicts in the Changelog.

This is my first PR in Polaris, what are the next steps?

@BPScott BPScott temporarily deployed to polaris-react-pr-608 November 14, 2018 14:42 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-608 November 15, 2018 01:32 Inactive
@chloerice
Copy link
Member

This is my first PR in Polaris, what are the next steps?

Thanks again, @amireynoso 🎉 You're good to merge once the conflicts are resolved in UNRELEASED (it's an ever-moving target 😣). Ping me if you get any percy snapshot stuff that you're unsure of. (It's kind of cryptic, but for this PR the shift to the left of the red marks is expected)

@amireynoso
Copy link
Contributor Author

Hi @chloerice, thank you so much for your help! Seconds before you commented, I resolved the conflicts in the UNRELEASED doc. It made the Percy check fail again. Would you mind re-approving? I'll merge afterwards. Thanks again! 🙌

@ghost
Copy link

ghost commented Nov 15, 2018

🎉 Thanks for your contribution to Polaris React!

@amireynoso amireynoso deleted the card-mobile-spacing branch November 15, 2018 19:21
@danrosenthal danrosenthal temporarily deployed to production November 16, 2018 21:41 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