From 94a2b51c92ff49cd0ab1ffb3881411810bbbdbb4 Mon Sep 17 00:00:00 2001 From: Ian James Date: Thu, 9 Sep 2021 11:16:54 +0100 Subject: [PATCH 1/3] Reorder the navigation lists vertically Lists are easier to scan when each column is alphabetically sorted vertically. This is possible to do automagically with CSS columns, but Chrome doesn't like CSS columns when links are using `text-decoration-thickness` [1][2] - so another solution was needed. CSS Grid Layout has support going back to IE 10[3] and allows for vertical columns as long as the number of items in the columns are known - so when the navigation is updated the CSS controlling the grid needs to be updated. [1]: https://github.com/alphagov/govuk-frontend/issues/2204 [2]: https://bugs.chromium.org/p/chromium/issues/detail?id=1190987 [3]: https://caniuse.com/css-grid --- .../_layout-super-navigation-header.scss | 143 +++++++++++++++++- .../_layout_super_navigation_header.html.erb | 2 +- 2 files changed, 140 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss b/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss index ff1bbd7438..9c81902f16 100644 --- a/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +++ b/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss @@ -599,8 +599,11 @@ $search-icon-size: 20px; padding: govuk-spacing(2) 0 govuk-spacing(6) 0; @include govuk-media-query($from: "desktop") { - display: flex; - flex-wrap: wrap; + display: -ms-grid; + display: grid; + grid-auto-flow: column; + -ms-grid-columns: 1fr 1fr; + grid-template-columns: 1fr 1fr; margin-left: (0 - govuk-spacing(3)); margin-right: (0 - govuk-spacing(3)); padding: govuk-spacing(6) 0 govuk-spacing(8) 0; @@ -610,7 +613,139 @@ $search-icon-size: 20px; margin-bottom: 0; padding-left: govuk-spacing(3); padding-right: govuk-spacing(3); - width: 50%; + } + } +} + +.gem-c-layout-super-navigation-header__navigation-second-items--government-activity { + @include govuk-media-query($from: "desktop") { + -ms-grid-rows: 1fr 1fr 1fr; + grid-template-rows: 1fr 1fr 1fr; + + & > li { + &:nth-child(1) { + -ms-grid-row: 1; + -ms-grid-column: 1; + } + + &:nth-child(2) { + -ms-grid-row: 2; + -ms-grid-column: 1; + } + + &:nth-child(3) { + -ms-grid-row: 3; + -ms-grid-column: 1; + } + + &:nth-child(4) { + -ms-grid-row: 1; + -ms-grid-column: 2; + } + + &:nth-child(5) { + -ms-grid-row: 2; + -ms-grid-column: 2; + } + } + } +} + +.gem-c-layout-super-navigation-header__navigation-second-items--topics { + @include govuk-media-query($from: "desktop") { + -ms-grid-rows: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; + grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr; + + & > li { + &:nth-child(1) { + -ms-grid-row: 1; + -ms-grid-column: 1; + } + + &:nth-child(2) { + -ms-grid-row: 2; + -ms-grid-column: 1; + } + + &:nth-child(3) { + -ms-grid-row: 3; + -ms-grid-column: 1; + } + + &:nth-child(4) { + -ms-grid-row: 4; + -ms-grid-column: 1; + } + + &:nth-child(5) { + -ms-grid-row: 5; + -ms-grid-column: 1; + } + + &:nth-child(6) { + -ms-grid-row: 6; + -ms-grid-column: 1; + } + + &:nth-child(7) { + -ms-grid-row: 7; + -ms-grid-column: 1; + } + + &:nth-child(8) { + -ms-grid-row: 8; + -ms-grid-column: 1; + } + + &:nth-child(9) { + -ms-grid-row: 9; + -ms-grid-column: 1; + } + + &:nth-child(10) { + -ms-grid-row: 1; + -ms-grid-column: 2; + } + + &:nth-child(11) { + -ms-grid-row: 2; + -ms-grid-column: 2; + } + + &:nth-child(12) { + -ms-grid-row: 3; + -ms-grid-column: 2; + } + + &:nth-child(13) { + -ms-grid-row: 4; + -ms-grid-column: 2; + } + + &:nth-child(14) { + -ms-grid-row: 5; + -ms-grid-column: 2; + } + + &:nth-child(15) { + -ms-grid-row: 6; + -ms-grid-column: 2; + } + + &:nth-child(16) { + -ms-grid-row: 7; + -ms-grid-column: 2; + } + + &:nth-child(17) { + -ms-grid-row: 8; + -ms-grid-column: 2; + } + + &:nth-child(18) { + -ms-grid-row: 9; + -ms-grid-column: 2; + } } } } @@ -628,8 +763,8 @@ $search-icon-size: 20px; .gem-c-layout-super-navigation-header__navigation-second-item-link--with-description { @include govuk-font($size: 19, $weight: bold); + margin-top: govuk-spacing(2); margin-bottom: 0; - padding-bottom: govuk-spacing(1); } // Dropdown menu footer links. diff --git a/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb b/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb index 115af61d59..ac547f89bb 100644 --- a/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +++ b/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb @@ -134,7 +134,7 @@ show_navigation_menu_text = t("components.layout_super_navigation_header.menu_to <% if link[:menu_contents].present? %>
-