Skip to content

Commit

Permalink
Refactor(web-twig): Apply more stricter comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Jun 11, 2023
1 parent cd1927c commit 75548bb
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<{{ _elementType }}
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _collapseClassNames = [ _rootClassName, _isOpenClassName ] -%}
{%- set _contentClassNames = [ _accordionClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<div
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _ariaExpanded = _isOpen ? 'true' : 'false' -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<{{ _elementType }}
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<{{ _elementType }}
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
{%- if _items|length > 0 -%}
<ol>
{% for item in _items %}
{% if loop.index is same as(_items|length - 1) and _goBackTitle != '' %}
{% if loop.index is same as(_items|length - 1) and _goBackTitle is not same as('') %}
<li class="d-tablet-none">
<Icon name="chevron-left" />
<Link href="{{ item.url }}" color="primary" isUnderlined>{{ _goBackTitle }}</Link>
</li>
{% endif %}
<li class="d-none d-tablet-flex">
{% if loop.index0 != 0 %}
{% if loop.index0 is not same as(0) %}
<Icon name="chevron-right" />
{% endif %}
<Link
href="{{ item.url }}"
color="{{ loop.last ? 'secondary' : 'primary' }}"
isUnderlined="{{ loop.last != true }}"
isUnderlined="{{ loop.last is not same as(true) }}"
aria-current="{{ loop.last ? 'page' : 'false' }}"
>
{{ item.title }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootDisabledClassName, _rootItemClassName, _rootValidationStateClassName, _styleProps.className ] -%}
{%- set _labelClassName = [ _labelClassName, _labelHiddenClassName, _labelRequiredClassName ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

{# Deprecations #}
{% if _validationState is same as('error') %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _isOpenClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<{{ _elementType }}
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutReservedAttributes = props | filter((value, prop) => prop != 'data-spirit-populate-field') -%}
{%- set _mainPropsWithoutReservedAttributes = props | filter((value, prop) => prop is not same as('data-spirit-populate-field')) -%}

<li
{{ mainProps(_mainPropsWithoutReservedAttributes) }}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-twig/src/Resources/components/Icon/Icon.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _mainProps = props | filter((value, prop) => prop != 'ariaHidden') | merge({
{%- set _mainProps = props | filter((value, prop) => prop is not same as('ariaHidden')) | merge({
'aria-hidden': _ariaHidden ? 'true' : 'false',
}) -%}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

{# Deprecations #}
{% deprecated 'Modal: The "Modal" component is deprecated, it will be replaced by implementation of "ModalComposed".' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootComposedClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

{# Deprecations #}
{% deprecated 'ModalComposed: The "ModalComposed" component is deprecated, it will be renamed to "Modal".' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootDisabledClassName, _rootItemClassName, _rootValidationStateClassName, _styleProps.className ] -%}
{%- set _labelClassName = [ _labelClassName, _labelHiddenClassName ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}
{%- set _allowedInputAttributes = [ 'autocomplete' ] -%}

<label {{ _labelForAttr | raw }} {{ mainProps(_mainPropsWithoutId) }} {{ styleProp(_styleProps) }} {{ classProp(_classNames) }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootDirectionClassName, _rootScrollbarDisabledClassName, _styleProps.className ] -%}
{%- set _indicatorsClassNames = [ _indicatorsClassName, _indicatorsShadowsClassName, _indicatorsBordersClassName ] -%}
{%- set _mainPropsWithoutReservedAttributes = props | filter((value, prop) => prop != 'data-spirit-direction') -%}
{%- set _mainPropsWithoutReservedAttributes = props | filter((value, prop) => prop is not same as('data-spirit-direction')) -%}

<div
{{ mainProps(_mainPropsWithoutReservedAttributes) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootFluidClassName, _rootDisabledClassName, _rootValidationStateClassName, _styleProps.className ] -%}
{%- set _labelClassName = [ _labelClassName, _labelHiddenClassName, _labelRequiredClassName ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<div {{ mainProps(_mainPropsWithoutId) }} {{ styleProp(_styleProps) }} {{ classProp(_classNames) }}>
<label for="{{ _id }}" {{ classProp(_labelClassName) }}>{{ _label }}</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootAnimationClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutLocal = props | filter((value, prop) => prop != 'color' and prop != 'class') -%}
{%- set _mainPropsWithoutLocal = props | filter((value, prop) => prop is not same as('color') and prop is not same as('class')) -%}

{% embed "@spirit/icon.twig" with { props: {
name: 'spinner',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{# Miscellaneous #}
{%- set _styleProps = useStyleProps(props) -%}
{%- set _classNames = [ _rootClassName, _rootPlacementClassName, _rootDismissibleClassName, _styleProps.className ] -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop != 'id') -%}
{%- set _mainPropsWithoutId = props | filter((value, prop) => prop is not same as('id')) -%}

<div
{{ mainProps(_mainPropsWithoutId) }}
Expand Down
2 changes: 1 addition & 1 deletion packages/web-twig/src/Resources/partials/inputProps.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{%- for propName, propValue in transferringAttributes %}{%- if propValue is not null and propValue != '' %} {{ propName }}="{{ propValue }}"{% endif -%}{% endfor -%}
{%- for propName, propValue in transferringAttributes %}{%- if propValue is not null and propValue is not same as('') %} {{ propName }}="{{ propValue }}"{% endif -%}{% endfor -%}
2 changes: 1 addition & 1 deletion packages/web-twig/src/Resources/partials/mainProps.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{%- if id != null %} id="{{ id }}"{% endif -%}{%- for propName, propValue in transferringAttributes %}{%- if propValue is not null and propValue != '' %} {{ propName }}="{{ propValue }}"{% endif -%}{% endfor -%}
{%- if id is not same as(null) %} id="{{ id }}"{% endif -%}{%- for propName, propValue in transferringAttributes %}{%- if propValue is not null and propValue is not same as('') %} {{ propName }}="{{ propValue }}"{% endif -%}{% endfor -%}
2 changes: 1 addition & 1 deletion packages/web-twig/src/Resources/partials/props.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{%- if id != null %} id="{{ id }}"{% endif -%}{%- for dataPropName, dataPropValue in dataAttributes %} {{ dataPropName }}="{{ dataPropValue }}"{% endfor -%}
{%- if id is not same as(null) %} id="{{ id }}"{% endif -%}{%- for dataPropName, dataPropValue in dataAttributes %} {{ dataPropName }}="{{ dataPropValue }}"{% endfor -%}
2 changes: 1 addition & 1 deletion packages/web-twig/src/Resources/partials/styleProp.twig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{%- if style != null %}style="{{ style }}"{% endif -%}
{%- if style is not same as(null) %}style="{{ style }}"{% endif -%}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Link
href="{{ item.url }}"
color="{{ loop.last ? 'secondary' : 'primary' }}"
isUnderlined="{{ loop.last != true }}"
isUnderlined="{{ loop.last is not same as(true) }}"
aria-current="{{ loop.last ? 'page' : 'false' }}"
>{{ item.title }}</Link>
</li>
Expand Down

0 comments on commit 75548bb

Please sign in to comment.