Start using Twig Hooks autoprefixing in the Country templates

This commit is contained in:
Jacob Tobiasz 2024-04-25 13:10:36 +02:00
parent 5461ad1200
commit f1551b1b82
No known key found for this signature in database
GPG key ID: 3F84290201B006E0
17 changed files with 28 additions and 50 deletions

View file

@ -19,6 +19,12 @@
"homepage": "https://github.com/Sylius/Sylius/contributors"
}
],
"repositories": [
{
"type": "path",
"url": "/packages/twig-hooks"
}
],
"require": {
"php": "^8.2",
"ext-dom": "*",

View file

@ -6,8 +6,6 @@ twig_hooks:
props:
country: '@=_context.resource'
form: '@=_context.form'
parentMainHook: '@=_context.parent_main_hook'
parentFallbackHook: '@=_context.parent_fallback_hook'
'sylius_admin.country.create.content.form':
sections:

View file

@ -6,8 +6,6 @@ twig_hooks:
props:
country: '@=_context.resource'
form: '@=_context.form'
parentMainHook: '@=_context.parent_main_hook'
parentFallbackHook: '@=_context.parent_fallback_hook'
configuration:
method: 'PUT'

View file

@ -1 +1 @@
{{ form_row(hookable_data.form.code, sylius_test_form_attribute('code')) }}
{{ form_row(get_hookable_context().form.code, sylius_test_form_attribute('code')) }}

View file

@ -1 +1 @@
{{ form_row(hookable_data.form.enabled, sylius_test_form_attribute('enabled')|merge({ label_attr: { class: 'checkbox-switch' } })) }}
{{ form_row(get_hookable_context().form.enabled, sylius_test_form_attribute('enabled')|merge({ label_attr: { class: 'checkbox-switch' } })) }}

View file

@ -1,12 +1,5 @@
{% set main_hook = hook_name(hookable_data.parent_main_hook, 'details') %}
{% set fallback_hook = hook_name(hookable_data.parent_fallback_hook, 'details') %}
<div class="card mb-3">
<div class="card-body">
{% hook [main_hook, fallback_hook] with {
parent_main_hook: main_hook,
parent_fallback_hook: fallback_hook,
form: hookable_data.form,
} %}
{% hook 'details' %}
</div>
</div>

View file

@ -1,11 +1,11 @@
<div class="card mb-3">
<div class="card-body">
{{ form_label(hookable_data.form.provinces) }}
{{ form_errors(hookable_data.form.provinces) }}
{{ form_label(get_hookable_context().form.provinces) }}
{{ form_errors(get_hookable_context().form.provinces) }}
<div {{ sylius_test_html_attribute('provinces') }}>
{% for key, provinceForm in hookable_data.form.provinces %}
{% for key, provinceForm in get_hookable_context().form.provinces %}
<div class="card mb-3" {{ sylius_test_html_attribute('province') }}>
<div class="card-body">
<div class="row">
@ -45,6 +45,6 @@
{% endfor %}
</div>
{{ form_widget(hookable_data.form.provinces.vars.button_add, sylius_test_form_attribute('add-province')) }}
{{ form_widget(get_hookable_context().form.provinces.vars.button_add, sylius_test_form_attribute('add-province')) }}
</div>
</div>

View file

@ -1,9 +1,3 @@
{% set main_hook = hook_name(hookable_data.parent_main_hook, 'sections') %}
{% set fallback_hook = hook_name(hookable_data.parent_fallback_hook, 'sections') %}
<div class="col-12">
{% hook [main_hook, fallback_hook] with hookable_data|merge({
parent_main_hook: main_hook,
parent_fallback_hook: fallback_hook,
}) %}
{% hook 'sections' %}
</div>

View file

@ -1,9 +1,6 @@
{# Rendered with using \Sylius\Bundle\AdminBundle\TwigComponent\Country\CountryType #}
{% form_theme form '@SyliusAdmin/Shared/form_theme.html.twig' %}
{% set main_hook = hook_name(parent_main_hook, 'form') %}
{% set fallback_hook = hook_name(parent_fallback_hook, 'form') %}
{% set hookable_configuration = get_hookable_configuration() %}
<div class="container-xl" {{ attributes }}>
{{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }}
@ -13,10 +10,7 @@
{{ form_errors(form) }}
{{ form_widget(form._token) }}
{% hook [main_hook, fallback_hook] with {
parent_main_hook: main_hook,
parent_fallback_hook: fallback_hook,
form,
} %}
{% hook 'form' with { form } %}
{{ form_end(form, {render_rest: false}) }}
</div>

View file

@ -1 +1 @@
{{ form_row(hookable_data.form._password) }}
{{ form_row(get_hookable_context().form._password) }}

View file

@ -1 +1 @@
{{ form_row(hookable_data.form._remember_me) }}
{{ form_row(get_hookable_context().form._remember_me) }}

View file

@ -1,3 +1,3 @@
{% set last_username = hookable_data.last_username|default('') %}
{% set last_username = get_hookable_context().last_username|default('') %}
{{ form_row(hookable_data.form._username, { 'value': last_username }) }}
{{ form_row(get_hookable_context().form._username, { 'value': last_username }) }}

View file

@ -1,4 +1,4 @@
{% set lastError = hookable_data.last_error|default(null) %}
{% set lastError = get_hookable_context().last_error|default(null) %}
{% if lastError is not null %}
<div class="alert alert-danger" {{ sylius_test_html_attribute('invalid-credentials-message') }}>

View file

@ -1,9 +1,8 @@
{% set form = hookable_data.form %}
{% set form = get_hookable_context().form %}
{% form_theme form '@SyliusAdmin/Shared/form_theme.html.twig' %}
{% set main_hook = hook_name(hookable_data.parent_main_hook, 'form') %}
{{ form_start(form, {'action': path('sylius_admin_login_check'), 'attr': {'class': 'ui large loadable form', 'novalidate': 'novalidate'}}) }}
{% hook main_hook with hookable_data|merge({ parent_main_hook: main_hook }) %}
{% hook 'form' %}
<input type="hidden" name="_csrf_admin_security_token" value="{{ csrf_token('admin_authenticate') }}">
{{ form_end(form, {'render_rest': false}) }}

View file

@ -1,7 +1,5 @@
{% set main_hook = hook_name(hookable_data.parent_main_hook, 'content') %}
<div class="card card-md">
<div class="card-body">
{% hook main_hook with hookable_data|merge({ parent_main_hook: main_hook }) %}
{% hook 'content' %}
</div>
</div>

View file

@ -1,7 +1,5 @@
{% extends '@SyliusAdmin/Shared/Layout/base.html.twig' %}
{% set main_hook = hook_name(_self) %}
{% block title %}Sylius | {{ 'sylius.ui.administration_panel_login'|trans }}{% endblock %}
{% block body_class %}d-flex flex-column{% endblock %}
@ -9,7 +7,7 @@
{% block body %}
<div class="page page-center">
<div class="container container-tight py-4">
{% hook main_hook with { parent_main_hook: main_hook, form, last_error, last_username } %}
{% hook 'sylius_admin.security.login' with { form, last_error, last_username } %}
</div>
</div>
{% endblock %}

View file

@ -13,8 +13,8 @@ declare(strict_types=1);
namespace Sylius\Bundle\AdminBundle\TwigComponent\Country;
use Sylius\Bundle\AdminBundle\TwigComponent\HookableComponentTrait;
use Sylius\Component\Addressing\Model\Country;
use Sylius\TwigHooks\LiveComponent\HookableLiveComponentTrait;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
@ -26,7 +26,7 @@ use Symfony\UX\LiveComponent\LiveCollectionTrait;
final class CountryType
{
use DefaultActionTrait;
use HookableComponentTrait;
use HookableLiveComponentTrait;
use LiveCollectionTrait;
#[LiveProp(fieldName: 'formData')]