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 grid syntax #665

Merged
merged 5 commits into from
Apr 25, 2018
Merged

Simplify grid syntax #665

merged 5 commits into from
Apr 25, 2018

Conversation

kr8n3r
Copy link

@kr8n3r kr8n3r commented Apr 19, 2018

Simplify grid classes based on user feedback

  • Propose new class names:
.govuk-grid-row
.govuk-grid-column-   one-quarter, one-third, one-half, three-quarters, three-thirds, full
  • created a map of common widths that is used to generate classes
  • classes are using words, not numbers
  • parameter $at describes when the fraction percentage kicks in

Default usage:

// row
@include govuk-grid-row;
// row with a custom class
@include govuk-grid-row("app-row);

// columns
@include govuk-grid-column(one-quarter);
@include govuk-grid-column(one-third);
@include govuk-grid-column(one-half);
@include govuk-grid-column(two-thirds);
@include govuk-grid-column(three-quarters);
@include govuk-grid-column(full); or  @include govuk-grid-column();

Define when percentage kicks in:

@include govuk-grid-column(three-quarters, $at: desktop)

Specify a custom class:

@include govuk-grid-column(one-quarter, $class: "app-grid");

Note: the column mixin is similar to the Frontend toolkit one
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/stylesheets/_grid_layout.scss#L93

  • Update all references in the review app

Trello ticket: https://trello.com/c/jjWZkDe0/865-5-simplify-the-grid-syntax

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 19, 2018 08:01 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 19, 2018 08:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 19, 2018 08:09 Inactive
@dashouse
Copy link

Related - If we go with this we should update govuk-!-width-one-third override classes to govuk-!-width-1/3 etc too

Copy link
Contributor

@alex-ju alex-ju left a comment

Choose a reason for hiding this comment

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

I like the approach. It feels simpler to me and provides a powerful mixin that others can use in their service if they need a more complex grid.

Copy link
Member

@hannalaakso hannalaakso left a comment

Choose a reason for hiding this comment

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

I like this approach too 🎉👍 Good that users can now define more grid classes if needed. Naming wise, maybe .govuk-grid-col-1-4 (dash instead of slash), it's easier to remember and same as Bootstrap, slash is unusual.

// columns. Widths should be defined as fractions of the full desktop width
// they want to fill. By default they break to become full width at tablet size
// but that can be configured to be desktop using the `$full-width` argument.
//
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm I think $full-width sounds like 100% width which could be confusing as that's what the mobile column is. Maybe $fraction-width, $unit-width... I don't know, naming is hard.

Copy link
Author

Choose a reason for hiding this comment

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

went with $full-width as its the same param as in toolkit. maybe advanced users will be familiar with it.
it's more like "take proportional width at this breakpoint".
$full-width-from ?

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm so the column is not "full width" from that point on. On mobile/tablet the column is full width (or 100% width). At this breakpoint the column width becomes a fraction/unit. So the name of the variable should be the opposite of "full-width" but I don't know what. $fraction-width-from, $unit-width-from?

I might not be explaining this very well 😅

Copy link
Author

Choose a reason for hiding this comment

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

$breakpoint?

Copy link
Member

Choose a reason for hiding this comment

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

Or $break-from? I'm okay with either, we'll learn more in user research.

@include govuk-exports("grid") {
// A mixin for a grid column
// Creates a cross browser grid column with a standardised gutter between the
// columns. Widths should be defined as fractions of the full desktop width
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: "units" instead of "fractions"

Copy link
Author

Choose a reason for hiding this comment

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

i like units

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 08:35 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 09:05 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 09:22 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 09:30 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 12:17 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 20, 2018 12:39 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 08:40 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 10:12 Inactive
@@ -11,73 +11,97 @@

<main id="content" role="main" class="govuk-main-wrapper">
<h1 class="govuk-heading-l">Example: Grid layout</h1>
<div class="govuk-grid">
<div class="govuk-grid__item govuk-grid__item--two-thirds">
<div class="govuk-layout-row">
Copy link
Contributor

Choose a reason for hiding this comment

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

This is all opinionated but are we sure about layout? could this instead be grid? 😁

Choose a reason for hiding this comment

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

I tend to agree, I think govuk-grid-row / govuk-grid-column would be more expected

This guide shows how to make your service look consistent with the rest of GOV.UK. It includes example code and guidance for layout, typography, colour, images, icons, forms, buttons and data.
</p>
</div>
<div class="govuk-layout-col-two-thirds on-desktop-three-quarters">

Choose a reason for hiding this comment

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

I love the functionality of on-desktop-three-quarters but I'm worried it doesn't feel like it's part of the grid syntax.

Did we discuss anything like:
govuk-grid-col-two-thirds d:govuk-grid-col-three-quarters

Copy link
Author

Choose a reason for hiding this comment

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

on-desktop-three-quarters was an example class name. i could have just used
@include govuk-layout-col(three-quarters, $at: desktop, $class: "govuk-grid-col-desktop");

@include govuk-layout-col(full);

// custom 100,66,75%
@include govuk-layout-col(three-quarters, $at: desktop, $class: "on-desktop");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have custom examples as part of the core library? It seems good to demonstrate but we shouldn't include them unless we know they'll be used?

Copy link
Author

Choose a reason for hiding this comment

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

no for demo only. still WIP :)

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 15:41 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 15:53 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 15:57 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 19:37 Inactive
@kr8n3r kr8n3r changed the title WIP: Simplify grid Simplify grid syntax Apr 23, 2018
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 23, 2018 19:51 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-665 April 24, 2018 08:02 Inactive
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.

This is looking good to me, and the mixins may make it easier for downstream projects to make custom grids in a supported way.

Nice work 👍

@joelanman
Copy link
Contributor

This looks great, very readable/predictable.

There was some concern earlier that this was moving away from BEM, is that still the case?

@kr8n3r
Copy link
Author

kr8n3r commented Apr 24, 2018

it's now kinda BEM, just two block elements

@joelanman
Copy link
Contributor

From a quick discussion with @igloosi it seems like govuk-grid-row isn't quite what I'd expect.

In our example page, it doesn't wrap each row, it wraps the whole grid.

Is it at all useful to wrap each row? If not maybe the previous name was actually better - just govuk-grid

@kr8n3r
Copy link
Author

kr8n3r commented Apr 24, 2018

i guess if you have wildly differing content length in columns you might want to wrap in multiple rows

@joelanman
Copy link
Contributor

ok cool, so our guidance and examples would be to wrap each row with .govuk-grid-row? I think that would be fine

@kr8n3r
Copy link
Author

kr8n3r commented Apr 24, 2018

updated the example page

@dashouse
Copy link

@joelanman @igloosi I think the choice whether to use grid containers as individual rows or as a wrapper for all grid items is dependent on content to some degree...

For example I've used two rows here https://govuk-design-system-production.cloudapps.digital/styles/layout/common-two-thirds-two-thirds-one-third/index.html

But equally if you just fill 2/3 1/3 1/4 3/4 it wouldn't technically need a new row as they would wrap.

It gets a little more complex when you actually want it to wrap because your grid changes from 4 > 3 > 2 so it doesn't leave widowed columns

@joelanman
Copy link
Contributor

I think even if it would work in some situations if you didn't wrap every row, its an easier thing to get your head around if we always do?

@dashouse
Copy link

Sure, so this would be just updating the example in the review app rather than anything else?

@joelanman
Copy link
Contributor

Seems so, I just checked the Design System layout page and it seems like we already wrap every row there.

@kr8n3r
Copy link
Author

kr8n3r commented Apr 24, 2018

and i have updated the review app grid example page as well

@kr8n3r kr8n3r merged commit e4e483e into master Apr 25, 2018
@kr8n3r kr8n3r deleted the simplify-grid branch April 25, 2018 07:55
@kr8n3r kr8n3r mentioned this pull request May 18, 2018
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.

7 participants