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

Simplify the grid mixins #1090

Merged
merged 4 commits into from
Dec 13, 2018
Merged

Simplify the grid mixins #1090

merged 4 commits into from
Dec 13, 2018

Conversation

36degrees
Copy link
Contributor

This simplifies the grid to make it easier to add the extended grid.

  • Move grid widths to the settings layer and make part of the public API
  • Rename the grid-width function to govuk-grid-width to be consistent with other functions, retaining grid-width as as deprecated alias
  • Copy govuk-grid-row mixin to create a new concrete class and mark the mixin as deprecated
  • Update the govuk-grid-column mixin to allow class name to be suppressed by setting $class to false.
  • Mark the class parameter of the govuk-grid-column mixin as deprecated
  • Create grid classes programatically in objects layer by iterating over the $govuk-grid-widths map.

https://trello.com/c/1aBarhHU/1613-add-extended-grid-to-govuk-frontend-pair

This is to be consistent with other functions which are namespaced under the govuk prefix.

We keep grid-width as a deprecated alias which we can remove in the next major version.
Wrapping the row functionality up in a mixin offers little other than the ability to use a custom name, but we’re not sure there’s a need for users to do that.

Simplify the code by deprecating the mixin and just using the code to create the concrete class directly.
The class names generated by the mixin are not flexible enough, as the width is just appended to the class name. In spiking how we might add an extended grid we found the generated class names a little yoda-ish, for example `govuk-grid-column--at-desktop-one-quarter` (bonus points if you actually read that in Yoda’s voice).

Moving the class naming out of the mixin and doing it within the objects layer is also more consistent with the rest of Frontend, and means that users who do use the grid mixins directly don’t have to fit with the constraints of our class name structure.
@36degrees
Copy link
Contributor Author

I think there would be three issues raised against 3.0 off the back of this work:

  • Remove deprecated grid-width function
  • Remove deprecated govuk-grid-row mixin
  • Remove $class parameter and logic from the govuk-grid-column mixin


$govuk-grid-widths: (
one-quarter: 25%,
one-third: 33.3333%,
Copy link

Choose a reason for hiding this comment

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

Quick question. Is it worth letting the Sass language handle the precision here?

Swapping this out for:

one-third: (100/3) * 1%,

I believe this is possible in a map as according to the docs: "Both the keys and values in maps can be any SassScript object".

I doubt it would have any effect on the rounded result so may just be best left hardcoded.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth keeping it simple since it works and doesnt require thinking.

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

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

Nice work, this makes the mixin much less complicated while using a regular CSS feature instead of the class option.

I've checked the review application grid page and it renders the regular classes correctly.

👍 for noting we need to open issues to track the deprecations.

https://govuk-frontend-review-pr-1090.herokuapp.com/examples/grid

@36degrees
Copy link
Contributor Author

Verified that the CSS output is the same using both snapshots and a quick MD5 check:

➜  ~ curl https://govuk-frontend-review.herokuapp.com/public/app.css | md5
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  102k  100  102k    0     0   261k      0 --:--:-- --:--:-- --:--:--  261k
039d3275202aedb95bf0a5cbc92bafa3

➜  ~ curl https://govuk-frontend-review-pr-1090.herokuapp.com/public/app.css | md5
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  102k  100  102k    0     0   650k      0 --:--:-- --:--:-- --:--:--  651k
039d3275202aedb95bf0a5cbc92bafa3

@36degrees 36degrees merged commit 05d2b83 into master Dec 13, 2018
@36degrees 36degrees deleted the grid-updates branch December 13, 2018 09:46
aliuk2012 added a commit that referenced this pull request May 14, 2019
#1090 deprecated this mixin
and left it in as an alias to govuk-grid-width.

ACTION: Replace all instances of grid-width with govuk-grid-width
aliuk2012 added a commit that referenced this pull request May 14, 2019
#1090 copied govuk-grid-row
mixin to create a new concrete `.govuk-grid-row` class and marked the mixin as deprecated.

ACTION TO BE TAKEN: Remove any references to `govuk-grid-row` mixin and
                    use `.govuk-grid-row` class.

closes: #1092
aliuk2012 added a commit that referenced this pull request May 14, 2019
#1090 deprecated this mixin
and left it in as an alias to govuk-grid-width.

ACTION: Replace all instances of grid-width with govuk-grid-width
36degrees added a commit that referenced this pull request May 23, 2019
This functionality was previously deprecated in v2.5.0, although it was unfortunately not mentioned in the release notes.

[1]: #1090
36degrees added a commit that referenced this pull request May 23, 2019
This functionality was previously deprecated in v2.5.0 [1], although it was unfortunately not mentioned in the release notes.

[1]: #1090
aliuk2012 added a commit that referenced this pull request Jun 14, 2019
#1090 copied govuk-grid-row
mixin to create a new concrete `.govuk-grid-row` class and marked the mixin as deprecated.

ACTION TO BE TAKEN: Remove any references to `govuk-grid-row` mixin and
                    use `.govuk-grid-row` class.

closes: #1092
aliuk2012 added a commit that referenced this pull request Jun 14, 2019
#1090 deprecated this mixin
and left it in as an alias to govuk-grid-width.

ACTION: Replace all instances of grid-width with govuk-grid-width
aliuk2012 pushed a commit that referenced this pull request Jun 14, 2019
This functionality was previously deprecated in v2.5.0 [1], although it was unfortunately not mentioned in the release notes.

[1]: #1090
aliuk2012 added a commit that referenced this pull request Jun 14, 2019
#1090 copied govuk-grid-row
mixin to create a new concrete `.govuk-grid-row` class and marked the mixin as deprecated.

ACTION TO BE TAKEN: Remove any references to `govuk-grid-row` mixin and
                    use `.govuk-grid-row` class.

closes: #1092
aliuk2012 added a commit that referenced this pull request Jun 14, 2019
#1090 deprecated this mixin
and left it in as an alias to govuk-grid-width.

ACTION: Replace all instances of grid-width with govuk-grid-width
aliuk2012 pushed a commit that referenced this pull request Jun 14, 2019
This functionality was previously deprecated in v2.5.0 [1], although it was unfortunately not mentioned in the release notes.

[1]: #1090
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.

4 participants