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

[WIP] Spacing doc draft #103

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

[WIP] Spacing doc draft #103

wants to merge 5 commits into from

Conversation

yaili
Copy link
Member

@yaili yaili commented May 14, 2020

Initial draft for spacing guidelines.

Original Google Doc draft (behind SSO).

Closes #102

@vercel
Copy link

vercel bot commented May 14, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/design/epws2f2c7
✅ Preview: https://design-git-users-yailispacing-doc.primer.vercel.app

docs/spacing.md Outdated Show resolved Hide resolved
docs/spacing.md Outdated

Icons

Inline spacing
Copy link
Member Author

@yaili yaili May 14, 2020

Choose a reason for hiding this comment

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

Need examples for this type of adjustment

@ashygee can you think of an example where inline spacing is important?

Can we write down how we usually handle inset spacing? For example, is it usually the same vertically and horizontally? Or is vertical padding usually smaller than horizontal?

docs/spacing.md Show resolved Hide resolved
docs/spacing.md Show resolved Hide resolved
docs/spacing.md Outdated Show resolved Hide resolved
docs/spacing.md Outdated

## Density

`[Examples: ]`
Copy link
Member Author

Choose a reason for hiding this comment

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

@vdepizzol can you think of one example of high density components (or areas of a page) and one of low density?

docs/spacing.md Show resolved Hide resolved
docs/spacing.md Outdated Show resolved Hide resolved
docs/spacing.md Show resolved Hide resolved

You can define different spacing values for different breakpoints, so the interface can better adapt to the available space.

`[Example: component with larger margin around it in large screen, vs smaller margin in small screen]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Find example component

Choose a reason for hiding this comment

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

You could reference the general spacing of the entire page? Padding/margin around most pages reduces at smaller screen sizes. I can try to think of some other examples, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks @colinkeany that's a good idea for now, do you know a page that would be better to use as an example? maybe something with not too much going on? 🤔

Choose a reason for hiding this comment

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

The issues page might be a good option? https://github.com/issues


In some cases, for very small components and in denser areas of the UI, you can use 4 pixels.

`[Example: text and icon button]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: image of text + icon button with redlines to indicate 4px space.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ashygee will create this


In some cases, the spacing values inside components don't follow the values in the scale, but the total size of the component should always follow the scale.

`[Example: the padding inside a button may be 3px or 5px but the total height is 32px]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: add image of a component with irregular padding values where total height follows the scale.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ashygee use large button as example


Elements that are close together are perceived as being related or part of the same group, while elements that are far apart from each other feel unrelated.

`[Examples: cancel, save buttons; repo top nav buttons]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Find an example of together and distant

Copy link
Member Author

Choose a reason for hiding this comment

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

We can use the header and indicate repo name / social buttons / tabs as 3 different groups.


As a general rule, elements should align to other elements' outer box, and not try to align to the content within a box.

`[Example: text outside and above a table/list should align to the edge of the table (and not to the content within the rows]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Add image of text above a list, and redline the alignment.

Copy link
Member Author

Choose a reason for hiding this comment

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


Do: Add more white space around components that are more important.

`[Examples: titles]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Add image of page titles.


Note: Editorial content can have more generous spacing.

`[Examples: first use cards, new features cards]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: example of editorial card.

Copy link
Member Author

Choose a reason for hiding this comment

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


Do: Apply the same spacing values to similar components.

`[Example: all items in the sidebar have the same vertical distance]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: redline vertical spacing between repo homepage sidebar elements.


In some cases, optical adjustments may break from the scale.

`[Example: avatar on commits in repo landing page align optically with file icons below]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: image of avatar + file icons alignment with redlines to show how it breaks


Small components usually have 8px between them. In some cases, for very small buttons, you can use 4px.

`[Example: buttons side by side, labels, icon+text]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: image of buttons side by side, and of icon+text button, redlines with values.

Copy link
Member Author

@yaili yaili Sep 25, 2020

Choose a reason for hiding this comment

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

Examples: side by side (separate) buttons it's 8px, and select field with save/delete button it's 4px (example in user settings)


The most common value when stacking components vertically is 16px.

`[Example: issue header above first comment, sidebar, stacked boxes]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Image of stacked boxes at the bottom of pull requests comments tab.


Generally, Primer elements have "squished" padding, where the vertical padding is smaller than the horizontal padding.

`[Example: squished padding element, like a button.]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Image of a representative squished element, ideally something else than a button so it's not always the same example. Ideas: a row, or tabs.


Some screens and flows require a denser layout, with smaller elements and less space between components, depending on the type of action users most often take. In these cases, use the smaller values of the spacing scale.

`[Examples: high density screen, or part of screen]`
Copy link
Member Author

@yaili yaili Sep 9, 2020

Choose a reason for hiding this comment

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

TODO: Find image of high density part of a screen with redlines of spacing

docs/spacing.md Outdated Show resolved Hide resolved
Copy link

@colinkeany colinkeany left a comment

Choose a reason for hiding this comment

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

Aside from updating/including the example images, this looks great!

@yaili yaili mentioned this pull request Jan 5, 2021
2 tasks
@yaili yaili marked this pull request as ready for review January 6, 2021 11:06
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.

Document spacing in Primer
2 participants