-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
205 combine macros and templates into one file (#269)
* Combine templates and macros into one file so Jinja wont complain about caller, and create test templates for unit tests * Update example macro and subnavigation macro * Ensure npm bundler doesnt deploy test templates
- Loading branch information
Showing
93 changed files
with
1,272 additions
and
1,268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
{% macro onsAccordion(params) %} | ||
{% include "components/accordion/_template.njk" %} | ||
{% from "components/details/_macro.njk" import onsDetails %} | ||
|
||
<div id="{{params.id}}" class="accordion{{ ' ' + params.classes if params.classes }}"> | ||
{% if params.openAll and params.closeAll %} | ||
{% from "components/button/_macro.njk" import onsButton %} | ||
{{ | ||
onsButton({ | ||
"text": params.openAll, | ||
"classes": "btn--secondary btn--small js-collapsible-all u-wa--@xs u-mb-s u-d-no", | ||
"attributes": { | ||
"data-ga": "click", | ||
"data-ga-category": "accordion", | ||
"data-ga-action": "Toggle all panels", | ||
"data-ga-label": params.openAll, | ||
"data-close-all": params.closeAll, | ||
"data-group": params.id | ||
} | ||
}) | ||
}} | ||
{% endif %} | ||
{% for item in params.items %} | ||
{{ | ||
onsDetails({ | ||
"isAccordion": true, | ||
"id": params.id + "-" + loop.index, | ||
"buttonOpen": params.buttonOpen, | ||
"closeButton": params.closeButton, | ||
"title": item.title, | ||
"content": item.content, | ||
"group": params.id | ||
}) | ||
}} | ||
{% endfor %} | ||
</div> | ||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% from "components/accordion/_macro.njk" import onsAccordion %} | ||
|
||
{{ onsAccordion(params) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
{% macro onsBreadcrumb(params) %} | ||
{% include "components/breadcrumb/_template.njk" %} | ||
<nav class="breadcrumb" aria-label="{{params.ariaLabel}}"> | ||
<ol class="breadcrumb__items"> | ||
{% for item in params.items %} | ||
<li class="breadcrumb__item u-fs-s{{ ' icon--breadcrumb' if loop.index < loop.length }}{{ ' breadcrumb__item--current' if item.current }}"> | ||
{% if item.current %} | ||
{{ item.text }} | ||
{% else %} | ||
<a href="{{ item.url }}" class="breadcrumb__link">{{ item.text }}</a> | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ol> | ||
</nav> | ||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
{% macro onsButton(params) %} | ||
{% include "components/button/_template.njk" %} | ||
{#- Define common attributes we can use for the toggle button type #} | ||
{% set buttonToggleAttributes %} aria-haspopup="true" aria-expanded="false" aria-controls="{{ params.ariaControls }}" aria-label="{{ params.ariaLabel }}"{% endset %} | ||
|
||
<button | ||
type="{{ params.type if params.type else 'submit' }}" | ||
class="btn{% if params.classes %} {{ params.classes }}{% endif %}{% if params.disabled %} btn--disabled{% endif %}" | ||
{% if params.id %}id="{{ params.id }}"{% endif %} | ||
{% if params.value %}value="{{ params.value }}"{% endif %} | ||
{% if params.name %}name="{{ params.name }}"{% endif %} | ||
{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %} | ||
{% for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %} | ||
{% if params.isToggle %}{{ buttonToggleAttributes | safe }}{% endif %} | ||
> | ||
{{- params.html | safe if params.html else params.text -}} | ||
</button> | ||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{%- macro onsCard(params) -%} | ||
{% include "components/card/_template.njk" %} | ||
<div class="card"> | ||
<h3 class="u-fs-l"> | ||
{% if params.url -%} | ||
<a href="{{ params.url }}"> | ||
{{ params.title }} | ||
</a> | ||
{%- else %} | ||
{{ params.title }} | ||
{% endif %} | ||
</h3> | ||
<p>{{ params.text }}</p> | ||
</div> | ||
{%- endmacro -%} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,56 @@ | ||
{% macro onsCheckboxes(params) %} | ||
{% include "components/checkboxes/_template.njk" %} | ||
{% from "components/field/_macro.njk" import onsField %} | ||
{% from "components/checkboxes/_checkbox-macro.njk" import onsCheckbox %} | ||
|
||
{% call onsField({ | ||
"id": params.id, | ||
"legend": params.legend, | ||
"description": params.description, | ||
"classes": params.classes, | ||
"mutuallyExclusive": params.mutuallyExclusive, | ||
"legendClasses": params.legendClasses, | ||
"questionMode": params.questionMode | ||
}) %} | ||
<div class="field__label">{{ params.checkboxesLabel }}</div> | ||
<div class="field__items"> | ||
{% for checkbox in params.checkboxes %} | ||
{% set labelHTML = checkbox.label.text %} | ||
{% if params.mutuallyExclusive %} | ||
{% set exclusiveClass = ' js-exclusive-group' %} | ||
{% endif %} | ||
<div class="field__item"> | ||
{{ | ||
onsCheckbox({ | ||
"id": checkbox.id, | ||
"name": checkbox.name, | ||
"value": checkbox.value, | ||
"checked": checkbox.checked, | ||
"classes": checkbox.classes, | ||
"inputClasses": exclusiveClass, | ||
"label": { | ||
"for": checkbox.id, | ||
"text": labelHTML, | ||
"description": checkbox.label.description, | ||
"classes": checkbox.label.classes | default('') | ||
}, | ||
"attributes": checkbox.attributes, | ||
"other": { | ||
"id": checkbox.other.id, | ||
"name": checkbox.other.name, | ||
"type": checkbox.other.type, | ||
"classes": checkbox.other.classes | default('') + exclusiveClass | default(''), | ||
"attributes": checkbox.other.attributes, | ||
"label": { | ||
"text": checkbox.other.label.text | ||
} | ||
} | ||
}) | ||
}} | ||
</div> | ||
{% if not loop.last %} | ||
<br> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
{% endcall %} | ||
{% endmacro %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% from "components/checkboxes/_macro.njk" import onsCheckboxes %} | ||
|
||
{{ onsCheckboxes(params) }} |
Oops, something went wrong.