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

Implemented configurable number of columns #74

Merged
merged 4 commits into from Feb 23, 2018

Conversation

marius7383
Copy link
Contributor

I very much like how many features of flexbox gridlex embraces. In various projects I came across the need to have different proportions / number of columns which is why I converted the hard-coded blocks into @for loops and introduced a variable called $gl-colCount which defaults to 12.
The file gridlex-preprocessing.scss uses this variable to calculate the column proportions and fractions which is then used in gridlex-mixins.scss to generate the needed column and grid definitions.
I though I'd try to give this back for all the time I saved by not having to create a grid system by myself. Maybe you find it useful as well and would be willing to merge this PR.

In any case: Thanks for gridlex!

dist/gridlex.css Outdated
[class~="grid"] > [data-push-right*="off-3"],
[class*="grid-"] > [data-push-right*="off-3"],
[class*="grid_"] > [data-push-right*="off-3"] {
margin-right: 25%; }

[class~="grid"] > [data-push-left*="off-4"],
Copy link
Owner

Choose a reason for hiding this comment

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

I have not look at all your work, but I see that offset are generated twice. Need to be fix before I decide to accept your great work :)

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 checked the diff of the CSS files again and it seems that it is not generated twice, but the order of rules between offset left and offset right is different if I put them in one for loop (as it is in this PR). If I seperate the loops as given below, the diff does not show any differences anymore. Would you like the loops to be seperate in order to have less differences?

// Function to generate the offset
@mixin makeOff($off)
{
  [#{$gl-attributeName}~="#{$gl-gridName}"],
  [#{$gl-attributeName}*="#{$gl-gridName}-"],
  [#{$gl-attributeName}*="#{$gl-gridName}_"] {
    @for $i from 0 through $gl-colCount - 1 {
      > [data-push-left*="#{$off}-#{$i}"]{ margin-left: map-get($gl-colPortions, $i); }
    }
  }

  [#{$gl-attributeName}~="#{$gl-gridName}"],
  [#{$gl-attributeName}*="#{$gl-gridName}-"],
  [#{$gl-attributeName}*="#{$gl-gridName}_"] {
    @for $i from 0 through $gl-colCount - 1 {
      > [data-push-right*="#{$off}-#{$i}"]{ margin-right: map-get($gl-colPortions, $i); }
    }
  }
}

@marius7383
Copy link
Contributor Author

marius7383 commented Feb 22, 2018

I just reworked the PR such that the diffs become slim and to be able to see that the offset rules are generated only once.
The only diff in the resulting CSS file is due some col_ rules that have been missing for grid_xx_11 in the previous version.

@devlint devlint merged commit 978b867 into devlint:master Feb 23, 2018
@devlint
Copy link
Owner

devlint commented Feb 23, 2018

Merge!
Thank you for your work !!

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.

None yet

2 participants