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 subdued section spacing issues #1082

Merged
merged 1 commit into from
Mar 1, 2019
Merged

Conversation

solonaarmstrong-zz
Copy link

@solonaarmstrong-zz solonaarmstrong-zz commented Feb 21, 2019

WHY are these changes introduced?

Resolves #954

The first fix was here: #962 but it created too much spacing with non-subdued sections and the header. This fix targets only the subdued sections.

WHAT is this pull request doing?

Add spacing and a border between header and subdued section & footer and subdued section.

Before

screen shot 2019-02-21 at 10 26 59 am
screen shot 2019-02-21 at 10 27 12 am
screen shot 2019-02-21 at 10 27 20 am

After

screen shot 2019-02-21 at 10 27 38 am
screen shot 2019-02-21 at 10 27 45 am
screen shot 2019-02-21 at 10 27 49 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, List, DisplayText, TextContainer} from '../src';

interface State {}

export default class Playground extends React.Component<{}, State> {
  render() {
    return (
      <Page title="">
        <TextContainer>
          <DisplayText size="medium">Card.Section</DisplayText>
          <Card>
            <Card.Section title="Deactivated reports" subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <hr />
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Footer actions + subdued Card.Section
          </DisplayText>
          <Card
            secondaryFooterAction={{content: 'Dismiss'}}
            primaryFooterAction={{content: 'Export Report'}}
          >
            <Card.Section title="Deactivated reports" subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <TextContainer>
          <DisplayText size="medium">Footer actions + Card.Section</DisplayText>
          <Card
            secondaryFooterAction={{content: 'Dismiss'}}
            primaryFooterAction={{content: 'Export Report'}}
          >
            <Card.Section title="Deactivated reports">
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <hr />
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Card.Header + subdued Card.Section with title
          </DisplayText>
          <Card>
            <Card.Header
              actions={[
                {
                  content: 'Preview',
                },
              ]}
              title="Staff accounts"
            />
            <Card.Section title="Deactivated reports" subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Card.Header + Card.Section with title
          </DisplayText>
          <Card>
            <Card.Header
              actions={[
                {
                  content: 'Preview',
                },
              ]}
              title="Staff accounts"
            />
            <Card.Section title="Deactivated reports">
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Card.Header + Card.Section without title
          </DisplayText>
          <Card>
            <Card.Header
              actions={[
                {
                  content: 'Preview',
                },
              ]}
              title="Staff accounts"
            />
            <Card.Section>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <hr />
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Header actions + subdued Card.Section with title
          </DisplayText>
          <Card title="Title" actions={[{content: 'Add variant'}]}>
            <Card.Section title="Deactivated reports" subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Header actions + Card.Section with title
          </DisplayText>
          <Card title="Title" actions={[{content: 'Add variant'}]}>
            <Card.Section title="Deactivated reports">
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Header actions + Card.Section without title
          </DisplayText>
          <Card title="Title" actions={[{content: 'Add variant'}]}>
            <Card.Section>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
        <br />
        <hr />
        <br />
        <TextContainer>
          <DisplayText size="medium">
            Multiple subdued Card.Sections
          </DisplayText>
          <Card
            title="Title"
            actions={[{content: 'Add variant'}]}
            secondaryFooterAction={{content: 'Dismiss'}}
            primaryFooterAction={{content: 'Export Report'}}
          >
            <Card.Section>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
            <Card.Section subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
            <Card.Section subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
            <Card.Section>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
            <Card.Section subdued>
              <List>
                <List.Item>Payouts</List.Item>
                <List.Item>Total Sales By Channel</List.Item>
              </List>
            </Card.Section>
          </Card>
        </TextContainer>
      </Page>
    );
  }
}

🎩 checklist

@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 18:26 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 18:33 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 18:35 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 18:36 Inactive
Copy link
Contributor

@ry5n ry5n left a comment

Choose a reason for hiding this comment

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

