Skip to content

Commit

Permalink
<dl> element improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Dec 6, 2023
1 parent 4ae0d38 commit a7b471f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/nationalarchives/tna-frontend/compare/v0.1.29-prerelease...HEAD)

### Added

- `<dl>` elements can now be stacked with `<dl class="tna-dl tna-dl--stacked">`

### Changed

- Cookies class parameter `extraPolicies` moved to key inside the options object parameter
Expand All @@ -17,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Chip colours and icons in chip lists fixed
- Better support for `<dl class="tna-dl">` elements

### Security

Expand Down
19 changes: 10 additions & 9 deletions src/nationalarchives/stories/utilities/lists/lists.stories.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const argTypes = {
items: { control: "object" },
plain: { control: "boolean" },
classes: { control: "text" },
};

export default {
title: "Utilities/Lists",
argTypes,
};

const UnorderedListTemplate = ({ items, plain }) =>
`<ul class="tna-ul${plain ? " tna-ul--plain" : ""}">${items.reduce(
const UnorderedListTemplate = ({ items, plain, classes }) =>
`<ul class="tna-ul${plain ? " tna-ul--plain" : ""} ${classes}">${items.reduce(
(list, item) => `${list}<li>${item}</li>`,
"",
)}</ul>`;
Expand All @@ -23,8 +24,8 @@ UnorderedListPlain.args = {
plain: true,
};

const OrderedListTemplate = ({ items, plain }) =>
`<ol class="tna-ol${plain ? " tna-ol--plain" : ""}">${items.reduce(
const OrderedListTemplate = ({ items, plain, classes }) =>
`<ol class="tna-ol${plain ? " tna-ol--plain" : ""} ${classes}">${items.reduce(
(list, item) => `${list}<li>${item}</li>`,
"",
)}</ol>`;
Expand All @@ -38,10 +39,10 @@ OrderedListPlain.args = {
plain: true,
};

const DescriptionListTemplate = ({ items, plain }) =>
const DescriptionListTemplate = ({ items, plain, classes }) =>
`<dl class="tna-dl${plain ? " tna-dl--plain" : ""}${
items.some((item) => item.icon) ? " tna-dl--icon-padding" : ""
}">${items.reduce(
} ${classes}">${items.reduce(
(list, item) => `${list}
<dt>
${item.icon ? `<i class="fa-solid fa-${item.icon}"></i>` : ""}
Expand Down Expand Up @@ -130,10 +131,10 @@ ComplexDescriptionList.args = {
],
};

const ChipListTemplate = ({ items }) =>
`<ul class="tna-chip-list">${items.reduce(
const ChipListTemplate = ({ items, plain, classes }) =>
`<ul class="tna-chip-list ${classes}">${items.reduce(
(list, item) => `${list}<li class="tna-chip-list__item">
<span class="tna-chip">
<span class="tna-chip${plain ? " tna-chip--plain" : ""}">
${item.icon ? `<i class="fa-solid fa-${item.icon}"></i>` : ""}
${item.text}
</span>
Expand Down
81 changes: 52 additions & 29 deletions src/nationalarchives/utilities/_lists.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,46 @@
}
}

@mixin stacked-dl {
dt,
dd {
width: 100%;
margin-left: 0;
}

dd {
padding-left: 1rem;
}

&.tna-dl--plain {
dt {
padding-top: 0;
padding-bottom: 0;

.fa-solid {
margin-top: 0;
}
}

dd {
margin-left: 0;
padding-top: 0;
}
}

&:not(.tna-dl--plain) {
dt {
@include colour.colour-background("background-tint");
}

dd {
background: transparent !important;

margin-left: 0;
}
}
}

.tna-dl {
margin: 1rem 0 0;

Expand All @@ -53,11 +93,16 @@

&--plain {
dt {
padding-top: 0;
// padding-bottom: 0;
padding-left: 0;
}

dd {
// margin-bottom: 0.5rem;
padding-top: 0;
padding-right: 0;
// padding-bottom: 0;
}
}

Expand Down Expand Up @@ -101,6 +146,8 @@
padding-left: 2rem !important;

.fa-solid {
margin-top: -0.25rem;

left: 0;
}
}
Expand Down Expand Up @@ -132,36 +179,12 @@
}
}

@include media.on-tiny {
dt,
dd {
width: 100%;
margin-left: 0;
}

dd {
padding-left: 1rem;
}

&--plain {
dt {
padding-bottom: 0;
}

dd {
padding-top: 0;
}
}

&:not(&--plain) {
dt {
@include colour.colour-background("background-tint");
}
&--stacked {
@include stacked-dl;
}

dd {
background: transparent !important;
}
}
@include media.on-tiny {
@include stacked-dl;
}

@include colour.on-high-contrast-and-forced-colours {
Expand Down

0 comments on commit a7b471f

Please sign in to comment.