Skip to content

Commit

Permalink
feat: Allow href to be passed to pagination links in attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
remydenton committed Jul 17, 2018
1 parent 4d9c1ba commit 2c27e74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packages/components/bolt-pagination/pagination.schema.yml
Expand Up @@ -22,7 +22,7 @@ properties:
properties:
href:
type: string
description: The link for this pager item
description: The link for this pager item. Href may also be passed as part of attributes (which will take precedence).
attributes:
type: object
description: A Drupal-style attributes object for this link.
Expand All @@ -32,7 +32,7 @@ properties:
properties:
href:
type: string
description: The link for this pager item
description: The link for this pager item. Href may also be passed as part of attributes (which will take precedence).
attributes:
type: object
description: A Drupal-style attributes object for this link.
Expand All @@ -42,7 +42,7 @@ properties:
properties:
href:
type: string
description: The link for this pager item
description: The link for this pager item. Href may also be passed as part of attributes (which will take precedence)
attributes:
type: object
description: A Drupal-style attributes object for this link.
Expand All @@ -52,7 +52,7 @@ properties:
properties:
href:
type: string
description: The link for this pager item.
description: The link for this pager item. Href may also be passed as part of attributes (which will take precedence)
attributes:
type: object
description: A Drupal-style attributes object for this link.
Expand All @@ -62,7 +62,7 @@ properties:
properties:
href:
type: string
description: The link for this pager item.
description: The link for this pager item. Href may also be passed as part of attributes (which will take precedence)
attributes:
type: object
description: A Drupal-style attributes object for this link.
Expand Down
10 changes: 5 additions & 5 deletions packages/components/bolt-pagination/pagination.twig
Expand Up @@ -59,7 +59,7 @@
<nav class="{{ baseClass }}" role="navigation" aria-label="Pagination Navigation">
{% if previous %}
{% set previousAttributes = create_attribute(previous.attributes|default({})) %}
{% set previousAttributes = previousAttributes.setAttribute("href", previous.href) %}
{% set previousAttributes = previousAttributes.setAttribute("href", previousAttributes.href|default(previous.href)) %}
<a {{ previousAttributes.addClass("#{baseClass}__item", "#{baseClass}__item--prev") }}>
<span class="{{ "#{baseClass}__icon" }}">
<bolt-icon name="chevron-left" size="small"></bolt-icon>
Expand All @@ -72,7 +72,7 @@

{% if first %}
{% set firstAttributes = create_attribute(first.attributes|default({})) %}
{% set firstAttributes = firstAttributes.setAttribute("href", first.href) %}
{% set firstAttributes = firstAttributes.setAttribute("href", firstAttributes.href|default(first.href)) %}
<a {{ firstAttributes.addClass("#{baseClass}__item") }}>
<span class="{{ "#{baseClass}__text" }}">
<span class="u-bolt-visuallyhidden">
Expand All @@ -90,7 +90,7 @@
{% if pages %}
{% for key, link in pages %}
{% set linkAttributes = create_attribute(link.attributes|default({})) %}
{% set linkAttributes = linkAttributes.setAttribute("href", link.href) %}
{% set linkAttributes = linkAttributes.setAttribute("href", linkAttributes.href|default(link.href)) %}
{% set linkAttributes = linkAttributes.addClass("#{baseClass}__item") %}
{% if key == current %}
{% set linkAttributes = linkAttributes.addClass("is-current") %}
Expand Down Expand Up @@ -122,7 +122,7 @@

{% if last %}
{% set lastAttributes = create_attribute(last.attributes|default({})) %}
{% set lastAttributes = lastAttributes.setAttribute("href", last.href) %}
{% set lastAttributes = lastAttributes.setAttribute("href", lastAttributes.href|default(last.href)) %}
<a {{ lastAttributes.addClass("#{baseClass}__item") }}>
<span class="{{ "#{baseClass}__text" }}">
<span class="u-bolt-visuallyhidden">
Expand All @@ -135,7 +135,7 @@

{% if next %}
{% set nextAttributes = create_attribute(next.attributes|default({})) %}
{% set nextAttributes = nextAttributes.setAttribute("href", next.href) %}
{% set nextAttributes = nextAttributes.setAttribute("href", nextAttributes.href|default(next.href)) %}
<a {{ nextAttributes.addClass("#{baseClass}__item", "#{baseClass}__item--next") }}>
<span class="{{ "#{baseClass}__text" }}">
{{ nextText }}
Expand Down

0 comments on commit 2c27e74

Please sign in to comment.