This feels much better—a more direct way to solve the original issue. 👍

+ .Section-subdued {
border-top: border-width() solid color('sky');
margin-top: spacing(loose);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is styling a subdued section, should these rules be nested under the .Section selector instead?

.Section {
   ...

   .Header + & {
     ...
  }
}

Copy link
Author

@solonaarmstrong-zz solonaarmstrong-zz Feb 21, 2019

Choose a reason for hiding this comment

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

That was fast! Thank you.

The + is the key here. What it's doing is targeting the subdued section only if it's the next sibling of header.

The diff makes it hard to notice because every line is preceded by a + already.

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry, Ryan. I tried your suggestion and you're absolutely right. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I do have mixed feelings about doing it this way. Nesting with + & is hard to understand. By contrast, the CSS that it compiles to is plain as day: .Header + .Section {…}.

Separately, it’s really helpful to have all the styles for each element (in this case, all the styles for .Section) in one place in the file.

My personal preference would be to have both, by avoiding the + & contortions but keeping the styles together:

.Section {
  // All the basic styles for the section
}

.Header + .Section {
  // Specific styles for this case right below
}

However, I think our in-house Sass style prefers nesting, so we need to do the + & thing unless we want to open a discussion about code style.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I think the linter complains if you repeat a class.

@ry5n
Copy link
Contributor

ry5n commented Feb 21, 2019

(Haven’t had a chance to tophat yet, which is the only reason I didn’t approve.)

@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 20:04 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 21, 2019 21:19 Inactive
Copy link
Contributor

@ry5n ry5n left a comment

Choose a reason for hiding this comment

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

I can’t fit in time to 🎩 today, but the screenshots look good and so does the code. Appoved on the condition that another friendly neighborhood reviewer can take this for a spin with several combinations of Card content.

I like that it’s a small changeset targeting just the cases where there are issues. 👍

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 looks good to me, I'm tophatting the changes in web and then I'll be back to give the ✅

@@ -12,6 +12,8 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f

### Bug fixes

- Added padding and margin to `subdued` sections for proper spacing between the header and footer ([#1082](https://github.com/Shopify/polaris-react/pull/1082))
Copy link
Member

Choose a reason for hiding this comment

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

❤️


.Section-subdued + & {
border-top: border-width() solid color('sky');
padding: spacing(loose) spacing(loose) spacing(loose);
Copy link
Member

Choose a reason for hiding this comment

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

Since the same value is set for all sides, this can be set with a single value shorthand.

Suggested change
padding: spacing(loose) spacing(loose) spacing(loose);
padding: spacing(loose);

Copy link
Author

Choose a reason for hiding this comment

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

Oh, you're right, the left padding doesn't matter.

@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 22, 2019 16:44 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 22, 2019 16:44 Inactive
@chloerice
Copy link
Member

I've been having a hard time getting web to run 😣Gonna switch gears and compare master to these changes, brb...

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.

Looks good in all browsers, mobile and web 🥇 :shipit:

@BPScott BPScott temporarily deployed to polaris-react-pr-1082 February 23, 2019 01:48 Inactive
@ry5n ry5n self-assigned this Feb 27, 2019
@ry5n ry5n force-pushed the card-subdued-spacing branch from d443823 to acee905 Compare March 1, 2019 00:44
@ghost ghost added the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Mar 1, 2019
@ry5n ry5n merged commit dc91c87 into master Mar 1, 2019
@ry5n ry5n deleted the card-subdued-spacing branch March 1, 2019 01:09
@ry5n ry5n removed the cla-needed Added by a bot. Contributor needs to sign the CLA Agreement. label Mar 1, 2019
@amrocha amrocha temporarily deployed to production March 7, 2019 22:06 Inactive
tmlayton pushed a commit that referenced this pull request Mar 15, 2019
This reverts commit dc91c87, reversing
changes made to d926b0f.
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.

[Card] Padding issue between footer actions and subdued section card
5 participants