Skip to content

Commit

Permalink
Fix(web-twig): Remove unused Header Button onClick prop
Browse files Browse the repository at this point in the history
  • Loading branch information
crishpeen committed Apr 7, 2023
1 parent b7e5bab commit b9aa01c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
18 changes: 8 additions & 10 deletions packages/web-twig/src/Resources/components/Header/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Both links and buttons are supported:
<HeaderLink href="/">Link item</HeaderLink>
</HeaderNavItem>
<HeaderNavItem>
<HeaderButton onClick="console.log('Hello!')">Button item</HeaderButton>
<HeaderButton>Button item</HeaderButton>
</HeaderNavItem>
</HeaderNav>
```
Expand Down Expand Up @@ -264,10 +264,9 @@ Both links and buttons are supported:

##### HeaderButton API

| Prop name | Type | Default | Required | Description |
| --------- | -------- | ------- | -------- | ------------------------- |
| `class` | `string` | `null` | no | Custom CSS class |
| `onClick` | `string` || yes | Function to call on click |
| Prop name | Type | Default | Required | Description |
| --------- | -------- | ------- | -------- | ---------------- |
| `class` | `string` | `null` | no | Custom CSS class |

On top of the API options, you can add `data-*` or `aria-*` attributes to
further extend component's descriptiveness and accessibility. These attributes
Expand Down Expand Up @@ -376,7 +375,7 @@ Navigation items can be links, buttons, or just text:
</HeaderDialogLink>
</HeaderDialogNavItem>
<HeaderDialogNavItem>
<HeaderDialogButton onClick="console.log('Hello!')">
<HeaderDialogButton>
Button item
</HeaderDialogButton>
</HeaderDialogNavItem>
Expand Down Expand Up @@ -412,10 +411,9 @@ Navigation items can be links, buttons, or just text:

##### HeaderDialogButton API

| Prop name | Type | Default | Required | Description |
| --------- | -------- | ------- | -------- | ------------------------- |
| `class` | `string` | `null` | no | Custom CSS class |
| `onClick` | `string` || yes | Function to call on click |
| Prop name | Type | Default | Required | Description |
| --------- | -------- | ------- | -------- | ---------------- |
| `class` | `string` | `null` | no | Custom CSS class |

##### HeaderDialogText API

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{# API #}
{%- set props = props | default([]) -%}
{%- set _class = props.class | default(null) -%}
{%- set _onClick = props.onClick -%}
{%- set _rootClass = props.rootClass -%}

{# Class names #}
Expand All @@ -10,15 +9,9 @@
{# Miscellaneous #}
{%- set _classNames = [ _rootClassName, _class ] -%}

{# Deprecations #}
{% if _onClick %}
{% deprecated 'Header: The "onClick" property will be removed in the next major version. Use native "onclick" attribute instead.' %}
{% endif %}

<button
{{ mainProps(props) }}
{{ classProp(_classNames) }}
onclick="{{ _onClick }}"
type="button"
>
{% block content %}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<title></title>
</head>
<body>
<button class="HeaderLink" onclick="console.log('Hello!')" type="button">My account</button>
<!-- Render with all props -->
<button class="HeaderLink my-custom-class" onclick="console.log('Hello!')" type="button">My account</button>
<button class="HeaderLink" type="button">My account</button> <!-- Render with all props -->
<button class="HeaderLink my-custom-class" type="button">My account</button>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<title></title>
</head>
<body>
<button class="HeaderDialogLink" onclick="console.log('Hello!')" type="button">My account</button>
<!-- Render with all props -->
<button class="HeaderDialogLink my-custom-class" onclick="console.log('Hello!')" type="button">My account</button>
<button class="HeaderDialogLink" type="button">My account</button> <!-- Render with all props -->
<button class="HeaderDialogLink my-custom-class" type="button">My account</button>
</body>
</html>
4 changes: 2 additions & 2 deletions packages/web-twig/tests/components-fixtures/headerButton.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<HeaderButton onClick="console.log('Hello!')">My account</HeaderButton>
<HeaderButton>My account</HeaderButton>

<!-- Render with all props -->
<HeaderButton class="my-custom-class" onClick="console.log('Hello!')">
<HeaderButton class="my-custom-class">
My account
</HeaderButton>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<HeaderDialogButton onClick="console.log('Hello!')">My account</HeaderDialogButton>
<HeaderDialogButton>My account</HeaderDialogButton>

<!-- Render with all props -->
<HeaderDialogButton class="my-custom-class" onClick="console.log('Hello!')">
<HeaderDialogButton class="my-custom-class">
My account
</HeaderDialogButton>

0 comments on commit b9aa01c

Please sign in to comment.