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 inline description list variant #3439

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f4b1347
add inital changes
precious-onyenaucheya-ons Nov 27, 2024
349573c
approve vr tests
precious-onyenaucheya-ons Nov 27, 2024
52c7272
Merge branch 'main' into feature/189/add-horizontal-description-list
precious-onyenaucheya-ons Nov 27, 2024
22c7b5f
update as per PR comments
precious-onyenaucheya-ons Nov 28, 2024
79f772b
delete test example
precious-onyenaucheya-ons Nov 28, 2024
3555877
fix failing test
precious-onyenaucheya-ons Nov 28, 2024
2d3c0d0
Merge branch 'main' into feature/189/add-horizontal-description-list
precious-onyenaucheya-ons Nov 28, 2024
6b953a8
address div issue
precious-onyenaucheya-ons Nov 29, 2024
c62a87d
approve visual tests
precious-onyenaucheya-ons Nov 29, 2024
5dd8f0e
update breakpoints
precious-onyenaucheya-ons Nov 29, 2024
56775f8
update css
precious-onyenaucheya-ons Nov 29, 2024
0470ee4
fix typo
precious-onyenaucheya-ons Dec 2, 2024
224586e
Merge branch 'main' into feature/189/add-horizontal-description-list
precious-onyenaucheya-ons Dec 2, 2024
4fbc009
refactor to fit inline variant with figma design
precious-onyenaucheya-ons Dec 4, 2024
2f21710
approve visual test
precious-onyenaucheya-ons Dec 4, 2024
4ce8321
Merge branch 'main' into feature/189/add-horizontal-description-list
precious-onyenaucheya-ons Dec 4, 2024
f6ab261
fix accessibility issues
precious-onyenaucheya-ons Dec 4, 2024
724349b
fix grid issues
precious-onyenaucheya-ons Dec 5, 2024
0680abb
approve visual test
precious-onyenaucheya-ons Dec 5, 2024
11e71bb
Update src/components/description-list/_description-list.scss
precious-onyenaucheya-ons Dec 5, 2024
5938ce0
Update src/components/description-list/_macro.njk
precious-onyenaucheya-ons Dec 5, 2024
a42b1ce
Update src/components/description-list/_description-list.scss
precious-onyenaucheya-ons Dec 5, 2024
27bd708
revert changes
precious-onyenaucheya-ons Dec 5, 2024
b23bbf1
update column width
precious-onyenaucheya-ons Dec 6, 2024
035b326
update styling
precious-onyenaucheya-ons Dec 6, 2024
ff0de57
remove margin from item
precious-onyenaucheya-ons Dec 6, 2024
5d0e332
revert changes and approve visual test
precious-onyenaucheya-ons Dec 6, 2024
cf89efe
update css
precious-onyenaucheya-ons Dec 9, 2024
3aa7edd
remove unused css
precious-onyenaucheya-ons Dec 9, 2024
8f45296
update css
precious-onyenaucheya-ons Dec 9, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 40 additions & 9 deletions src/components/description-list/_description-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,56 @@
clear: both;
float: left;
font-weight: $font-weight-bold;

&:not(:first-child) {
margin-top: 0.5rem;
}
}

&__value {
float: right;
margin-left: 0; /* As normalize adds a 40px left margin */
}

