-
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.
Refactor(web-twig): Rename Tabs components to same names as we have i…
…n react package
- Loading branch information
Showing
11 changed files
with
135 additions
and
42 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
12 changes: 12 additions & 0 deletions
12
packages/web-twig/src/Resources/components/Tabs/TabItem.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,12 @@ | ||
{# API #} | ||
{%- set _class = props.class | default(null) -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = _spiritClassPrefix ~ 'Tabs__item' -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _classNames = [ _rootClassName, _class ] -%} | ||
|
||
<li {{ mainProps(props) }} {{ classProp(_classNames)}}> | ||
{% block content %}{% endblock %} | ||
</li> |
39 changes: 39 additions & 0 deletions
39
packages/web-twig/src/Resources/components/Tabs/TabLink.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,39 @@ | ||
{# API #} | ||
{%- set _ariaTarget = props.ariaTarget | default(null) -%} | ||
{%- set _class = props.class | default(null) -%} | ||
{%- set _href = props.href | default(null) -%} | ||
{%- set _id = props.id | default(null) -%} | ||
{%- set _isSelected = props.isSelected | default(false) -%} | ||
|
||
{# Class names #} | ||
{%- set _isSelectedClassName = _isSelected == 'true' ? 'is-selected' : null -%} | ||
{%- set _rootClassName = _spiritClassPrefix ~ 'Tabs__link' -%} | ||
|
||
{# Attributes #} | ||
{%- set _ariaSelectedAttr = _isSelected ? 'true' : 'false' -%} | ||
{%- set _ariaControlsAttr = _ariaTarget ? 'aria-controls=' ~ _ariaTarget : null -%} | ||
{%- set _dataTargetAttr = _ariaTarget ? 'data-target=#' ~ _ariaTarget : null -%} | ||
{%- set _dataToggleAttr = _href ? null : 'data-toggle=tabs' -%} | ||
{%- set _hrefAttr = _href ? 'href=' ~ _href : null -%} | ||
{%- set _idAttr = _id ? ' id=' ~ _id : null -%} | ||
{%- set _roleAttr = _href ? 'role=tab' : null -%} | ||
{%- set _typeAttr = _href ? null : 'type=button' -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _classNames = [ _rootClassName, _isSelectedClassName, _class ] -%} | ||
{%- set _elementType = _href ? 'a' : 'button' -%} | ||
|
||
<{{ _elementType }} | ||
{{ mainProps(props) }} | ||
{{ classProp(_classNames) }} | ||
{{ _hrefAttr | raw }} | ||
{{ _idAttr }} | ||
{{ _roleAttr }} | ||
{{ _typeAttr }} | ||
{{ _dataToggleAttr | raw }} | ||
aria-selected="{{ _ariaSelectedAttr }}" | ||
{{ _dataTargetAttr | raw }} | ||
{{ _ariaControlsAttr }} | ||
> | ||
{% block content %}{% endblock %} | ||
</{{ _elementType }}> |
12 changes: 12 additions & 0 deletions
12
packages/web-twig/src/Resources/components/Tabs/TabList.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,12 @@ | ||
{# API #} | ||
{%- set _class = props.class | default(null) -%} | ||
|
||
{# Class names #} | ||
{%- set _rootClassName = _spiritClassPrefix ~ 'Tabs' -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _classNames = [ _rootClassName, _class ] -%} | ||
|
||
<ul {{ mainProps(props) }} {{ classProp(_classNames) }} role="tablist"> | ||
{% block content %}{% endblock %} | ||
</ul> |
26 changes: 26 additions & 0 deletions
26
packages/web-twig/src/Resources/components/Tabs/TabPane.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,26 @@ | ||
{# API #} | ||
{%- set _class = props.class | default(null) -%} | ||
{%- set _id = props.id | default(null) -%} | ||
{%- set _isSelected = props.isSelected | default(false) -%} | ||
{%- set _label = props.label | default(null) -%} | ||
|
||
{# Class names #} | ||
{%- set _isSelectedClassName = _isSelected == 'true' ? 'is-selected' : null -%} | ||
{%- set _rootClassName = _spiritClassPrefix ~ 'Tabs-pane' -%} | ||
|
||
{# Attributes #} | ||
{%- set _ariaLabelAttr = _label ? ' aria-labelledby=' ~ _label : null -%} | ||
{%- set _idAttr = _id ? ' id=' ~ _id : null -%} | ||
|
||
{# Miscellaneous #} | ||
{%- set _classNames = [ _rootClassName, _isSelectedClassName, _class ] -%} | ||
|
||
<div | ||
{{ mainProps(props) }} | ||
{{ classProp(_classNames) }} | ||
{{ _idAttr }} | ||
role="tabpanel" | ||
{{ _ariaLabelAttr }} | ||
> | ||
{% block content %}{% endblock %} | ||
</div> |
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/Tabs/TabItem.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/Tabs/TabLink.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/Tabs/TabList.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/Tabs/TabPane.twig' %} |
36 changes: 18 additions & 18 deletions
36
packages/web-twig/tests/components-fixtures/tabsDefault.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,23 +1,23 @@ | ||
<Tabs> | ||
<TabsItem> | ||
<TabsLink isSelected id="pane1-tab" target="pane1"> | ||
<TabList> | ||
<TabItem> | ||
<TabLink isSelected id="pane1-tab" target="pane1"> | ||
Item selected | ||
</TabsLink> | ||
</TabsItem> | ||
<TabsItem> | ||
<TabsLink id="pane2-tab" target="pane2"> | ||
</TabLink> | ||
</TabItem> | ||
<TabItem> | ||
<TabLink id="pane2-tab" target="pane2"> | ||
Item | ||
</TabsLink> | ||
</TabsItem> | ||
<TabsItem> | ||
<TabsLink href="https://www.example.com"> | ||
</TabLink> | ||
</TabItem> | ||
<TabItem> | ||
<TabLink href="https://www.example.com"> | ||
Item link | ||
</TabsLink> | ||
</TabsItem> | ||
</Tabs> | ||
<TabsPane id="pane1" isSelected label="pane1-tab"> | ||
</TabLink> | ||
</TabItem> | ||
</TabList> | ||
<TabPane id="pane1" isSelected label="pane1-tab"> | ||
Pane 1 | ||
</TabsPane> | ||
<TabsPane id="pane2" label="pane2-tab"> | ||
</TabPane> | ||
<TabPane id="pane2" label="pane2-tab"> | ||
Pane 2 | ||
</TabsPane> | ||
</TabPane> |