Skip to content

Commit

Permalink
BREAKING CHANGE(web-twig): ID prop is required for all Form component…
Browse files Browse the repository at this point in the history
…s #DS-885
  • Loading branch information
curdaj committed May 20, 2024
1 parent 8e4ab60 commit 90c2451
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 37 deletions.
16 changes: 0 additions & 16 deletions packages/web-twig/DEPRECATIONS-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ Following deprecations will be removed in version 3 of the _spirit-web-twig_ pac

## Deprecations

### Required `id` Prop For Form Components

The `id` prop will be required for all form components.

Related components:

- `Checkbox`
- `HelperText`
- `Radio`
- `Select`
- `ValidationText`

#### Migration Guide

Add `id` prop to the form components.

### Dropdown `id` Prop

The `id` prop will be mandatory for the `Dropdown` component.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# API #}
{%- set props = props | default([]) -%}
{%- set _helperText = props.helperText | default(null) -%}
{%- set _id = props.id | default(null) -%}
{%- set _id = props.id -%}
{%- set _inputProps = props.inputProps | default([]) -%}
{%- set _isChecked = props.isChecked | default(false) -%}
{%- set _isDisabled = props.isDisabled | default(false) -%}
Expand Down Expand Up @@ -44,11 +44,6 @@
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}
{%- set _allowedInputAttributes = [ 'autocomplete' ] -%}

{# Deprecations #}
{% if not _id %}
{% deprecated 'Checkbox: The "id" property will be required starting from the next major version.' %}
{% endif %}

<label for="{{ _id }}" {{ mainProps(_mainPropsWithoutId) }} {{ styleProp(_styleProps) }} {{ classProp(_classNames) }}>
<input
{{ inputProps(props, _allowedInputAttributes, _inputProps) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

<!-- Render with minimum props -->
<Checkbox
id="example-id"
id="example-id-min"
label="Example label"
/>

<!-- Render checked -->
<Checkbox
id="example-id"
id="example-id-checked"
isChecked
label="Example label"
/>

<!-- Render with helper text -->
<Checkbox
id="example-id"
id="example-id-helper"
label="Example label"
helperText="Example helper text"
/>

<!-- Render with hidden label -->
<Checkbox
id="example-id"
id="example-id-hidden"
isLabelHidden
label="Example label"
/>
Expand All @@ -31,7 +31,7 @@
{% set inputProps = { "data-validate": "true" } %}
<Checkbox
helperText="Example helper text"
id="example-id"
id="example-id-all"
inputProps={ inputProps }
isChecked
isDisabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
<body>
<label for="" class="Checkbox"><input type="checkbox" id="" class="Checkbox__input"></label>
<!-- Render with minimum props -->
<label for="example-id" class="Checkbox"><input type="checkbox" id="example-id" class="Checkbox__input">
<label for="example-id-min" class="Checkbox"><input type="checkbox" id="example-id-min" class="Checkbox__input">
<span class="Checkbox__text"><span class="Checkbox__label">Example label</span></span></label>
<!-- Render checked -->
<label for="example-id" class="Checkbox"><input type="checkbox" id="example-id" class="Checkbox__input" checked> <span class="Checkbox__text"><span class="Checkbox__label">Example label</span></span></label>
<!-- Render with helper text -->
<label for="example-id" class="Checkbox"><input type="checkbox" id="example-id" class="Checkbox__input">
<span class="Checkbox__text"><span class="Checkbox__label">Example label</span> <span class="Checkbox__helperText">Example helper text</span></span></label> <!-- Render with hidden label -->
<label for="example-id" class="Checkbox"><input type="checkbox" id="example-id" class="Checkbox__input">
<span class="Checkbox__text"><span class="Checkbox__label Checkbox__label--hidden">Example
<label for="example-id-checked" class="Checkbox"><input type="checkbox" id="example-id-checked" class="Checkbox__input" checked> <span class="Checkbox__text"><span class="Checkbox__label">Example
label</span></span></label> <!-- Render with helper text -->
<label for="example-id-helper" class="Checkbox"><input type="checkbox" id="example-id-helper" class="Checkbox__input"> <span class="Checkbox__text"><span class="Checkbox__label">Example label</span> <span class="Checkbox__helperText">Example helper text</span></span></label> <!-- Render with hidden label -->
<label for="example-id-hidden" class="Checkbox"><input type="checkbox" id="example-id-hidden" class="Checkbox__input"> <span class="Checkbox__text"><span class="Checkbox__label Checkbox__label--hidden">Example
label</span></span></label> <!-- Render with all props -->
<label for="example-id" class="Checkbox Checkbox--disabled Checkbox--item Checkbox--danger"><input data-validate="true" type="checkbox" id="example-id" class="Checkbox__input" checked disabled name="example-name" required="" value=""> <span class="Checkbox__text"><span class="Checkbox__label Checkbox__label--hidden Checkbox__label--required">UNSAFE label</span> <span class="Checkbox__helperText">UNSAFE helper text</span> <span class="Checkbox__validationText">Example validation
<label for="example-id-all" class="Checkbox Checkbox--disabled Checkbox--item Checkbox--danger"><input data-validate="true" type="checkbox" id="example-id-all" class="Checkbox__input" checked disabled name="example-name" required="" value=""> <span class="Checkbox__text"><span class="Checkbox__label Checkbox__label--hidden Checkbox__label--required">UNSAFE label</span> <span class="Checkbox__helperText">UNSAFE helper text</span> <span class="Checkbox__validationText">Example validation
text</span></span></label>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{# API #}
{%- set _autocomplete = props.autocomplete | default(null) -%}
{%- set _id = props.id | default(null) -%}
{%- set _id = props.id -%}
{%- set _inputProps = props.inputProps | default([]) -%}
{%- set _isChecked = props.isChecked | default(false) -%}
{%- set _isDisabled = props.isDisabled | default(false) -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# API #}
{%- set props = props | default([]) -%}
{%- set _helperText = props.helperText | default(null) -%}
{%- set _id = props.id | default(null) -%}
{%- set _id = props.id -%}
{%- set _inputProps = props.inputProps | default([]) -%}
{%- set _isDisabled = props.isDisabled | default(false) -%}
{%- set _isFluid = props.isFluid | default(false) -%}
Expand Down

0 comments on commit 90c2451

Please sign in to comment.