carbon-design-system / carbon-for-ibm-dotcom

Carbon for IBM.com is based on the Carbon Design System for IBM
https://www.ibm.com/standards/carbon/
Apache License 2.0
269 stars 156 forks source link

[Spacing] POC for Spacing logic #9561

Open oliviaflory opened 2 years ago

oliviaflory commented 2 years ago

User Story

As a Carbon for IBM.com developer I need to create a proof of concept of the spacing logic proposal.

Additional information

To support the explorations of the Spacing logic epic, we want to create a demo of the spacing logic proposal that the designers shared in the team huddle. This will help to see how our components look with consistent spacing applied throughout a page and will help the designers better define the rules for spacing.

Suggestion: dump a bunch of our components into a demo page to see how the spacing works.

Tasks:

oliviaflory commented 2 years ago

Ideas

Content block 1

Recreate Content block mixed using modular components:

Content block 2

Recreate AEMs custom layout:

Content block 3

Recreate AEMs custom layout:

oliviaflory commented 1 year ago

Review 10/26


Custom component vs Pre-build component

When we attempt to recreate a pre-build component with the individual pieces we provide to adopters, they don't always come out the same.

Example Re-creating Content group pictograms with:

Pre built components can have targeted styles that are controlling the alignment on the grid or targeting specific margin / padding.

Questions:

Styles, styles, styles

Can we get rid of some styles??

Example: Content group pictograms has styles targeting the pictogram item

Padding vs margin

Clarifying when padding vs margin should be used:

Content x are using margin and some are using padding

Questions:

RichKummer commented 1 year ago

Looked through the WC storybook and took a snapshot of whether the component overhangs or not. The overhang was most commonly from cards (even if optional), and bottom borders that extended into the gutter.

Overhang

No overhang

N/A

ariellalgilmore commented 1 year ago

Weird thing happening with cta cards...

Screen Shot 2022-10-27 at 3 10 29 PM
RichKummer commented 1 year ago

Margin/Padding notes

Wanted to visualize some of the rules we reviewed (ignore the placeholder text):

  1. When a margin value is stacked with a padding value, both are preserved and stacked:

Screen Shot 2022-11-01 at 11.31.26 AM.png

  1. When two margin values are stacked, only the largest value among them becomes the vertical spacing: Screen Shot 2022-11-01 at 11.33.36 AM.png

  2. When two padding values are stacked, they are both preserved and stacked on one another:

Screen Shot 2022-11-01 at 11.34.54 AM.png

More on Margins:

https://stackoverflow.com/questions/42652952/css-margins-not-collapsing

CSS margin collapsing only occurs vertically & under 3 circumstances:

  1. Adjacent siblings: The margins of adjacent siblings are collapsed (except when the later sibling needs to be cleared past floats). For example:

The bottom margin of this paragraph is collapsed...

...with the top margin of this paragraph.

  1. Parent and first/last child: If there is no border, padding, inline content, block_formatting_context created or clearance to separate the margin-top of a block from the margin-top of its first child block, or no border, padding, inline content, height, min-height, or max-height to separate the margin-bottom of a block from the margin-bottom of its last child, then those margins collapse. The collapsed margin ends up outside the parent.

  2. Empty blocks: If there is no border, padding, inline content, height, or min-height to separate a block's margin-top from its margin-bottom, then its top and bottom margins collapse.