Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Add grid-container #408

Merged
merged 1 commit into from Mar 1, 2016
Merged

Add grid-container #408

merged 1 commit into from Mar 1, 2016

Conversation

wardpenney
Copy link
Contributor

Builds on @whmii's Cask grid and previous PR #406. The goal is to do set up a few features:

  • Provide default grid configuration.
  • Enable multiple grids with different gutters and max-widths.
  • Enable collapsed grids (via gutter: 0 grid type)

screen shot 2016-02-05 at 12 54 30 pm

I still need to write tests and possibly factor the column width calculation into two discrete @functions.

LMKWYT!


width: calc(#{$_column-width-calc});
}
@else {

Choose a reason for hiding this comment

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

@else should be placed on same line as previous curly brace

Choose a reason for hiding this comment

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

@else should be placed on same line as previous curly brace

@joshuaogle
Copy link
Contributor

Has there been more discussion around namespacing? I liked the $grid- prefixes better than $neat- because I think it would be easier to remember and be nicer for users, but I understand wanting to avoid any possibility of conflicts.

@tysongach
Copy link
Contributor

Nice! This feels like a really great start…

I really enjoy the fact that instead of creating a special syntax, or term, you can create a gutter-less grid with gutter: 0. It’s damn clear.

///
/// @type map

$neat-grid-default: () !default;
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of this feels too similar to the one above, $neat-default-grid, which I think could easily lead to confusion or accidental bugs.

Maybe this one becomes $neat-base-grid? Or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh whops, I think I missed a copy-paste. I took that from Bourbon. Perhaps I don't need that +$neat-grid-default: () !default;? Now that I look at it, I don't think it's useful here.

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 think I see what you mean now, in relation to the later comment. So I'm going to remove it, and trying to convey to the user that they should define this ahead of time, if they don't want these default values

@tysongach
Copy link
Contributor

We’ll need to have a merging function of sorts, so to allow the user to define their overrides in a map, and those get merged in. Currently, I don’t think this works…

@wardpenney
Copy link
Contributor Author

@tysongach Can you explain the need for the merging functionality? I was trying to avoid the need to merge maps by not using the same variable.

This is done in a way that asks the developer to provide a grid context to the method call, as opposed to overriding an assumed global map variable. The methods use the base grid as fallback only. So it's either "use the default" or "provide your custom grid."

Wat do u think?

@wardpenney
Copy link
Contributor Author

@joshuaogle regarding naming prefix, I am down for both! What do y'all think?

We have had some issues, and anecdotal evidence that overly-generic variable names have conflicted with other frameworks and custom variables. I have not seen anyone using grid-, and definately not anyone using neat-. Either way (or other way) I do vote that we just be consistent and everything have the same prefix, 'cause:

  • Conflict mitigation
  • Explicitness to user

@tysongach
Copy link
Contributor

@wardpenney @joshuaogle Sass 4 is expected to introduce a native module system, and part of that system will (likely) allow us to associate prefixes dynamically, as well as allowing users to change/swap the prefix dynamically to their pleasing. It sounds incredible and you can read more about that here: https://github.com/sass/proposal.module-system#using-modules

@whmii
Copy link
Contributor

whmii commented Feb 11, 2016

So happy to see this. Pumped for some new functionality. I agree with @joshuaogle that personally I prefer grid prefixing to neat especially since we have everything so well scoped. I could see having neat-settings be a thing but then still using things like grid-column. Not that we always should take cues from others, but in poking around, I was unable to find another system that used a taxonimy like my-thing-column but the majority were using grid-column.

But it's not a huge issue for me. ¯_(ツ)_/¯

I would like to take a deeper look at this PR over all. lets hold off merging till at least Friday.
ty

@joshuaogle
Copy link
Contributor

I've done my best to completely tear this apart and find any use-case that I've come across that has made Neat frustrating to see how these changes hold up. I love it. Not only is the code so so much simpler than the current mixins, but the way you've set it up to handle multiple grids is really clever. I love the idea of setting up multiple grids (in grid-settings.scss, let's say) rather than overriding variables and some of the messier solutions I've seen out there.

Code looks great and this is nice solid foundation in my opinion 👍 Good work @wardpenney and @whmii!

@tysongach I hadn't seen the module system in Sass4, and it looks like the perfect solution to the naming problem (and I think a good reason to use grid- prefixes for now)

@whmii
Copy link
Contributor

whmii commented Feb 12, 2016

@wardpenney Hey I have a weird request. Would you mind rebasing your neat pr off of https://github.com/thoughtbot/neat/tree/neat-2.0.0-origin

It is just the addition of the grid columns mixin. I put a lot of work in to that system, and wanted to have my signature on it. Not because of the code itself but I feel like that file represents the idea as a whole. I thought it wouldn't bother me, but annoyingly it does. This is very petty. I apologize. 🙇

Also, based on some of the comments, I swapped out the neat prefix for grid on the mixins.