&:not(:nth-of-type(1)) {
@include mq(m) {
&__item {
&:not(:first-child) {
.ons-description-list__term {
margin-top: 0.5rem;
}

.ons-description-list__value:nth-of-type(1) {
@include mq(m) {
margin-top: 0.5rem;
}
}

.ons-description-list--inline & {
.ons-description-list__value:nth-of-type(1),
.ons-description-list__term {
@include mq(l) {
margin-top: 0;
}
@include mq(xs, l) {
margin-top: 0.5rem;
}
admilne marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}

&--inline {
.ons-description-list__term {
padding-right: 1rem;
}

& + & {
@include mq(m) {
margin-top: 0;
@include mq(l) {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.5rem 2.5rem;

.ons-description-list__value {
grid-column-start: 2;
}

.ons-description-list__item {
display: grid;
grid-template-columns: auto 1fr;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/components/description-list/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| termCol | number | true | The number of grid columns used for the `<dt>` elements above medium breakpoint |
| descriptionCol | number | true | The number of grid columns used for the `<dd>` elements above medium breakpoint |
| itemsList | array`<Item>` | true | Settings for the terms and descriptions of the [description list items](#item) |
| variant | string | false | Set to "inline" to display the description list inline |

## Item

Expand Down
32 changes: 20 additions & 12 deletions src/components/description-list/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
{% macro onsDescriptionList(params) %}
<dl
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless ons-u-cf{{ " " + params.classes if params.classes else "" }}"
{% if params.id %}id="{{ params.id }}"{% endif %}{% if params.descriptionListLabel %}
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless{{ ' ons-description-list--inline' if params.variant == 'inline' else ' ons-u-cf' }}{{ ' ' + params.classes if params.classes else '' }}"
{% if params.id %}id="{{ params.id }}"{% endif %}
{% if params.descriptionListLabel %}
title="{{ params.descriptionListLabel }}" aria-label="{{ params.descriptionListLabel }}"
{% endif %}
>
{% for item in params.itemsList %}
{% if item.term | length %}
<dt class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
{% endif %}
{% for descriptionItem in item.descriptions %}
{% if descriptionItem.description | length %}
<dd
{% if descriptionItem.id %}id="{{ descriptionItem.id }}"{% endif %}class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@m"
<div class="ons-description-list__item">
{% if item.term | length %}
<dt
class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@{{ 'xs@l' if params.variant == 'inline' else 'm' }}"
>
{{- descriptionItem.description -}}
</dd>
{{- item.term -}}
</dt>
{% endif %}
{% endfor %}
{% for descriptionItem in item.descriptions %}
{% if descriptionItem.description | length %}
<dd
{% if descriptionItem.id %}id="{{ descriptionItem.id }}"{% endif %}
class="ons-description-list__value ons-grid__col ons-col-{{ params.descriptionCol }}@{{ 'xs@l' if params.variant == 'inline' else 'm' }}"
>
{{- descriptionItem.description -}}
</dd>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</dl>
{% endmacro %}
12 changes: 11 additions & 1 deletion src/components/description-list/_macro.spec.js
rmccar marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/** @jest-environment jsdom */

import * as cheerio from 'cheerio';

import axe from '../../tests/helpers/axe';
import { renderComponent } from '../../tests/helpers/rendering';

Expand Down Expand Up @@ -87,6 +86,17 @@ describe('macro: description-list', () => {
expect($('#example-id').length).toBe(1);
});

it('has the provided variant style class when variant is provided', () => {
const $ = cheerio.load(
renderComponent('description-list', {
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
variant: 'inline',
}),
);

expect($('.ons-description-list').hasClass('ons-description-list--inline')).toBe(true);
});

it('has additionally provided style classes', () => {
const $ = cheerio.load(
renderComponent('description-list', {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% from "components/description-list/_macro.njk" import onsDescriptionList %}
{{
onsDescriptionList({
"classes": "ons-u-mb-no",
"descriptionListLabel": "Information about this business and its survey requirements",
"variant": 'inline',
"termCol": "4",
"descriptionCol": "8",
"itemsList": [
{
"term": "Survey:",
"descriptions": [
{
"description": "Bricks & Blocks"
}
]
},
{
"term": "RU Refs:",
"descriptions": [
{
"description": "49900000118"
},
{
"description": "49300005832"
}
]
},
{
"term": "Business:",
"descriptions": [
{
"description": "Bolts & Ratchets Ltd."
}
]
},
{
"term": "Trading as:",
"descriptions": [
{
"description": "Bolts & Ratchets"
}
]
},
{
"term": "To:",
"descriptions": [
{
"description": "Jacky Turner"
},
{
"description": "Louise Goodland"
}
]
}
]
})
}}
Loading