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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
address div issue
precious-onyenaucheya-ons committed Nov 29, 2024
commit 6b953a84e48c9c71f1a6c484923d3451be6ec515
59 changes: 30 additions & 29 deletions src/components/description-list/_description-list.scss
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
.ons-description-list {
&__items {
&__items & {
margin: 0 0 2rem;
}

&--inline {
@include mq(l) {
grid-template-columns: repeat(3, 1fr);
display: grid;
gap: 0.5rem 2.5rem;
}
.ons-description-list__term,
.ons-description-list__value {
overflow-wrap: normal;
&__term {
clear: both;
float: left;
font-weight: $font-weight-bold;
word-break: break-word;
}
}

&__term {
clear: both;
float: left;
font-weight: $font-weight-bold;
&__value {
float: right;
margin-left: 0; /* As normalize adds a 40px left margin */
word-break: break-word;

&:not(:first-child) {
margin-top: 0.5rem;
& + & {
@include mq(m) {
margin-top: 0;
}
}
}
}

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

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

& + & {
@include mq(m) {
margin-top: 0;
}
&--inline {
@include mq(l) {
grid-template-columns: repeat(3, 1fr);
display: grid;
gap: 0.5rem 2.5rem;
}
}
}
18 changes: 9 additions & 9 deletions src/components/description-list/_macro-options.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
| Name | Type | Required | Description |
| -------------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| id | string | false | The HTML `id` for the description list (`<dl>`) |
| classes | string | false | Classes to apply to description list (`<dl>`) |
| descriptionListLabel | string | false | Sets the HTML `title` and `aria-label` attributes to provide additional information about the description list |
| 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) |
| variants | array or string | false | An array of values or single value (string) to adjust the component using available variants:“inline |
| Name | Type | Required | Description |
| -------------------- | ------------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| id | string | false | The HTML `id` for the description list (`<dl>`) |
| classes | string | false | Classes to apply to description list (`<dl>`) |
| descriptionListLabel | string | false | Sets the HTML `title` and `aria-label` attributes to provide additional information about the description list |
| 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 discription list inline |

## Item

16 changes: 4 additions & 12 deletions src/components/description-list/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{% macro onsDescriptionList(params) %}
<dl
class="ons-description-list ons-description-list__items ons-grid ons-grid--gutterless{{ " " + params.classes if params.classes else "" }}{{ " ons-description-list--inline" if params.variants == 'inline' else " ons-u-cf" }}"
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 %}
{% set descriptionItems %}
<div class="ons-description-list__item">
{% if item.term | length %}
<dt class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@m ons-grid-flex--no-wrap">
{{ item.term }}
</dt>
<dt class="ons-description-list__term ons-grid__col ons-col-{{ params.termCol }}@m">{{ item.term }}</dt>
{% endif %}

{% for descriptionItem in item.descriptions %}
@@ -24,13 +22,7 @@
</dd>
{% endif %}
{% endfor %}
{% endset %}

{% if params.variants == 'inline' %}
<div>{{ descriptionItems | safe }}</div>
{% else %}
{{ descriptionItems | safe }}
{% endif %}
</div>
{% endfor %}
</dl>
{% endmacro %}
2 changes: 1 addition & 1 deletion src/components/description-list/_macro.spec.js
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ describe('macro: description-list', () => {
const $ = cheerio.load(
renderComponent('description-list', {
...EXAMPLE_DESCRIPTION_LIST_MINIMAL,
variants: 'inline',
variant: 'inline',
}),
);

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
onsDescriptionList({
"classes": "ons-u-mb-no",
"descriptionListLabel": "Information about this business and its survey requirements",
"variants": 'inline',
"variant": 'inline',
"termCol": "4",
"descriptionCol": "8",
"itemsList": [