Skip to content

Vertical margin proposal #16

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

joebourne
Copy link
Contributor

No description provided.

function rhythm(size, direction = 'bottom') {
try {
if (!['top', 'bottom'].includes(direction)) {
throw `direction must be either 'top' or 'bottom'`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to throw an actual error here, as it has a stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've redone the error handling as a whole. Please can you check I've got the right idea?


```js
type Props = {|
variant: 'section' | 'semiSection',
Copy link
Contributor

Choose a reason for hiding this comment

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

Camel case or kebab case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 will go with kebab

}
```

As for the `<Section />` component, it will take a boolean prop `isFirst` that will determine whether or not the margin should be added to top and bottom.
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we agreed you could assign both ways?:

<Section spacingTop="section" spacingBottom="semi-section" />

I dont like the naming of spacingTop % spacingBottom so am open to suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

went with marginTop and marginBottom as that's explicit.

The `spacing` module will be renamed and will allow an optional second argument to specify the direction of the margin.

```js
function rhythm(size, direction = 'bottom') {
Copy link

@richiemccoll richiemccoll Aug 22, 2018

Choose a reason for hiding this comment

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

I think this name is worse than spacing tbh. One of the problems states that spacing is a confusing name because it could imply space in any direction, you've added that functionality here so surely the name makes sense now?

Copy link
Contributor

Choose a reason for hiding this comment

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

or it can by renamed to [vSpacing | vspacing] - to make it more specific

Copy link
Contributor

Choose a reason for hiding this comment

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

Its supposed to map to vertical rhythm rather than spacing. Maybe we should just name it that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gonna go with verticalMargin so there can be no confusion

@benkingcode
Copy link
Contributor

benkingcode commented Aug 22, 2018

Rhythm

I agree that the spacing util is very restrictive, and the name is confusing. There are certainly places in the UI on a micro level where it makes sense to be setting the margin on the top rather than the bottom, and this has been achieved in some places by duplicating the mixin's logic, which is not ideal.

Enabling margin-top as an option is definitely a minimum requirement, and I think this proposal is a good way to achieve that. Although I'm not sure that 5px makes sense as a default.

This proposal does have a shortcoming though in that it doesn't tackle setting padding. I personally think the CSS variables approach would still be the best way to resolve this fully. That way, on a component's styles you could set;

margin-bottom: var(--spacing-sm);
padding-top: var(--spacing-md);

etc, without the need for a mixin, and the value of the variable would be dynamically updated in a root media query, so the individual components don't need to know about media queries themselves. Only IE 11 does not support this dynamic variable updating natively, but since it's a desktop browser we could easily transpile it to always use the desktop sizes.

Section

I'm not sure I understand the correlation between isFirst and setting spacing on the top. Also, my initial thought when seeing the isFirst prop was, "why can't that be a pseudo selector"?

@joebourne joebourne changed the title Rhythm proposal Vertical margin proposal Aug 23, 2018
@joebourne
Copy link
Contributor Author

Thanks @dbbk

As discussed in the components working group on Monday, we're going to improve things incrementally and stage 1 is to sort out the issue with vertical margin.

Next step is to look more closely at layout components or utilities that concern all types of spacing: margin and padding, both vertical and horizontal.

As for CSS variables, this is again something worth looking into but out of the scope of this initial phase.

With regard to your other feedback, I've removed the isFirst logic so that should be clearer now, and I agree that the default value from the original spacing utility makes no sense so I've removed that.

@benkingcode
Copy link
Contributor

benkingcode commented Aug 23, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants