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 option to include links in description list #3464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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.
4 changes: 4 additions & 0 deletions src/components/description-list/_description-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@
}
}
}

&__link {
display: inline;
}
}
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
Loading