Skip to content

Commit

Permalink
changes as per ticket (#3305)
Browse files Browse the repository at this point in the history
Co-authored-by: Precious Onyenaucheya <86783201+precious-onyenaucheya-ons@users.noreply.github.com>
Co-authored-by: Alessio Venturini <112873190+alessioventuriniAND@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 1e09a5e commit 87a148c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
10 changes: 5 additions & 5 deletions src/components/section-navigation/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
| ------- | ---------------- | -------- | -------------------------------------------------- |
| classes | string | false | Additional classes for the list item element |
| url | string | true | The URL for the HTML `href` attribute for the link |
| title | string | true | The text for the link |
| text | string | true | The text for the link |
| anchors | `Array<Anchors>` | false | An array of [sub-section list anchors](#anchors) |

## Anchors

| Name | Type | Required | Description |
| ----- | ------ | -------- | ------------------------------------------------------- |
| url | string | true | The HTML `id` of the heading tag on the page to link to |
| title | string | true | The text for the anchor link |
| Name | Type | Required | Description |
| ---- | ------ | -------- | ------------------------------------------------------- |
| url | string | true | The HTML `id` of the heading tag on the page to link to |
| text | string | true | The text for the anchor link |
16 changes: 8 additions & 8 deletions src/components/section-navigation/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% endif %}
<ul class="ons-section-nav__list">
{% for item in section.itemsList %}
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title | lower) %}
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.text | lower) %}
{% set isCurrent = true %}
{% else %}
{% set isCurrent = false %}
Expand All @@ -33,16 +33,16 @@
{% if isCurrent == true %}
{{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
aria-current="location">{{ item.title }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
{% else %}
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
{% endif %}
{% if item.anchors and isCurrent == true %}
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
{% for anchor in item.anchors %}
<li class="ons-section-nav__item ons-list__item">
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link"
>{{ anchor.title }}</a
>{{ anchor.text }}</a
>
</li>
{% endfor %}
Expand All @@ -62,7 +62,7 @@
<ul class="ons-section-nav__list">
{% for item in params.itemsList %}
{% set sectionItemHeadingLevel = headingLevel + 2 if params.title else headingLevel + 1 %}
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.title | lower) %}
{% if (params.currentPath and item.url == params.currentPath) or (params.tabQuery and params.tabQuery == item.text | lower) %}
{% set isCurrent = true %}
{% else %}
{% set isCurrent = false %}
Expand All @@ -73,15 +73,15 @@
{% if isCurrent == true %}
{{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
aria-current="location">{{ item.title }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
{% else %}
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.title }}</a>
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
{% endif %}
{% if item.anchors %}
<ul class="ons-section-nav__sub-items ons-list ons-list--dashed ons-u-mt-xs ons-u-mb-xs">
{% for anchor in item.anchors %}
<li class="ons-section-nav__item ons-list__item">
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link">{{ anchor.title }}</a>
<a href="{{ anchor.url }}" class="ons-section-nav__link ons-list__link">{{ anchor.text }}</a>
</li>
{% endfor %}
</ul>
Expand Down
30 changes: 15 additions & 15 deletions src/components/section-navigation/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const EXAMPLE_SECTION_NAVIGATION = {
currentPath: '/results',
itemsList: [
{
title: 'Results',
text: 'Results',
url: '/results',
},
{
title: 'Dashboard',
text: 'Dashboard',
url: '/results/dashboard',
},
],
Expand All @@ -26,29 +26,29 @@ const EXAMPLE_SECTION_NAVIGATION_VERTICAL = {
currentPath: '#section-2',
itemsList: [
{
title: 'Section 1',
text: 'Section 1',
url: '#section-1',
},
{
title: 'Section 2',
text: 'Section 2',
url: '#section-2',
anchors: [
{
title: 'Sub section 1',
text: 'Sub section 1',
url: '#sub-section-1',
},
{
title: 'Sub section 2',
text: 'Sub section 2',
url: '#sub-section-2',
},
{
title: 'Sub section 3',
text: 'Sub section 3',
url: '#sub-section-3',
},
],
},
{
title: 'Section 3',
text: 'Section 3',
url: '#0',
},
],
Expand All @@ -62,29 +62,29 @@ const EXAMPLE_SECTION_NAVIGATION_VERTICAL_WITH_SECTIONS = {
title: 'Section Title',
itemsList: [
{
title: 'Section 1',
text: 'Section 1',
url: '#section-1',
},
{
title: 'Section 2',
text: 'Section 2',
url: '#section-2',
anchors: [
{
title: 'Sub section 1',
text: 'Sub section 1',
url: '#sub-section-1',
},
{
title: 'Sub section 2',
text: 'Sub section 2',
url: '#sub-section-2',
},
{
title: 'Sub section 3',
text: 'Sub section 3',
url: '#sub-section-3',
},
],
},
{
title: 'Section 3',
text: 'Section 3',
url: '#0',
},
],
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('macro: section-navigation', () => {
itemsList: [
{
classes: 'extra-class another-extra-class',
title: 'Section 1',
text: 'Section 1',
url: '#section-1',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"title": "Sections title",
"itemsList": [
{
"title": "Section 1",
"text": "Section 1",
"url": "#section-1"
},
{
"title": "Section 2",
"text": "Section 2",
"url": "#0"
},
{
"title": "Section 3",
"text": "Section 3",
"url": "#0"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
"title": "Section Title",
"itemsList": [
{
"title": "Section 1",
"text": "Section 1",
"url": "#section-1",
"anchors": [
{
"title": "Sub section 1",
"text": "Sub section 1",
"url": "#sub-section-1"
},
{
"title": "Sub section 2",
"text": "Sub section 2",
"url": "#sub-section-2"
},
{
"title": "Sub section 3",
"text": "Sub section 3",
"url": "#sub-section-3"
}
]
},
{
"title": "Section 2",
"text": "Section 2",
"url": "#section-2"
},
{
"title": "Section 3",
"text": "Section 3",
"url": "#section-3"
},
{
"title": "Section 4",
"text": "Section 4",
"url": "#section-4"
}
]
Expand All @@ -44,33 +44,33 @@
"title": "Section Title",
"itemsList": [
{
"title": "Section 5",
"text": "Section 5",
"url": "#section-5"
},
{
"title": "Section 6",
"text": "Section 6",
"url": "#section-6",
"anchors": [
{
"title": "Sub section 1",
"text": "Sub section 1",
"url": "#sub-section-1"
},
{
"title": "Sub section 2",
"text": "Sub section 2",
"url": "#sub-section-2"
},
{
"title": "Sub section 3",
"text": "Sub section 3",
"url": "#sub-section-3"
}
]
},
{
"title": "Section 7",
"text": "Section 7",
"url": "#0"
},
{
"title": "Section 8",
"text": "Section 8",
"url": "#0"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"currentPath": "#section-1",
"itemsList": [
{
"title": "Section 1",
"text": "Section 1",
"url": "#section-1"
},
{
"title": "Section 2",
"text": "Section 2",
"url": "#0"
},
{
"title": "Section 3",
"text": "Section 3",
"url": "#0"
}
]
Expand Down

0 comments on commit 87a148c

Please sign in to comment.