Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE(web-twig): Rename TabLink target prop to targetPaneId #DS-1096 #1399

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/migrations/web-twig/MIGRATION-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Introducing version 3 of the _spirit-web-twig_ package
- [Header: Abstracts Class and Style](#header-abstracts-class-and-style)
- [Modal: ModalDialog `isScrollable` Prop](#modal-modaldialog-isscrollable-prop)
- [Modal: ModalDialog Uniform Appearance](#modal-modaldialog-uniform-appearance)
- [Tabs: TabLink `target` Prop](#tabs-tablink-target-prop)
- [Tooltip: Composition](#tooltip-composition)

## General Changes
Expand Down Expand Up @@ -181,6 +182,17 @@ remains accessible via the `isDockedOnMobile` property.

Add `isDockedOnMobile` prop to the `ModalDialog` component.

### Tabs: TabLink `target` Prop

The `target` prop was renamed to `targetPaneId` in the `TabLink` component.
crishpeen marked this conversation as resolved.
Show resolved Hide resolved

The reason for this change is to avoid confusion with the
[`target` attribute][mdn-anchor-target] in the anchor tag.

#### Migration Guide

Replace `target` with `targetPaneId` in the `TabLink` component.

### Tooltip: Composition

The `Tooltip` component structure was changed, so `Tooltip` (formerly the optional
Expand Down Expand Up @@ -231,6 +243,7 @@ Please refer back to this guide or reach out to our team if you encounter any is
[alert-role-documentation]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role
[dictionary-placement]: https://github.com/lmc-eu/spirit-design-system/blob/main/docs/DICTIONARIES.md#placement
[dropdown-readme]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/src/Resources/components/Dropdown/README.md
[mdn-anchor-target]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target
[readme-additional-attributes]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/README.md#additional-attributes
[readme-deprecations]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/README.md#deprecations
[tooltip-readme]: https://github.com/lmc-eu/spirit-design-system/blob/main/packages/web-twig/src/Resources/components/Tooltip/README.md
16 changes: 8 additions & 8 deletions packages/web-twig/src/Resources/components/Tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Basic example usage:
```html
<TabList>
<TabItem>
<TabLink isSelected id="pane1-tab" target="pane1" data-spirit-toggle="tabs">Item selected</TabLink>
<TabLink isSelected id="pane1-tab" targetPaneId="pane1" data-spirit-toggle="tabs">Item selected</TabLink>
</TabItem>
<TabItem>
<TabLink id="pane2-tab" target="pane2" data-spirit-toggle="tabs">Item</TabLink>
<TabLink id="pane2-tab" targetPaneId="pane2" data-spirit-toggle="tabs">Item</TabLink>
</TabItem>
<TabItem>
<TabLink href="https://www.example.com">Item link</TabLink>
Expand All @@ -30,7 +30,7 @@ Without lexer:
{% embed "@spirit/tabLink.twig" with { props: {
id: 'pane1-tab',
isSelected: true,
target: 'pane1',
targetPaneId: 'pane1',
} } %}
{% block content %}
Item selected
Expand All @@ -56,11 +56,11 @@ There is no API for TabItem.

### TabLink

| Name | Type | Default | Required | Description |
| ------------ | -------- | ------- | -------- | ---------------------------- |
| `href` | `string` | `null` || URL target of a link |
| `isSelected` | `bool` | `false` || Whether is tab item selected |
| `target` | `string` | `null` || Target tab pane ID |
| Name | Type | Default | Required | Description |
| -------------- | -------- | ------- | -------- | ---------------------------- |
| `href` | `string` | `null` || URL target of a link |
| `isSelected` | `bool` | `false` || Whether is tab item selected |
| `targetPaneId` | `string` | `null` || Target tab pane ID |

### TabPane

Expand Down
6 changes: 3 additions & 3 deletions packages/web-twig/src/Resources/components/Tabs/TabLink.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
{%- set _ariaTarget = props.ariaTarget | default(null) -%}
{%- set _href = props.href | default(null) -%}
{%- set _isSelected = props.isSelected | default(false) -%}
{%- set _target = props.target | default(null) -%}
{%- set _targetPaneId = props.targetPaneId | default(null) -%}

{# Class names #}
{%- set _isSelectedClassName = _isSelected ? 'is-selected' : null -%}
{%- set _rootClassName = _spiritClassPrefix ~ 'Tabs__link' -%}

{# Attributes #}
{%- set _ariaControlsAttr = _target ? 'aria-controls="' ~ _target | escape('html_attr') ~ '"' : null -%}
{%- set _dataTargetAttr = _target ? 'data-spirit-target="#' ~ _target | escape('html_attr') ~ '"' : null -%}
{%- set _ariaControlsAttr = _targetPaneId ? 'aria-controls="' ~ _targetPaneId | escape('html_attr') ~ '"' : null -%}
{%- set _dataTargetAttr = _targetPaneId ? 'data-spirit-target="#' ~ _targetPaneId | escape('html_attr') ~ '"' : null -%}
{%- set _roleAttr = _href ? 'role="tab"' : null -%}
{%- set _typeAttr = _href ? null : 'type="button"' -%}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<TabList>
<TabItem>
<TabLink isSelected id="pane1-tab" data-spirit-toggle="tabs" target="pane1">
<TabLink isSelected id="pane1-tab" data-spirit-toggle="tabs" targetPaneId="pane1">
Item selected
</TabLink>
</TabItem>
<TabItem>
<TabLink id="pane2-tab" data-spirit-toggle="tabs" target="pane2">
<TabLink id="pane2-tab" data-spirit-toggle="tabs" targetPaneId="pane2">
Item
</TabLink>
</TabItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<TabList>
<TabItem>
<TabLink isSelected id="pane1-tab" data-spirit-toggle="tabs" target="pane1">Item 1</TabLink>
<TabLink isSelected id="pane1-tab" data-spirit-toggle="tabs" targetPaneId="pane1">Item 1</TabLink>
</TabItem>
<TabItem>
<TabLink id="pane2-tab" data-spirit-toggle="tabs" target="pane2">Item 2</TabLink>
<TabLink id="pane2-tab" data-spirit-toggle="tabs" targetPaneId="pane2">Item 2</TabLink>
</TabItem>
<TabItem>
<TabLink href="https://www.example.com">Item link</TabLink>
Expand Down
Loading