Skip to content

Commit

Permalink
Merge pull request #102 from w3c/hotfix/#195-ordered-lists
Browse files Browse the repository at this point in the history
Hotfix/#195 ordered lists
  • Loading branch information
deniak authored Jun 20, 2023
2 parents 577a9c0 + 13eea78 commit 945d2ec
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 52 deletions.
32 changes: 6 additions & 26 deletions assets-src/styles/sass/30-base/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,21 @@ ul[class] {
}

ul:not([class]),
ol:not([class]) {
ol:not([class]),
ol.counter {
padding-inline-start: 2.4em;

> * + *,
li ul,
li ol {

margin-top: 0.75em;

}

}

ul:not([class]) {

padding-inline-start: 2.4em;

}

ol:not([class]) {

counter-reset: count;
list-style-type: none;
padding-inline-start: 1.25em;

> li {

counter-increment: count;

&::before {

content: counters(count, ".") " ";
padding-inline-end: 0.5em;

}
ol.counter {

::marker {
content: counters(list-item, ".") ". ";
}

}
Expand Down
14 changes: 14 additions & 0 deletions design-system-templates/components/list-ol-counter.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ol class="counter">
<li>Level 1 list item 1</li>
<li>Level 1 list item 2</li>
<li>Level 1 list item 3
<ol>
<li>Level 2 list item 1</li>
<li>Level 2 list item 2</li>
<li>Level 2 list item 3</li>
</ol>
</li>
<li>Level 1 list item 4</li>
<li>Level 1 list item 5</li>
<li>Level 1 list item 6</li>
</ol>
2 changes: 1 addition & 1 deletion design-system-templates/components/list-ol.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<li>Level 1 list item 1</li>
<li>Level 1 list item 2</li>
<li>Level 1 list item 3
<ol>
<ol type="a">
<li>Level 2 list item 1</li>
<li>Level 2 list item 2</li>
<li>Level 2 list item 3</li>
Expand Down
4 changes: 3 additions & 1 deletion design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ in the `package.json` file. The compiled assets can be found in the `public/dist

#### Installing the build tools and running them

Make sure you are using the right version of npm to both install packages and run scripts. We strongly recommend using [nvm](https://github.com/nvm-sh/nvm)
to do so.

The npm version to use is defined in the `.nvmrc` file. To switch to that version, use the command:

```bash
nvm install --lts
nvm use
```

Expand Down
18 changes: 14 additions & 4 deletions docs/styles/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

Use lists to make blocks of text easier to read, and to break information into manageable chunks.

## Bulleted lists
## Unordered lists

<example title="Unordered list with bullets" src="components/list-ul.html.twig" />
<example title="Unordered list with markers" src="components/list-ul.html.twig" />

## Numbered lists
## Ordered lists

<example title="Ordered list with bullets" src="components/list-ol.html.twig" />
<example title="Ordered list with markers" src="components/list-ol.html.twig" />

### Using a counter for decimal numbering

Adding the `.counter` class to an ordered list will ensure that any nested ordered lists are displayed as decimals, with the first digit corresponding to the number of the parent list item:

<example title="Ordered list with a counter" src="components/list-ol-counter.html.twig" />

#### Considerations

The counter supports the `"start"` and `"reversed"` attributes on the ordered list, but does not support the `"type"` attribute, e.g. for roman numerals. Ordered lists with the `.counter` class will always use decimal numbers for the markers.

## Clean list

Expand Down
31 changes: 12 additions & 19 deletions public/dist/assets/styles/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -1709,33 +1709,26 @@ ul[class] {
padding: 0;
}

ul:not([class]),
ol:not([class]),
ol.counter {
-webkit-padding-start: 2.4em;
padding-inline-start: 2.4em;
}
ul:not([class]) > * + *,
ul:not([class]) li ul,
ul:not([class]) li ol,
ol:not([class]) > * + *,
ol:not([class]) li ul,
ol:not([class]) li ol {
ol:not([class]) li ol,
ol.counter > * + *,
ol.counter li ul,
ol.counter li ol {
margin-top: 0.75em;
}

ul:not([class]) {
-webkit-padding-start: 2.4em;
padding-inline-start: 2.4em;
}

ol:not([class]) {
counter-reset: count;
list-style-type: none;
-webkit-padding-start: 1.25em;
padding-inline-start: 1.25em;
}
ol:not([class]) > li {
counter-increment: count;
}
ol:not([class]) > li::before {
content: counters(count, ".") " ";
-webkit-padding-end: 0.5em;
padding-inline-end: 0.5em;
ol.counter ::marker {
content: counters(list-item, ".") ". ";
}

.clean-list li {
Expand Down
2 changes: 1 addition & 1 deletion public/dist/assets/styles/core.min.css

Large diffs are not rendered by default.

0 comments on commit 945d2ec

Please sign in to comment.