Skip to content

Commit

Permalink
Add option to include links in description list (#3464)
Browse files Browse the repository at this point in the history
Co-authored-by: SriHV <[email protected]>
Co-authored-by: SriHV <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2025
1 parent a2cf3fd commit 466335b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
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.
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 @@ -21,3 +21,4 @@
| ----------- | ------ | -------- | ----------------------------------------------------- |
| id | string | false | The HTML `id` for the description of the related term |
| description | string | true | The value of the description of the related term |
| url | string | false | The url of the description of the related term |
8 changes: 7 additions & 1 deletion src/components/description-list/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
{% 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 -}}
{%- if descriptionItem.url -%}
<a class="ons-description-list__link" href="{{ descriptionItem.url }}">
{{- descriptionItem.description -}}
</a>
{%- else -%}
{{- descriptionItem.description -}}
{%- endif -%}
</dd>
{% endif %}
{% endfor %}
Expand Down
5 changes: 4 additions & 1 deletion src/components/description-list/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const EXAMPLE_DESCRIPTION_LIST_FULL = {
{
id: 'description-3',
description: '49300005832',
url: '#',
},
],
},
Expand Down Expand Up @@ -142,7 +143,9 @@ describe('macro: description-list', () => {

expect($listElements[4].tagName).toBe('dd');
expect($($listElements[4]).attr('id')).toBe('description-3');
expect($($listElements[4]).text()).toBe('49300005832');
const $link = $($listElements[4]).find('a');
expect($link.attr('href')).toBe('#');
expect($link.text()).toBe('49300005832');
});

it.each([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"description": "Jacky Turner"
},
{
"description": "Louise Goodland"
"description": "Louise Goodland",
'url': '#'
}
]
}
Expand Down

0 comments on commit 466335b

Please sign in to comment.