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

Remove redundant marketing layout selectors #1373

Merged
merged 4 commits into from
May 3, 2021

Conversation

tobiasahlin
Copy link
Contributor

@tobiasahlin tobiasahlin commented Apr 29, 2021

This PR removes redundant marketing layout selectors by checking for 0 in marketing/utlities/layout.scss:

@each $breakpoint, $variant in $marketing-position-variants {
  @include breakpoint($breakpoint) {
    @each $scale, $size in $marketing-all-spacers {
      @if ($size != 0 or $variant != "") {
        .top#{$variant}-#{$scale}     { top: $size !important; }
        .right#{$variant}-#{$scale}   { right: $size !important; }
        .bottom#{$variant}-#{$scale}  { bottom: $size !important; }
        .left#{$variant}-#{$scale}    { left: $size !important; }
      }

      @if ($size != 0) {
        .top#{$variant}-n#{$scale}     { top: -$size !important; }
        .right#{$variant}-n#{$scale}   { right: -$size !important; }
        .bottom#{$variant}-n#{$scale}  { bottom: -$size !important; }
        .left#{$variant}-n#{$scale}    { left: -$size !important; }
      }
    }
  }
}

This change removes these selectors from the marketing-utilities bundle (all redundant):

 // Already defined in primer core
.top-0 {}
.right-0 {}
.bottom-0 {}
.left-0 {}

// Redundant (they are not negative)
.top-n0 {}
.right-n0 {}
.bottom-n0 {}
.left-n0 {}
.top-md-n0 {}
.right-md-n0 {}
.bottom-md-n0 {}
.left-md-n0 {}
.top-lg-n0 {}
.right-lg-n0 {}
.bottom-lg-n0 {}
.left-lg-n0 {}

@changeset-bot
Copy link

changeset-bot bot commented Apr 29, 2021

🦋 Changeset detected

Latest commit: 46b6f6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/css Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tobiasahlin tobiasahlin requested review from simurai and jonrohan April 29, 2021 12:21
Copy link
Contributor

@simurai simurai left a comment

Choose a reason for hiding this comment

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

@jonrohan Are the utility classes like .top-n0 removed in this PR? If so, I guess this would need to be a major release and added to the deprecations?

Also, would it be possible to run the versionDeprecations script in every PR and not just once merged into main? Or is that bad for performance?

@tobiasahlin
Copy link
Contributor Author

tobiasahlin commented Apr 30, 2021

@jonrohan Are the utility classes like .top-n0 removed in this PR? If so, I guess this would need to be a major release and added to the deprecations?

They are 🙏 I've added all the deprecated selectors to deprecations.js ☝️

@tobiasahlin
Copy link
Contributor Author

@simurai Also bumped it to a major release 🙏 would love your fresh 👀

Copy link
Contributor

@simurai simurai left a comment

Choose a reason for hiding this comment

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

@simurai simurai merged commit b11e1bc into main May 3, 2021
@simurai simurai deleted the tobiasahlin/avoid-redundant-positioning-utilities branch May 3, 2021 12:21
@primer-css primer-css mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants