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

Add text-align override classes #2339

Merged
merged 2 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}