-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
c76efa7
to
16af510
Compare
16af510
to
7c67173
Compare
7c67173
to
d67f8a7
Compare
There was a problem hiding this 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. 👍
src/components/Card/Card.scss
Outdated
+ .Section-subdued { | ||
border-top: border-width() solid color('sky'); | ||
margin-top: spacing(loose); | ||
} |
There was a problem hiding this comment.
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 + & {
...
}
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
(Haven’t had a chance to tophat yet, which is the only reason I didn’t approve.) |
b047b46
to
40a388a
Compare
There was a problem hiding this 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. 👍
There was a problem hiding this 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
src/components/Card/Card.scss
Outdated
|
||
.Section-subdued + & { | ||
border-top: border-width() solid color('sky'); | ||
padding: spacing(loose) spacing(loose) spacing(loose); |
There was a problem hiding this comment.
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.
padding: spacing(loose) spacing(loose) spacing(loose); | |
padding: spacing(loose); |
There was a problem hiding this comment.
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.
40a388a
to
4e06ecf
Compare
4e06ecf
to
e2677f9
Compare
I've been having a hard time getting |
There was a problem hiding this 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 🥇
e2677f9
to
d443823
Compare
d443823
to
acee905
Compare
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
After
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist