-
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
Increase spacing scale #376
Conversation
3b0a701
to
100cc8f
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.
Thanks for starting this @gladwearefriends!!
Left some notes and questions inline.
) !default; | ||
|
||
// Adds aliases | ||
$spacer-7: nth($spacers, 8) !default; // 56px |
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.
We shouldn't redefine the whole map again, it will likely result in a lot of duplicate and unnecessary compiled CSS.
Instead, to keep things simple and readable, we can just define the variables manually (like: $spacer-7: $spacer * 7
). This can be added onto the existing variable file: https://github.com/primer/primer-css/blob/master/modules/primer-marketing-support/lib/variables.scss
@@ -0,0 +1,80 @@ | |||
// Margin spacer utilities | |||
// stylelint-disable block-opening-brace-space-before, declaration-colon-space-before, primer/selector-no-utility, comment-empty-line-before | |||
@for $i from 1 through length($spacers) { |
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.
Likewise here, we don't need this full loop since it will generate CSS for allll the spacer variables instead of just the biggos you're adding.
Two options:
- Specify which values you want to run the loop to limit it to just the new marketing spacers
- Ditch the fancy Sass loop all together and write it manually
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 gonna specify the new variables so the loop only goes through the new marketing spacers
/* Set a #{$size} margin on the top */ | ||
.mt-#{$scale} { margin-top : #{$size} !important; } | ||
/* Set a #{$size} margin on the right */ | ||
.mr-#{$scale} { margin-right : #{$size} !important; } |
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.
Do we need margin right and left for these? I can't think of any situations where I've wanted bigger values for these than what we've got. Currently, I feel like we just need the vertical values (to allow us to refactor jumbotron and featurette custom css). Taking these out will reduce a lot of final CSS.
(I'd be curious to hear from others on @primer/design-systems on if they agree)
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.
im gonna remove them unless others think otherwise! @primer/design-systems
/* Set a #{$size} margin on the left */ | ||
.ml-#{$scale} { margin-left : #{$size} !important; } | ||
/* Set a negative #{$size} margin on top */ | ||
.mt-n#{$scale} { margin-top : -#{$size} !important; } |
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 don't think we need biggo negative margins.
// Padding spacer utilities for marketing | ||
// stylelint-disable block-opening-brace-space-before, declaration-colon-space-before | ||
// stylelint-disable comment-empty-line-before | ||
@for $i from 1 through length($spacers) { |
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.
All the notes I left for margin apply to padding too.
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.
These changes all look good to me. Can you make sure to write docs for the spacers?
// Margin spacer utilities for marketing | ||
// Utilities only added for y-direction margin (i.e. top & bottom) | ||
// stylelint-disable block-opening-brace-space-before, declaration-colon-space-before, primer/selector-no-utility, comment-empty-line-before | ||
@for $i from 1 through length($marketingSpacers) { |
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.
Niiice
@@ -1,3 +1,13 @@ | |||
// Type | |||
$alt-body-font: Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Open Sans", sans-serif; | |||
$alt-mono-font: $mono-font; |
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.
hmm should I move these variables to the primer-marketing-type
module? @sophshep @broccolini
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 would keep them there, it allows them to be used in any modules for marketing.
f9dedd2
to
2f38f54
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.
Thanks for working on this @gladwearefriends 💖. Requesting some documentation changes.
@@ -1,3 +1,13 @@ | |||
// Type | |||
$alt-body-font: Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Open Sans", sans-serif; | |||
$alt-mono-font: $mono-font; |
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 would keep them there, it allows them to be used in any modules for marketing.
@@ -33,7 +33,7 @@ $ npm run build | |||
|
|||
## Documentation | |||
|
|||
|
|||
You can read more about utilities in the [docs folder](./docs/). |
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.
👍
@@ -0,0 +1,38 @@ | |||
--- | |||
title: Margin |
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.
The titles in the docs are also used in the navigation for the style guide so we need to prefix marketing styles with marketing
when there is a duplicate styles like margin.
@@ -38,6 +27,24 @@ The source files included are written in [Sass][sass] (`scss`) You can simply po | |||
|
|||
You can also import specific portions of the module by importing those partials from the `/lib/` folder. _Make sure you import any requirements along with the modules._ | |||
|
|||
## Documentation |
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.
When documentation is in a readme it needs to be wrapped in these tags so that we can pull only the documentation part, and not the rest of the readme, into the styleguide.
<!-- %docs
title:
status:
-->
## Documentation goes here
<!-- %enddocs -->
|
||
### Extended spacing scale | ||
This module includes extra variables that extend the Primer spacing scale for marketing site needs. | ||
Starting from where the `primer-core` spacing scale ends, we are stepping up by 16px increments... |
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.
Were you intending Starting from...
to be on the same line or a new paragraph? You'll need an extra line space if you want it to be on a new line. Small formatting thing, can you put the 16px in code tag, like this 16px
😁 .
We don't usually say "we", or shouldn't do once we update the voice and tone of the documentation, use back ticks on any units, and rather than the ...
use a colon at the end of the sentence. Also, I think included the spacer units helps.
Starting where the
primer-core
spacing scale ends at spacer 6, the marketing scale steps in increments of16px
from spacer 7 up to 11.
|
||
Use y-directional utilities to apply margin to the top, bottom or Y axis of an element. Directional utilities can change or override default margins, and can be used with a spacing scale of 7-11. | ||
|
||
Note: The marketing spacing scale extends the core 0-6 scale. See [primer-marketing-support](https://github.com/primer/primer-css/tree/master/modules/primer-marketing-support) for the extended marketing spacing scale. |
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.
You can remove this note if you update the intro para as per comment above.
|
||
## Responsive y-directional margins | ||
|
||
All y-directional margin utilities can be adjusted per [breakpoint](/styleguide/css/modules/grid#breakpoints) using the following formula: `m[y-direction]-[breakpoint]-[spacer]`. Each responsive style is applied to the specified breakpoint and up. |
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.
Suggest remove y-directional
with marketing:
All marketing margin utilities can be adjusted per...
</div> | ||
``` | ||
|
||
## Responsive y-directional margins |
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.
Suggest changing heading to: Responsive y-axis margin utilities
status_issue: https://github.com/github/design-systems/issues/378 | ||
--- | ||
|
||
Padding spacing utilities can be applied to elements to achieve bigger y-directional spaces beyond the `primer-core` spacing scale. |
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.
Could you make the same changes to padding based on the changes I suggested for margins?
|
||
## Y-Directional margin spacing | ||
|
||
Use y-directional utilities to apply margin to the top, bottom or Y axis of an element. Directional utilities can change or override default margins, and can be used with a spacing scale of 7-11. |
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 notice you're using "y-directional" quite a lot through the docs. It doesn't really roll off the tongue very well and I don't think it's a commonly used term 😬. In this instance I think you can get away from using by changing the sentence to the following:
Use marketing margin utilities to apply margin to top, bottom, or y-axis of an element.
I know it says "margin" twice but kinda difficult to get away from that here.
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.
Haha great point @broccolini ! I think i pulled it from our usage of "directional margins" and ran with it... agreed, axis is a much better term. I'll update it!
😬 😞 🙈 Going to pre-face this comment with a huge sorry to @gladwearefriends for not thinking of this earlier, but while I was reviewing the pr, something dawned on me and I think best to share now rather than ignore it. I had looked at the initial values and thought "they seem fine, if that's what works for marketing then cool", but then something started to bother me... I kept looking at 7 to 11 thinking this feels like an odd range, why don't we have 6 like core? And then I thought about how it's bothered me for a while that we start with a half step of This led me to seeing what happens if we started the marketing scale on 48 (because if we re-mapped core to This is what I aimed for with our other scales because design is often about horizontally and vertically lining a bunch of small and medium sized elements with other larger elements etc. Here's the re-mapped scale starting from
I think the marketing scale could have 6 steps like the core scale, that feels more natural and what people would expect. It also means starting the scale on a half step just like core. This is a fault of our core scale starting on a half step, we could have separated the I know the timing of this is not good, it's very late in the process. We're working up to a release next week, and @gladwearefriends ❤️ ❤️ ❤️ has done a ton of work on adding the Sass for the new scale, writing docs, and updating the GitHub codebase. However, after having shipped a not-so-great spacing scale in the past and then having to update it (ht Rohan and Mu-an), it's a painful process and could be worth the effort now to ship this with a better more composable scale—assuming it actually works for marketing too. @sophshep @gladwearefriends @jonrohan I'd like to hear what you think about this proposed scale? If you agree there's a number of ways we can go about rolling this out, and I also sincerely want to avoid extra pressure and work to @gladwearefriends - some options might be delaying v10, doing a minor release shortly after, and @primer/ds-core could take on the work to update too. Of course another option is that you might feel this updated version doesn't provide you enough benefits and feel the current proposed scale works better - I'm open to that too. |
The scale you're proposing looks good to me @broccolini. It will still give us all the values needed for marketing sites. You're right to speak up now vs. after it's shipped and is in use -- not hard to change a few values at this stage in the game! |
aff9bf5
to
2055351
Compare
@broccolini i updated the scale and updated the docs to reflect the new scale as well as remove my poor usage of thank you so much for reading everything carefully and putting thought into it. this was exactly why i wanted to open this PR so we could see the numbers and reflect on the scale more. dont feel bad at all for asking changes later in the game. its better to have a scale that works well for us! ive learned a lot about how our primer repo is set up and what things to consider when increasing the spacing scale (i.e. emphasis on composability of the values and what primer users would expect (marketing scale should mimic core scale)) so its been a great experience for me :) |
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.
A couple of bits of feedback, will review more thoroughly when I'm back next week.
@@ -38,6 +27,31 @@ The source files included are written in [Sass][sass] (`scss`) You can simply po | |||
|
|||
You can also import specific portions of the module by importing those partials from the `/lib/` folder. _Make sure you import any requirements along with the modules._ | |||
|
|||
<!-- %docs | |||
title: |
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 needs a title and status:
title: Marketing support
status: new release
And ## Documentation
should be before the <!--%docs
so that it looks good in the readme when someone views it on dotcom.
Documentation & refactor coming very soon | ||
|
||
<!-- %enddocs --> | ||
|
||
## Install |
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.
Usage instructions should follow ## Install
, it probably got missed with other updates 😬. Would you mind adding it? You can copy this section and update to say primer-marketing-support
: https://github.com/primer/primer/blob/master/modules/primer-support/README.md#usage
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.
Usage is already included below ## Install
here :) https://github.com/primer/primer/pull/376/files/7c8b3be162835cc4d51fedbb9f74d6f9036198ed#diff-e22f2520c00c79678dbb5d56c4e38b6aR20
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 sorry I missed that!
@gladwearefriends This looks good to go! I'll update your github pr before merging this one in so we can test. |
@gladwearefriends confirmed changes look good in github/github so I'm merging this in. |
TLDR
With
primer-marketing
we now have an extended spacing scale to use for y-axis spacingTesting on github/github here: https://github.com/github/github/pull/81032
Deployed to review lab here: https://testing-primer.review-lab.github.com/
To test on review-lab, slap some of those new classes onto some elements!
This has also been tested in storybook.
Hi friends!
Wanted to get a PR open to see if this works and also so we could discuss about exactly which increments to increase our spacing scale with. Previous conversation at https://github.com/github/design-systems/issues/378 where we established we needed this on marketing sites.
Some ideas that have been proposed.
After 40px,
In this PR i went ahead and jumped it by 16px. Only adding spacer utilities for y-directional spacing. i.e. mt-7, pb-7, my-7
.featurette
(50, 60, 80) and.jumbotron
(60, 100, 120) classes for github marketing pages.$spacers
variable through the margin & padding utility mixins again but not the most DRY way of doing that..featurette
and.jumbotron
classes/cc @primer/ds-core @sophshep