Skip to content

Commit

Permalink
Merge pull request #2339 from alphagov/add-alignment-classes
Browse files Browse the repository at this point in the history
Add text align override classes
  • Loading branch information
hannalaakso authored Sep 20, 2021
2 parents 4b3c656 + bd29c22 commit d46debe
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
198 changes: 198 additions & 0 deletions app/views/examples/text-alignment/index.njk
Original file line number Diff line number Diff line change
@@ -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 %}
<h1 class="govuk-heading-xl">Text alignment</h1>

<h2 class="govuk-heading-m">govuk-!-text-align-right</h2>
{{ 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'
}
]
]
}) }}

<h2 class="govuk-heading-m">govuk-!-text-align-centre</h2>
{{ 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'
}
]
]
}) }}

<h2 class="govuk-heading-m">govuk-!-text-align-left</h2>
{{ 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 %}
1 change: 1 addition & 0 deletions src/govuk/overrides/_all.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "display";
@import "spacing";
@import "text-align";
@import "typography";
@import "width";
20 changes: 20 additions & 0 deletions src/govuk/overrides/_text-align.scss
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit d46debe

Please sign in to comment.