Skip to content

Commit

Permalink
Remove list-style for govspeak ordered lists
Browse files Browse the repository at this point in the history
This removes setting list-style on ordered lists to instead allow the
use of the type attribute on an ordered list to specify the list-style.

I couldn't determine why this style was needed. Current browsers style
this as list-style decimal by default and I can't find any code this
undoes. It could be that previously this was to undo an earlier
override, but it would be very unconventional for current GOV.UK to
style an `ol` without a class so this seems unlikely.

The motivation for making this change is to support some niche behaviour
used by publishers that will become disabled. Currently some advanced
published have managed to published ordered lists that are alphabetical
or roman numeral prefixed by use of an `ol` element with a style
attribute. This will not be available with the role out of the GOV.UK
Content Security Policy which forbids unsafe inline styles [1].

[1]: alphagov/govuk_app_config#291
  • Loading branch information
kevindew committed May 23, 2023
1 parent 3f169f7 commit 6db3373
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## Unreleased

* Remove list-style for govspeak ordered lists ([PR #3413](https://github.com/alphagov/govuk_publishing_components/pull/3413))
* Allow ga4-form-tracker text to be overridden ([PR #3409](https://github.com/alphagov/govuk_publishing_components/pull/3409))
* Change GA4 share values ([PR #3407](https://github.com/alphagov/govuk_publishing_components/pull/3407))
* Add GA4 index_section_count to step by step links ([PR #3410](https://github.com/alphagov/govuk_publishing_components/pull/3410))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@

ol,
ul {
list-style: decimal;
// we intentionally don't set list-style for ol elements, so that they can
// utilise the type attribute for the formatting. Browsers default to a
// style of decimal.
list-style-position: outside;
margin-left: $gutter-two-thirds;
padding: 0;
Expand Down
43 changes: 43 additions & 0 deletions app/views/govuk_publishing_components/components/docs/govspeak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,49 @@ examples:
</li>
<li>three</li>
</ul>
ordered_lists_types:
description: |
Govspeak/markdown does not generate HTML with type and start attributes,
however we still provide support for them as some advanced users write
HTML directly to achieve the list formatting.
data:
block: |
<h2>Lowercase alphabetical list</h2>
<ol type="a">
<li>one</li>
<li>two</li>
</ol>
<h2>Uppercase alphabetical list</h2>
<ol type="A">
<li>one</li>
<li>two</li>
</ol>
<h2>Lowercase Roman numeral list</h2>
<ol type="i">
<li>one</li>
<li>two</li>
</ol>
<h2>Uppercase Roman numberal list</h2>
<ol type="I">
<li>one</li>
<li>two</li>
</ol>
<h2>Numerical list starting at 3</h2>
<ol start="3">
<li>three</li>
<li>four</li>
</ol>
<h2>Lowercase alphabetical list, starting at 3</h2>
<ol type="a" start="3">
<li>three</li>
<li>four</li>
</ol>
legislative_lists:
data:
block: |
Expand Down

0 comments on commit 6db3373

Please sign in to comment.