-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-twig): Introduce BreadcrumbsItem component
* and refactor Breadcrumbs to use it refs #DS-835
- Loading branch information
Showing
6 changed files
with
104 additions
and
48 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
42 changes: 42 additions & 0 deletions
42
packages/web-twig/src/Resources/components/Breadcrumbs/BreadcrumbsItem.twig
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,42 @@ | ||
{# API #} | ||
{%- set props = props | default([]) -%} | ||
{%- set _children = block('content') -%} | ||
{%- set _href = props.href -%} | ||
{%- set _isCurrent = props.isCurrent | default(false) -%} | ||
{%- set _isGoBackOnly = props.isGoBackOnly | default(false) -%} | ||
{%- set _unsafeIconStart = props.UNSAFE_iconStart | default(null) -%} | ||
{%- set _unsafeIconEnd = props.UNSAFE_iconEnd | default(null) -%} | ||
|
||
{# Class names #} | ||
{%- set _displayNoneClassName = _spiritClassPrefix ~ 'd-none' -%} | ||
{%- set _displayTabletNoneClassName = _spiritClassPrefix ~ 'd-tablet-none' -%} | ||
{%- set _displayTabletFlexClassName = _spiritClassPrefix ~ 'd-tablet-flex' -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _styleProps = useStyleProps(props) -%} | ||
{% if _isGoBackOnly is not same as(true) %} | ||
{%- set _classNames = [ _styleProps.className, _displayNoneClassName, _displayTabletFlexClassName ] -%} | ||
{% else %} | ||
{%- set _classNames = [ _styleProps.className, _displayTabletNoneClassName ] -%} | ||
{% endif %} | ||
|
||
<li {{ mainProps(props) }} {{ styleProp(_styleProps) }} {{ classProp(_classNames) }}> | ||
{% if _unsafeIconStart %} | ||
{{ _unsafeIconStart | raw }} | ||
{% endif %} | ||
<Link | ||
href="{{ _href }}" | ||
color="{{ _isCurrent ? 'secondary' : 'primary' }}" | ||
isUnderlined="{{ _isCurrent is not same as(true) }}" | ||
aria-current="{{ _isCurrent ? 'page' : 'false' }}" | ||
> | ||
{{ _children }} | ||
</Link> | ||
{% if _isCurrent is not same as(true) and _isGoBackOnly is not same as(true) %} | ||
{% if _unsafeIconEnd %} | ||
{{ _unsafeIconEnd | raw }} | ||
{% else %} | ||
<Icon name="chevron-right" /> | ||
{% endif %} | ||
{% endif %} | ||
</li> |
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
34 changes: 17 additions & 17 deletions
34
packages/web-twig/src/Resources/components/Breadcrumbs/stories/BreadcrumbsDefault.twig
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,20 +1,20 @@ | ||
{% set items = [ | ||
{ | ||
title: 'Root', | ||
url: '#rootUrl', | ||
}, | ||
{ | ||
title: 'Category', | ||
url: '#categoryUrl', | ||
}, | ||
{ | ||
title: 'Subcategory', | ||
url: '#subcategoryUrl', | ||
}, | ||
{ | ||
title: 'Current page', | ||
url: '#currentUrl', | ||
}, | ||
{ | ||
title: 'Root', | ||
url: '#rootUrl', | ||
}, | ||
{ | ||
title: 'Category', | ||
url: '#categoryUrl', | ||
}, | ||
{ | ||
title: 'Subcategory', | ||
url: '#subcategoryUrl', | ||
}, | ||
{ | ||
title: 'Current page', | ||
url: '#currentUrl', | ||
}, | ||
] %} | ||
|
||
<Breadcrumbs items={{ items }} /> | ||
<Breadcrumbs goBackTitle="Back" items={{ items }} /> |
1 change: 1 addition & 0 deletions
1
packages/web-twig/src/Resources/twig-components/breadcrumbsItem.twig
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 @@ | ||
{% extends '@spirit/Breadcrumbs/BreadcrumbsItem.twig' %} |