From a679a64d29ae5cbe35473029629e2c6d5f4aabc3 Mon Sep 17 00:00:00 2001 From: Hanna Date: Tue, 7 Sep 2021 17:35:05 +0100 Subject: [PATCH 1/2] Add text-align override classes --- app/views/examples/text-alignment/index.njk | 198 ++++++++++++++++++++ src/govuk/overrides/_all.scss | 1 + src/govuk/overrides/_text-align.scss | 20 ++ 3 files changed, 219 insertions(+) create mode 100644 app/views/examples/text-alignment/index.njk create mode 100644 src/govuk/overrides/_text-align.scss diff --git a/app/views/examples/text-alignment/index.njk b/app/views/examples/text-alignment/index.njk new file mode 100644 index 0000000000..f0ec40a4a6 --- /dev/null +++ b/app/views/examples/text-alignment/index.njk @@ -0,0 +1,198 @@ +{% from "back-link/macro.njk" import govukBackLink %} +{% from "table/macro.njk" import govukTable %} + +{% extends "layout.njk" %} + +{% block beforeContent %} + {{ govukBackLink({ + "href": "/" + }) }} +{% endblock %} + +{% block content %} +

Text alignment

+ +

govuk-!-text-align-right

+ {{ govukTable({ + caption: "Month you apply", + captionClasses: "govuk-table__caption--m", + firstCellIsHeader: true, + head: [ + { + text: "Date" + }, + { + text: "Rate for vehicles", + classes: 'govuk-!-text-align-right' + }, + { + text: "Rate for bicycles", + classes: 'govuk-!-text-align-right' + } + ], + rows: [ + [ + { + text: "First 6 weeks" + }, + { + text: "£109.80 per week", + classes: 'govuk-!-text-align-right' + }, + { + text: "£59.10 per week", + classes: 'govuk-!-text-align-right' + } + ], + [ + { + text: "Next 33 weeks" + }, + { + text: "£159.80 per week", + classes: 'govuk-!-text-align-right' + }, + { + text: "£89.10 per week", + classes: 'govuk-!-text-align-right' + } + ], + [ + { + text: "Total estimated pay" + }, + { + text: "£4,282.20", + classes: 'govuk-!-text-align-right' + }, + { + text: "£2,182.20", + classes: 'govuk-!-text-align-right' + } + ] + ] + }) }} + +

govuk-!-text-align-centre

+ {{ govukTable({ + caption: "Month you apply", + captionClasses: "govuk-table__caption--m", + firstCellIsHeader: true, + head: [ + { + text: "Date" + }, + { + text: "Rate for vehicles", + classes: 'govuk-!-text-align-centre' + }, + { + text: "Rate for bicycles", + classes: 'govuk-!-text-align-centre' + } + ], + rows: [ + [ + { + text: "First 6 weeks" + }, + { + text: "£109.80 per week", + classes: 'govuk-!-text-align-centre' + }, + { + text: "£59.10 per week", + classes: 'govuk-!-text-align-centre' + } + ], + [ + { + text: "Next 33 weeks" + }, + { + text: "£159.80 per week", + classes: 'govuk-!-text-align-centre' + }, + { + text: "£89.10 per week", + classes: 'govuk-!-text-align-centre' + } + ], + [ + { + text: "Total estimated pay" + }, + { + text: "£4,282.20", + classes: 'govuk-!-text-align-centre' + }, + { + text: "£2,182.20", + classes: 'govuk-!-text-align-centre' + } + ] + ] + }) }} + +

govuk-!-text-align-left

+ {{ govukTable({ + caption: "Month you apply", + captionClasses: "govuk-table__caption--m", + firstCellIsHeader: true, + head: [ + { + text: "Date" + }, + { + text: "Rate for vehicles", + classes: 'govuk-!-text-align-left' + }, + { + text: "Rate for bicycles", + classes: 'govuk-!-text-align-left' + } + ], + rows: [ + [ + { + text: "First 6 weeks" + }, + { + text: "£109.80 per week", + classes: 'govuk-!-text-align-left' + }, + { + text: "£59.10 per week", + classes: 'govuk-!-text-align-left' + } + ], + [ + { + text: "Next 33 weeks" + }, + { + text: "£159.80 per week", + classes: 'govuk-!-text-align-left' + }, + { + text: "£89.10 per week", + classes: 'govuk-!-text-align-left' + } + ], + [ + { + text: "Total estimated pay" + }, + { + text: "£4,282.20", + classes: 'govuk-!-text-align-left' + }, + { + text: "£2,182.20", + classes: 'govuk-!-text-align-left' + } + ] + ] + }) }} + +{% endblock %} diff --git a/src/govuk/overrides/_all.scss b/src/govuk/overrides/_all.scss index 699a8711ce..7e475f3c6f 100644 --- a/src/govuk/overrides/_all.scss +++ b/src/govuk/overrides/_all.scss @@ -1,4 +1,5 @@ @import "display"; @import "spacing"; +@import "text-align"; @import "typography"; @import "width"; diff --git a/src/govuk/overrides/_text-align.scss b/src/govuk/overrides/_text-align.scss new file mode 100644 index 0000000000..90647a5455 --- /dev/null +++ b/src/govuk/overrides/_text-align.scss @@ -0,0 +1,20 @@ +@if not mixin-exists("govuk-exports") { + @warn "Importing items from the overrides layer without first importing `base` is deprecated, and will no longer work as of GOV.UK Frontend v4.0."; +} + +@import "../base"; + +// stylelint-disable declaration-no-important +@include govuk-exports("govuk/overrides/text-align") { + .govuk-\!-text-align-left { + text-align: left !important; + } + + .govuk-\!-text-align-centre { + text-align: center !important; + } + + .govuk-\!-text-align-right { + text-align: right !important; + } +} From bd29c2268287660b05825507f9805fbc6e607074 Mon Sep 17 00:00:00 2001 From: Hanna Date: Tue, 7 Sep 2021 17:57:34 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 668784aaba..cd483234a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New features + +- [#2339: Add text align override classes](https://github.com/alphagov/govuk-frontend/pull/2339) + ## 3.13.1 (Fix release) ### Fixes