@wardpenney wardpenney force-pushed the neat-2.0.0-basic-grid branch 3 times, most recently from 045ec39 to 49650f1 Compare February 12, 2016 21:31
&::after {
clear: both;
content: "";
display: table;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be display block, Display table is no longer needed → thoughtbot/bourbon@7633f70

Copy link
Contributor

Choose a reason for hiding this comment

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

+1…don’t forget to also update Line 19 above, for the docs showing output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call!

@whmii
Copy link
Contributor

whmii commented Feb 15, 2016

BTW, I like the inclusion of grid-container, instead of grid row. I think grid-row is a leftover from when people were wrapping each row of content individually, which is very rare now a days.

@@ -0,0 +1,35 @@
/// Creates Neat grid container with clearfix.
///
/// @argument {list} $grid
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% on sass doc but I think this line should be:

/// @argument {map} $grid [$neat-default-grid]

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@tysongach
Copy link
Contributor

@whmii @wardpenney I’m confused why we rebased off of another branch and are now merging changes from that branch into neat-2.0.0 via this PR? I think we lost the focus of this PR by doing that.

If we go back to the original commit this PR was opened with, get it reviewed and merged, we can then put up a new PR with other additions (a2c5842). This way it gets a solid review, discussion and clear path in. Will you’re commit authorship will remain the same.

///
/// @type map
///
/// @property {number (unitless)} columns 12
Copy link
Contributor

Choose a reason for hiding this comment

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

The property’s default value should be in brackets:

- /// @property {number (unitless)} columns 12
+ /// @property {number (unitless)} columns [12]

@tysongach
Copy link
Contributor

I’m going to rebase and remove Will’s commit, which is the same commit in his new PR: #415

@tysongach
Copy link
Contributor

I removed 65980d3 and this PR is now solely Ward’s addition of grid-container.


@mixin grid-container($grid: $neat-default-grid) {
margin-left: auto;
margin-right: auto;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should “centering” be an option? Do we need it at all? Maybe this mixin is literally just a wrapper to a clearfix mixin, so to have a nice grid API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we had chatted a bit about that earlier and defaulted to this. But maybe the best thing to do is not try to do anything, and let the developer do it.

Other option is to handle it in the $grid map definition, center, left, or right but that seems like a lot of logic for little benefit. Also, on more than one project we wanted it left aligned at large breakpoints, and centered at lower ones. The $grid setting route would prove painful for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good to me. let's remove the option and just have this be a simple mixin with no options (since we aren't using $grid anyways).

Copy link
Contributor

Choose a reason for hiding this comment

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

So this grid-container will literally just be a wrapper for a clearfix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep 💩. I would imagine anyone using a floated grid would want this, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the margin styles may do more harm than good. I'm okay with it just being a clearfix wrapper. It's really all we need.

Copy link
Contributor

Choose a reason for hiding this comment

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

@wardpenney Yeah. To clarify, I think it's totally fine for this mixin to just be a clearfix. It makes for a good API for the grid system and prevents us from having to say “Oh, don't forget when you use grid columns, that you need to use a clearfix!”.

👍

@whmii
Copy link
Contributor

whmii commented Mar 1, 2016

#415 has been merged

<div class="box column--thirds">
</div>
<div class="box column--thirds">
</div>
</main>
</body>
</html>
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole file is oddly indented?

Copy link
Contributor

Choose a reason for hiding this comment

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

The pre tag will add indentation as whitespace in the code block that you can see. It looks weird here, but you have to.

Copy link
Contributor

Choose a reason for hiding this comment

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

@joshuaogle That pre tag is deleted. I’m referencing the fact that the entire HTML document is indented with two spaces: https://github.com/thoughtbot/neat/blob/neat-2.0.0-basic-grid/contrib/index.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay. Your comment was showing up on the deleted side so I thought you were just curious. Yep, good catch on that spacing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh weird, good catch.

@wardpenney wardpenney force-pushed the neat-2.0.0-basic-grid branch 2 times, most recently from b16573b to e7005de Compare March 1, 2016 18:13
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header class="welcome-message" role="banner">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove all these unused classes?

✂️ welcome-message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

@include grid-column(1, $nested-grid);
}

.grid__column--full {

Choose a reason for hiding this comment

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

Selector grid__column--full should be written in lowercase with hyphens

Choose a reason for hiding this comment

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

Selector grid__column--full should be written in lowercase with hyphens

@@ -0,0 +1,4 @@
$nested-grid: (
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to not put this in _variables.scss, since $nested-grid is just a variable?

@include grid-column(4);
}

.grid__column--full {

Choose a reason for hiding this comment

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

Selector grid__column--full should be written in lowercase with hyphens

@tysongach
Copy link
Contributor

👍 Do it.

@wardpenney wardpenney merged commit f589a7f into neat-2.0.0 Mar 1, 2016
@wardpenney wardpenney deleted the neat-2.0.0-basic-grid branch March 1, 2016 18:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants